[英]PULP optimization solution undefined
I was trying to optimize the following problem using python pulp我试图使用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'
The solution turns out to be undefined.结果证明该解决方案是未定义的。 Am I making a mistake in problem formulation or missing out something ?我是在问题表述上犯了错误还是遗漏了什么?
When I implement the same code I get the result 'Infeasible'.当我实现相同的代码时,我得到了“不可行”的结果。
This makes sense as your variables W, X, Y, Z
all have to be integers, but you then bound them to be more than 0.1, and less than another number which is less than 1.这是有道理的,因为您的变量W, X, Y, Z
都必须是整数,但是您随后将它们绑定为大于 0.1,并且小于另一个小于 1 的数字。
There are no integers inbetween 0.1 and 0.XX, so there is no feasible solution. 0.1 和 0.XX 之间没有整数,所以没有可行解。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.