import numpy as np
import cvxpy as cp
n = 11
x = cp.Variable(n, integer=True)
Object = np.array([140 - 3 * 9 - 2 * 1.5,
300 - 1.5 * 60,
140 - 2 * 13,
60 - 0.5 * 13,
150 - 1.5 * 1.5 - 2 * 2.25,
180 - 2.5 * 9 - 1.5 * 1.5,
175 - 3 * 12 - 2 * 1.5,
105 - 2 * 2.5,
35-0.5 * 2.5,
40 - 1.5 * 12,
30 - 2.25 * 1.5])
material = np.array([[3, 0, 0, 0, 0, 2.5, 0, 0, 0, 0, 0],
[2, 0, 0, 0, 1.5, 1.5, 2, 0, 0, 0, 0],
[0, 1.5, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 2, 0.5, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1.5],
[0, 0, 0, 0, 0, 0, 3, 0, 0, 1.5, 0],
[0, 0, 0, 0, 0, 0, 0, 2, 0.5, 0, 0]]) # 羊毛,醋,开司米,丝绸,人造纤维,天鹅绒,棉布
material1 = np.array([0, 0, 0, 0, 0, 0, 0])
material2 = np.array([45000, 28000, 9000, 18000, 30000, 20000, 30000])
price = np.array([9, 1.5, 60, 13, 2.25, 12, 2.5])
predict1 = np.array([4200, 0, 0, 0, 2800, 3000, 0, 0, 0, 0, 0]) # 至少
predict2 = np.array([7000, 4000, 12000, 3000, np.inf, 5000, 5500, np.inf, np.inf, 6000, np.inf]) # 至多
waste = cp.Variable(n, integer=True)
# (a):给定产量,资源和需求的条件下:材料没用完的可以退,但是零碎布料不能退
prob_a = cp.Problem(cp.Maximize((Object @ x)),
[material1 <= (material @ x),
(material @ x) <= material2,
x <= predict2,
x >= predict1
]
)
prob_a.solve()
print("Optimal value:", prob_a.value)
print("Optimal solution:")
print(x.value)
Assertion failed: j->lb < j->ub
Error detected in file ..\src\npp\npp3.c at line 2131
|