Python 纸浆优化解未定义

Python 纸浆优化解未定义,python,optimization,pulp,Python,Optimization,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')

我试图使用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'
进口纸浆
#实例化我们的问题类
模型=纸浆.LpProblem(“成本最小化问题”,纸浆.LpMinimize)
W=pill.LpVariable('W',cat='Integer')
X=pill.LpVariable('X',cat='Integer')
Y=pill.LpVariable('Y',cat='Integer')
Z=pill.LpVariable('Z',cat='Integer')
#目标函数
模型+=1.33*W+1.76*X+1.46*Y+0.79*Z,“成本”
#约束条件
模型+=W+X+Y+Z==1
型号+=W>=0.1
型号+=W=0.1
模型+=X=0.1
模型+=Y=0.1

model+=Z当我实现相同的代码时,我得到的结果是“不可行”

这是有意义的,因为变量W、X、Y、Z都必须是整数,但随后将它们绑定为大于0.1,小于另一个小于1的数字


0.1和0.XX之间没有整数,因此没有可行的解决方案。

这是否回答了您的问题?您能显示解算器日志吗?谢谢,这很有效,但是在纸浆中有没有一种方法不指定为整数。就像当我使用excel solver解决相同问题时,我会得到32.567、38.9867等值。这可以通过使用纸浆来实现吗?将
cat='Integer'
替换为
cat='Continuous'
。看见