Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我的纸浆(线性规划批量)代码中不断出现错误,怎么了?_Python_Error Handling_Linear Programming_Pulp - Fatal编程技术网

Python 我的纸浆(线性规划批量)代码中不断出现错误,怎么了?

Python 我的纸浆(线性规划批量)代码中不断出现错误,怎么了?,python,error-handling,linear-programming,pulp,Python,Error Handling,Linear Programming,Pulp,我需要用线性规划分析一个批量问题,但我的纸浆代码不能正常工作 from pulp import * prob = LpProblem("Lot_Sizing_Problem", LpMinimize) period = [] for i in range(H): period.append(i) order = LpVariable.dicts('order', period, lowBound = 0, upBound = 1, cat='integer'), orderamou

我需要用线性规划分析一个批量问题,但我的纸浆代码不能正常工作

from pulp import *

prob = LpProblem("Lot_Sizing_Problem", LpMinimize)

period = []
for i in range(H):
    period.append(i)

order = LpVariable.dicts('order', period, lowBound = 0, upBound = 1, cat='integer'),
orderamount = LpVariable.dicts('orderamount', period, lowBound = 0, cat='integer'),
inventory = LpVariable.dicts('orderamount', period, lowBound = 0, cat='integer'),

prob += lpSum([A*period[i]+h*(inventory[i]+orderamount[i]-D[i]) for i in period])

prob += (inventory[i+1] for i in period) == inventory[i]+orderamount[i]-D[i]
prob += (orderamount[i] for i in period) <= M*order[i]
prob += (orderamount[i] for i in period) == D[i] - inventory[i]

prob.solve()

谢谢

有相当多的错误

from pulp import *

prob = LpProblem("Lot_Sizing_Problem", LpMinimize)

H=10
h=0.5
A=10
C=18
D=[12,10,13,14,13,15,17,20,19,14]
M=100

period = list(range(H))

order = LpVariable.dicts('order', period, lowBound = 0, upBound = 1, cat='integer')
orderamount = LpVariable.dicts('orderamount', period, lowBound = 0, cat='integer')
inventory = LpVariable.dicts('inventory', period, lowBound = 0, cat='integer')

prob += lpSum([A*period[i]+h*(inventory[i]+orderamount[i]-D[i]) for i in period])

for i in period:
  if i<H-1:
    prob += inventory[i+1]  == inventory[i]+orderamount[i]-D[i]
  prob += orderamount[i]  <= M*order[i]
  prob += orderamount[i]  == D[i] - inventory[i]

prob.solve()
等等

from pulp import *

prob = LpProblem("Lot_Sizing_Problem", LpMinimize)

H=10
h=0.5
A=10
C=18
D=[12,10,13,14,13,15,17,20,19,14]
M=100

period = list(range(H))

order = LpVariable.dicts('order', period, lowBound = 0, upBound = 1, cat='integer')
orderamount = LpVariable.dicts('orderamount', period, lowBound = 0, cat='integer')
inventory = LpVariable.dicts('inventory', period, lowBound = 0, cat='integer')

prob += lpSum([A*period[i]+h*(inventory[i]+orderamount[i]-D[i]) for i in period])

for i in period:
  if i<H-1:
    prob += inventory[i+1]  == inventory[i]+orderamount[i]-D[i]
  prob += orderamount[i]  <= M*order[i]
  prob += orderamount[i]  == D[i] - inventory[i]

prob.solve()
order = [LpVariable(...) for i in period]