我正在尝试通过编程解决线性整数,并遇到了一个名为TypeError: float argument required, not str
的问题。
这是我目前的代码:
from pulp import *
y = pulp.LpVariable.dicts('y', (M, C, W), None, pulp.LpInteger)
prob += pulp.lpSum(cost[m][c][w]*y[m][c][w] for m in M for c in C for w in W)
for i in M:
for j in C:
prob += pulp.lpSum(y[i][j][k] for k in W)==x[j][i]
prob.writeLP('Resource_Dispatch.lp')
答案 0 :(得分:1)
自:
y = pulp.LpVariable.dicts('y', (M, C, W), None, pulp.LpInteger)
要:
y = pulp.LpVariable.dicts('y', (M, C, W), None, None, pulp.LpInteger)
第一行出了什么问题,下限是None
,而上限是pulp.LpInteger