15
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ロジスティクス・ネットワーク設計問題

Last updated at Posted at 2016-10-18

これなに

ロジスティクス・ネットワーク設計問題の実行例

需要を満たしつつ輸送費と生産費の和が最小となるように、どこで何をどれだけ生産し、どう輸送するかを求める。

Pythonで試す

諸元

python
製品 = list('AB')
需要地 = list('PQ')
工場 = list('XY')
レーン = (2, 2)

輸送費表

python
import numpy as np, pandas as pd
tbdi = pd.DataFrame(((j, k) for j in 需要地 for k in 工場), columns=['需要地', '工場'])
tbdi['輸送費'] = [1,2,3,1]
tbdi
需要地 工場 輸送費
0 P X 1
1 P Y 2
2 Q X 3
3 Q Y 1

需要表

python
tbde = pd.DataFrame(((j, i) for j in 需要地 for i in 製品), columns=['需要地', '製品'])
tbde['需要'] = [10, 10, 20, 20]
tbde
需要地 製品 需要
0 P A 10
1 P B 10
2 Q A 20
3 Q B 20

生産表

python
tbfa = pd.DataFrame(((k, l, i, 0, np.inf) for k, nl in zip(工場, レーン)
    for l in range(nl) for i in 製品), columns=['工場', 'レーン', '製品', '下限', '上限'])
tbfa['生産費'] = [1, np.nan, np.nan, 1, 3,  np.nan, 5, 3]
tbfa.dropna(inplace=True)
tbfa.ix[4, '上限'] = 10
tbfa
工場 レーン 製品 下限 上限 生産費
0 X 0 A 0 inf 1.0
3 X 1 B 0 inf 1.0
4 Y 0 A 0 10.000000 3.0
6 Y 1 A 0 inf 5.0
7 Y 1 B 0 inf 3.0

解く

python
from ortoolpy import logistics_network
_, tbdi2, _ = logistics_network(tbde, tbdi, tbfa)

結果:生産量(ValY)

python
tbfa
工場 レーン 製品 下限 上限 生産費 VarY ValY
0 X 0 A 0 inf 1.0 v9 20.0
3 X 1 B 0 inf 1.0 v10 10.0
4 Y 0 A 0 10.000000 3.0 v11 10.0
6 Y 1 A 0 inf 5.0 v12 0.0
7 Y 1 B 0 inf 3.0 v13 20.0

結果:輸送量(ValX)

python
tbdi2
需要地 工場 輸送費 製品 VarX ValX
0 P X 1 A v1 10.0
1 P X 1 B v2 10.0
2 Q X 3 A v3 10.0
3 Q X 3 B v4 0.0
4 P Y 2 A v5 0.0
5 P Y 2 B v6 0.0
6 Q Y 1 A v7 10.0
7 Q Y 1 B v8 20.0

以上

15
13
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?