簡體   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