繁体   English   中英

PULP 优化解决方案未定义

[英]PULP optimization solution undefined

我试图使用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'

结果证明该解决方案是未定义的。 我是在问题表述上犯了错误还是遗漏了什么?

当我实现相同的代码时,我得到了“不可行”的结果。

这是有道理的,因为您的变量W, X, Y, Z都必须是整数,但是您随后将它们绑定为大于 0.1,并且小于另一个小于 1 的数字。

0.1 和 0.XX 之间没有整数,所以没有可行解。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM