我正在尝试使用python纸浆优化以下问题
import pulp
# Instantiate our problem class
model = pulp.LpProblem("Cost minimising problem", pulp.LpMinimize)
W = pulp.LpVariable('W', cat='Integer')
X = pulp.LpVariable('X', cat='Integer')
Y = pulp.LpVariable('Y', cat='Integer')
Z = pulp.LpVariable('Z', cat='Integer')
# Objective function
model += 1.33 * W + 1.76 * X + 1.46 * Y + 0.79 * Z,"Cost"
# Constraints
model += W + X + Y + Z == 1
model += W >= 0.1
model += W <= 0.75
model += X >= 0.1
model += X <= 0.85
model += Y >= 0.1
model += Y <= 0.65
model += Z >= 0.1
model += Z <= 0.40
# Solve our problem
model.solve()
pulp.LpStatus[model.status]
'Undefined'
结果证明是不确定的。我是在表达问题时犯了错误还是错过了某些东西?
答案 0 :(得分:1)
当我执行相同的代码时,得到的结果是“不可行”。
这很有意义,因为您的变量W, X, Y, Z
都必须是整数,但随后将它们限制为大于0.1,并且小于另一个小于1的数字。
0.1到0.XX之间没有整数,因此没有可行的解决方案。