例1: 加工奶制品的生产计划
问题一:奶制品加工厂用牛奶生产 A 1 A_1 A1, A 2 A_2 A2两种奶制品,1桶牛奶可以在甲类设备上用12 h加工成3 kg A 1 A_1 A1,或者在乙类设备上用8 h加工成4 kg A 2 A_2 A2,.根据市场需求,生产的 A 1 A_1 A1, A 2 A_2 A2、全部能售出,且每千克 A 1 A_1 A1,获利24元,每千克 A 2 A_2 A2获利16元.现在加工厂每天能得到50桶牛奶的供应,每天正式工人总的劳动时间为480 h,并且甲类设备每天至多能加工100 kg A 1 A_1 A1,乙类设备的加工能力没有限制.试为该厂制订一个生产计划,使每天获利最大,并进一步讨论以下3个附加问题:
1)若用35元可以买到1桶牛奶,应否作这项投资?若投资,每天最多购买多少桶牛奶?
2)若可以聘用临时工人以增加劳动时间,付给临时工人的工资最多是每小时几元?
3)由于市场需求变化,每千克 A 1 A_1 A1的获利增加到30元,应否改变生产计划?1
针对原始问题,我们可以假设生产 A 1 . A 2 A_1.A_2 A1.A2所消耗牛奶的桶数分别为 x 1 , x 2 x_1,x_2 x1,x2利润为 y y y那么即可建立模型
M a x y = 24 ∗ 3 ∗ x 1 + 16 ∗ 4 ∗ x 2 S . T . { x 1 + x 2 < = 50 12 ∗ x 1 + 8 ∗ x 2 < = 480 3 ∗ x 1 < = 100 x 1 , x 2 > = 0 Max\quad y = 24*3*x_1 + 16*4*x_2\\ S.T.\left\{ \begin{aligned} x_1+x_2<=50\\ 12*x_1+8*x_2<=480\\ 3*x_1<=100\\ x_1,x_2>=0\\ \end{aligned} \right. Maxy=24∗3∗x1+16∗4∗x2S.T.⎩⎪⎪⎪⎪⎨⎪⎪⎪⎪⎧x1+x2<=5012∗x1+8∗x2<=4803∗x1<=100x1,x2>=0
原始问题结果最终由代码求解(代码1-1)得到
目标函数值是: 3360.0
x_1 = 20.0
x_2 = 30.0
故原始问题用20桶牛奶生产 A 1 30 桶 牛 奶 生 产 A 2 A_130桶牛奶生产A_2 A130桶牛奶生产A2即可得到利润的最大值为3360
第一个附加问题将目标函数进行适当改动即可,假设购买了 x 3 x_3 x3桶牛奶
M a x y = 24 ∗ 3 ∗ x 1 + 16 ∗ 4 ∗ x 2 − 35 ∗ x 3 S . T . { x 1 + x 2 < = 50 + x 3 12 ∗ x 1 + 8 ∗ x 2 < = 480 3 ∗ x 1 < = 100 x 1 , x 2 > = 0 Max\qquad y = 24*3*x_1 + 16*4*x_2 - 35*x_3\\ S.T.\left\{ \begin{aligned} x_1+x_2<=50+x_3\\ 12*x_1+8*x_2<=480\\ 3*x_1<=100\\ x_1,x_2>=0\\ \end{aligned} \right. Maxy=24∗3∗x1+16∗4∗x2−35∗x3S.T.⎩⎪⎪⎪⎪⎨⎪⎪⎪⎪⎧x1+x2<=50+x312∗x1+8∗x2<=4803∗x1<=100x1,x2>=0
由代码1-2重新求解得到
目标函数值是: 3438.0
x_1 = 8.0
x_2 = 48.0
x_3 = 6.0
可得应该做这笔投资,增加6桶牛奶的购买量即可
影子价格
增加了6桶牛奶的量,利润增加了3438-3360=78。每增加1桶牛奶可增加13的利润,在问题中,13即为牛奶的影子价格。为投资购买牛奶时牛奶桶数即为限制利润变的更大的主要因素,为紧约束
gurobipy有相关影子价格求解的相关函数2 因此对于附加问题1不用重新求解,求解影子价格进行分析即可,在代码1-1的基础上进行输出即可,详见代码1-3
x_1 20
x_2 30
machine_Time 40
Milk 48
Time 2
对于Slack
machine_Time为40对应的约束条件为x1*3<=100,这就说明,甲机器在此生产情况下仍有40h的剩余。
表明原料、劳动时间已用完,而甲类设备的能力有余.一般称“资源”剩余为0的约束为紧约束(有效约束).
对于影子价格
目标函数可以看作“效益”,成为紧约束的“资源”一旦增加,“效益”必然跟着增长.输出第影子价格给出这3种资源在最优解下“资源”增加1个单位时“效益”的增量:原料[MILK]增加1个单位(1桶牛奶)时利润增长48元,劳动时间[TIME]增加1个单位( 1h)时利润增长2元,而增加非紧约束[ CPCT]甲类设备的能力显然不会使利润增长.这里,“效益”的增量可以看作“资源”的潜在价值,经济学上称为影子价格,即1桶牛奶的影子价格为48元,1 h劳动的影子价格为2元,甲类设备的影子价格为0.
由此可得若可以聘用临时工人以增加劳动时间,付给临时工人的工资最多是每小时几元。而牛奶的影子价格也与改变模型重新求解得到的结果一致
以下为目标函数中的系数发生变化时最优解条件不变,目标系数的变化范围
x_1为64-96 x_2为48-72 注意:x_1系数的允许范围需要x_2系数64不变,反之亦然.
x_1 64
x_2 48
x_1 96
x_2 72
以下为约束条件右端常数项的变化范围
Milk 43.3333
Time 400
machine_Time 60
Milk 60
Time 533.333
machine_Time inf
由此可回答上述问题三问
(1)Milk影子价格48 大于一桶牛奶的成本。应该做这项投资,最多可购买10桶牛奶。
(2)Time的影子价格为2,说明每增加1h的工作时间可带来2r的收益。则雇用临时工人的最高工资为2r/h
(3)每千克1的获利增加到30元,那么目标函数中A1的系数就变为了 30*3 = 90 < 96 可不更改原来的生产计划。
代码1-1
import gurobipy as grb
model = grb.Model("Milk_1_1")
# 定义变量
x1 = model.addVar(lb=0,ub=50,vtype=grb.GRB.INTEGER, name='x_1')
x2 = model.addVar(lb=0,ub=50,vtype=grb.GRB.INTEGER, name='x_2')
# 添加约束
model.addConstr(x1+x2<=50)
model.addConstr(12*x1+8*x2<=480)
model.addConstr(x1*3<=100)
# 目标函数
model.setObjective(24*3*x1+16*4*x2, grb.GRB.MAXIMIZE)
# 求解
model.optimize()
print('目标函数值是:', model.objVal)
for v in model.getVars():
print(v.varName, '=', v.x)
输出:
Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 3 rows, 2 columns and 5 nonzeros
Model fingerprint: 0x39cf0539
Variable types: 0 continuous, 2 integer (0 binary)
Coefficient statistics:
Matrix range [1e+00, 1e+01]
Objective range [6e+01, 7e+01]
Bounds range [5e+01, 5e+01]
RHS range [5e+01, 5e+02]
Found heuristic solution: objective 3016.0000000
Presolve removed 1 rows and 0 columns
Presolve time: 0.00s
Presolved: 2 rows, 2 columns, 4 nonzeros
Variable types: 0 continuous, 2 integer (0 binary)
Root relaxation: objective 3.360000e+03, 2 iterations, 0.00 seconds
Nodes | Current Node | Objective Bounds | Work
Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time
* 0 0 0 3360.0000000 3360.00000 0.00% - 0s
Explored 0 nodes (2 simplex iterations) in 0.04 seconds
Thread count was 8 (of 8 available processors)
Solution count 2: 3360 3016
Optimal solution found (tolerance 1.00e-04)
Best objective 3.360000000000e+03, best bound 3.360000000000e+03, gap 0.0000%
目标函数值是: 3360.0
x_1 = 20.0
x_2 = 30.0
代码1-2
import gurobipy as grb
model = grb.Model("Milk_1_2")
# 定义变量
x1 = model.addVar(lb=0,ub=50,vtype=grb.GRB.INTEGER, name='x_1')
x2 = model.addVar(lb=0,ub=50,vtype=grb.GRB.INTEGER, name='x_2')
x3 = model.addVar(lb=0,ub=50,vtype=grb.GRB.INTEGER, name='x_3')
# 添加约束
model.addConstr(x1+x2<=50+x3)
model.addConstr(12*x1+8*x2<=480)
model.addConstr(x1*3<=100)
# 目标函数
model.setObjective(24*3*x1+16*4*x2-35*x3, grb.GRB.MAXIMIZE)
# 求解
model.optimize()
print('目标函数值是:', model.objVal)
for v in model.getVars():
print(v.varName, '=', v.x)
输出
Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 3 rows, 3 columns and 6 nonzeros
Model fingerprint: 0x990a2b23
Variable types: 0 continuous, 3 integer (0 binary)
Coefficient statistics:
Matrix range [1e+00, 1e+01]
Objective range [4e+01, 7e+01]
Bounds range [5e+01, 5e+01]
RHS range [5e+01, 5e+02]
Found heuristic solution: objective 3016.0000000
Presolve removed 1 rows and 0 columns
Presolve time: 0.00s
Presolved: 2 rows, 3 columns, 5 nonzeros
Variable types: 0 continuous, 3 integer (0 binary)
Root relaxation: objective 3.446667e+03, 1 iterations, 0.00 seconds
Nodes | Current Node | Objective Bounds | Work
Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time
0 0 3446.66667 0 2 3016.00000 3446.66667 14.3% - 0s
H 0 0 3430.0000000 3446.66667 0.49% - 0s
H 0 0 3438.0000000 3446.66667 0.25% - 0s
0 0 3446.66667 0 2 3438.00000 3446.66667 0.25% - 0s
Explored 1 nodes (1 simplex iterations) in 0.04 seconds
Thread count was 8 (of 8 available processors)
Solution count 3: 3438 3430 3016
Optimal solution found (tolerance 1.00e-04)
Best objective 3.438000000000e+03, best bound 3.438000000000e+03, gap 0.0000%
目标函数值是: 3438.0
x_1 = 8.0
x_2 = 48.0
x_3 = 6.0
代码1-3
import gurobipy as grb
from gurobipy import *
model = grb.Model("Milk_1_1")
# 定义变量
x1 = model.addVar( name='x_1')
x2 = model.addVar( name='x_2')
# 添加约束
model.addConstr(x1+x2<=50,"Milk")
model.addConstr(12*x1+8*x2<=480,"Time")
model.addConstr(x1*3<=100,"machine_Time")
# 目标函数
model.setObjective(24*3*x1+16*4*x2, grb.GRB.MAXIMIZE)
# 求解
model.optimize()
print('目标函数值是:', model.objVal)
for v in model.getVars():
print(v.varName, '=', v.x)
#print("影子价格:",model.Pi)
if model.status == GRB.OPTIMAL:
model.printAttr('X')
model.printAttr('Slack')
model.printAttr('Pi')
model.printAttr('SAObjLow')
model.printAttr('SAObjUp')
model.printAttr('SARHSLow')
model.printAttr('SARHSUp')
#注意:vtype=grb.GRB.INTEGER, vtype=grb.GRB.INTEGER,在固定变量类型之后,求解Pi会报错
#
输出:
Using license file C:\Users\mzq\gurobi.lic
Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 3 rows, 2 columns and 5 nonzeros
Model fingerprint: 0x31f8b533
Coefficient statistics:
Matrix range [1e+00, 1e+01]
Objective range [6e+01, 7e+01]
Bounds range [0e+00, 0e+00]
RHS range [5e+01, 5e+02]
Presolve removed 1 rows and 0 columns
Presolve time: 0.02s
Presolved: 2 rows, 2 columns, 4 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 3.6000000e+03 2.416667e+01 0.000000e+00 0s
2 3.3600000e+03 0.000000e+00 0.000000e+00 0s
Solved in 2 iterations and 0.04 seconds
Optimal objective 3.360000000e+03
目标函数值是: 3360.0
x_1 = 20.0
x_2 = 30.0
Variable X
-------------------------
x_1 20
x_2 30
Constraint Slack
-------------------------
machine_Time 40
Constraint Pi
-------------------------
Milk 48
Time 2
Variable SAObjLow
-------------------------
x_1 64
x_2 48
Variable SAObjUp
-------------------------
x_1 96
x_2 72
Constraint SARHSLow
-------------------------
Milk 43.3333
Time 400
machine_Time 60
Constraint SARHSUp
-------------------------
Milk 60
Time 533.333
machine_Time inf
奶制品的生产销售计划
例1:给出的 A 1 A_1 A1, A 2 A_2 A2两种奶制品的生产条件、利润及工厂的“资源”限制全都不变.为增加工厂的获利,开发了奶制品的深加工技术:用2 h和3元加工费,可将1kg A 1 A_1 A1加工成0.8 kg高级奶制品 B 1 B_1 B1,也可将1 kg A 2 A_2 A2加工成0.75 kg高级奶制品 B 2 B_2 B2,每千克 B 1 B_1 B1能获利44元,每千克 B 2 B_2 B2能获利32元.试为该厂制订一个生产销售计划,使每天的净利润最大,并讨论以下问题:
(1)若投资30元可以增加供应1桶牛奶,投资3元可以增加1 h劳动时间,应否作这些投资?若每天投资150元,可赚回多少?
(2)每千克高级奶制品$B_1$,$B_2$,的获利经常有10%的波动,对制订的生产销售计划有无影响?若每千克$B_1$的获利下降10% ,计划应该变化吗?
(3)若公司已经签订了每天销售10 kg $A_1$的合同并且必须满足,该合同对公司的利润有什么影响?
在原来的模型基础上进行改动,假设变量 x 1 , x 2 , x 3 , x 4 , x 5 , x 6 x_1,x_2,x_3,x_4,x_5,x_6 x1,x2,x3,x4,x5,x6
x 1 , x 2 , x 3 , x 4 x_1,x_2,x_3,x_4 x1,x2,x3,x4对应 A 1 , A 2 , B 1 , B 2 A_1,A_2,B_1,B_2 A1,A2,B1,B2的产量,其中 x 5 x_5 x5的 A 1 A_1 A1用来生产 B 1 B_1 B1, x 6 x_6 x6的 A 2 A_2 A2用来生产 B 2 B_2 B2那么可建立模型如下
M a x q q u a d y = 24 ∗ x 1 + 16 ∗ x 2 + 44 ∗ x 3 + 32 ∗ x 4 − 3 ∗ ( x 5 + x 6 ) S . T . { x 1 + x 5 3 + x 2 + x 6 4 < = 50 12 ∗ x 1 + x 5 3 + 8 ∗ x 2 + x 6 4 + 2 ∗ ( x 5 + x 6 ) < = 480 x 1 + x 5 < = 100 0.8 ∗ x 5 = x 3 0.75 ∗ x 6 = x 4 x 1 , x 2 , x 3 , x 4 , x 5 , x 6 > = 0 Max \\qquad y = 24*x_1 + 16*x_2 + 44*x_3 + 32*x_4 - 3*(x_5+x_6)\\ S.T.\left\{ \begin{aligned} \frac{x_1+x_5}{3}+\frac{x_2+x_6}{4}<=50\\ 12*\frac{x_1+x_5}{3}+8*\frac{x_2+x_6}{4} + 2*(x_5+x_6)<=480\\ x_1+x_5<=100\\ 0.8 * x_5 = x_3\\ 0.75 * x_6 = x_4\\ x_1,x_2,x_3,x_4,x_5,x_6>=0\\ \end{aligned} \right. Maxqquady=24∗x1+16∗x2+44∗x3+32∗x4−3∗(x5+x6)S.T.⎩⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎧3x1+x5+4x2+x6<=5012∗3x1+x5+8∗4x2+x6+2∗(x5+x6)<=480x1+x5<=1000.8∗x5=x30.75∗x6=x4x1,x2,x3,x4,x5,x6>=0
目标函数值是: 3460.8
x_2 168
x_3 19.2
x_5 24
Machine_Time 76
Milk_Num 37.92
Worker_Time 3.26
bound1 -44
bound2 -32
x_1 -inf
x_2 13.9
x_3 40.8333
x_4 -inf
x_5 -5.53333
x_6 -inf
x_1 25.68
x_2 24.15
x_3 63.75
x_4 34.0267
x_5 12.8
x_6 -1.48
Milk_Num 26.6667
Worker_Time 400
Machine_Time 24
bound1 -inf
bound2 -inf
Milk_Num 60
Worker_Time 733.333
Machine_Time inf
bound1 19.2
最终求解得到结果:
目标函数值:3460.8
x_2 168
x_3 19.2
x_5 24
而第一问:
(1)若投资30元可以增加供应1桶牛奶,投资3元可以增加1 h劳动时间,应否作这些投资?若每天投资150元,可赚回多少?
根据求解得到的影子价格,一桶牛奶的影子价格为37.92 > 30 1h工作时间的影子价格为 3.26 > 3故应该做这些投资。而若拥有150元,根据灵敏性分析中的SARHSLow(约束条件右端常数最小值)SARHSUp (约束条件右端常数最大值)可得,影子价格有效的范围为
Milk_Num:[26.6667,60] Worker_Time:[400,733.333]。
故在150r的范围内,影子价格均有效。故可用来增加5桶牛奶增加189.6的收益
而第二问:
(2)每千克高级奶制品$B_1$,$B_2$,的获利经常有10%的波动,对制订的生产销售计划有无影响?若每千克$B_1$的获利下降10% ,计划应该变化吗?
根据灵敏性分析中的SAObj,x_3.x_4 的在计划不变的情况下系数变化范围分别为[40.8333,63.75],[0,34.0267],而原来 x_3,x_4 的系数分别为44和32。 所以当 B_1 的获利向下波动 10% ,或B_2的获利向上波动10%时,上面得到的生产销售计划将不再一定是最优的,应该重新制订.如若每千克B,的获利下降10% ,应将原模型式中x_3,的系数改为39.6,重新计算,见代码2-2 得到的最优解。可见计划变化很大,这就是说,(最优)生产计划对B_1或B_2,获利的波动是很敏感的.
新计划:
目标函数值是: 3400.0
x_2 160
x_4 30
x_6 40
而第三问:
(3)若公司已经签订了每天销售10 kg $A_1$的合同并且必须满足,该合同对公司的利润有什么影响?
(Reduce Cost 的意义以及应用 列出最优单纯形表中判别数所在行的变量的系数,表示当变量有微小变动时,目标函数的变化率。)
可重新求解,也可利用 Reduce Cost 直接得出结果,此部分有待完善
代码2-1
import gurobipy as grb
from gurobipy import *
model = grb.Model("Milk_2_1")
# 定义变量
x1 = model.addVar(lb=0, name='x_1')
x2 = model.addVar(lb=0, name='x_2')
x3 = model.addVar(lb=0, name='x_3')
x4 = model.addVar(lb=0, name='x_4')
x5 = model.addVar(lb=0, name='x_5')
x6 = model.addVar(lb=0, name='x_6')
# 添加约束
model.addConstr((x1+x5)/3 + (x2+x6)/4 <= 50,"Milk_Num")
model.addConstr(12*(x1+x5)/3 + 8*(x2+x6)/4 + 2*(x5+x6)<= 480,"Worker_Time")
model.addConstr((x1+x5)<=100,"Machine_Time")
model.addConstr(0.8*x5 == x3,"bound1")
model.addConstr(0.75*x6 == x4,"bound2")
# 目标函数
model.setObjective(24*x1 + 16*x2 + 44*x3 + 32*x4 -3*(x5+x6), grb.GRB.MAXIMIZE)
# 求解
model.optimize()
print('目标函数值是:', model.objVal)
#for v in model.getVars():
# print(v.varName, '=', v.x)
if model.status == GRB.OPTIMAL:
model.printAttr('X')
model.printAttr('Slack')
model.printAttr('Pi')
model.printAttr('SAObjLow')
model.printAttr('SAObjUp')
model.printAttr('SARHSLow')
model.printAttr('SARHSUp')
model.printAttr('RC')
#注意:vtype=grb.GRB.INTEGER, vtype=grb.GRB.INTEGER,在固定变量类型之后,求解Pi会报错
#
输出
Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 5 rows, 6 columns and 14 nonzeros
Model fingerprint: 0xec6a1c4f
Coefficient statistics:
Matrix range [3e-01, 6e+00]
Objective range [3e+00, 4e+01]
Bounds range [0e+00, 0e+00]
RHS range [5e+01, 5e+02]
Presolve removed 2 rows and 2 columns
Presolve time: 0.01s
Presolved: 3 rows, 4 columns, 10 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 4.8300000e+03 7.370950e+01 0.000000e+00 0s
3 3.4608000e+03 0.000000e+00 0.000000e+00 0s
Solved in 3 iterations and 0.01 seconds
Optimal objective 3.460800000e+03
目标函数值是: 3460.8
Variable X
-------------------------
x_2 168
x_3 19.2
x_5 24
Constraint Slack
-------------------------
Machine_Time 76
Constraint Pi
-------------------------
Milk_Num 37.92
Worker_Time 3.26
bound1 -44
bound2 -32
Variable SAObjLow
-------------------------
x_1 -inf
x_2 13.9
x_3 40.8333
x_4 -inf
x_5 -5.53333
x_6 -inf
Variable SAObjUp
-------------------------
x_1 25.68
x_2 24.15
x_3 63.75
x_4 34.0267
x_5 12.8
x_6 -1.48
Constraint SARHSLow
-------------------------
Milk_Num 26.6667
Worker_Time 400
Machine_Time 24
bound1 -inf
bound2 -inf
Constraint SARHSUp
-------------------------
Milk_Num 60
Worker_Time 733.333
Machine_Time inf
bound1 19.2
Variable RC
-------------------------
x_1 -1.68
x_6 -1.52
代码2-2
import gurobipy as grb
from gurobipy import *
model = grb.Model("Milk_2_2")
# 定义变量
x1 = model.addVar(lb=0, name='x_1')
x2 = model.addVar(lb=0, name='x_2')
x3 = model.addVar(lb=0, name='x_3')
x4 = model.addVar(lb=0, name='x_4')
x5 = model.addVar(lb=0, name='x_5')
x6 = model.addVar(lb=0, name='x_6')
# 添加约束
model.addConstr((x1+x5)/3 + (x2+x6)/4 <= 50,"Milk_Num")
model.addConstr(12*(x1+x5)/3 + 8*(x2+x6)/4 + 2*(x5+x6)<= 480,"Worker_Time")
model.addConstr((x1+x5)<=100,"Machine_Time")
model.addConstr(0.8*x5 == x3,"bound1")
model.addConstr(0.75*x6 == x4,"bound2")
# 目标函数
model.setObjective(24*x1 + 16*x2 + 39.6*x3 + 32*x4 -3*(x5+x6), grb.GRB.MAXIMIZE)
# 求解
model.optimize()
print('目标函数值是:', model.objVal)
#for v in model.getVars():
# print(v.varName, '=', v.x)
if model.status == GRB.OPTIMAL:
model.printAttr('X')
输出
Using license file C:\Users\mzq\gurobi.lic
Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 5 rows, 6 columns and 14 nonzeros
Model fingerprint: 0x06e710c1
Coefficient statistics:
Matrix range [3e-01, 6e+00]
Objective range [3e+00, 4e+01]
Bounds range [0e+00, 0e+00]
RHS range [5e+01, 5e+02]
Presolve removed 2 rows and 2 columns
Presolve time: 0.01s
Presolved: 3 rows, 4 columns, 10 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 4.3020000e+03 7.370950e+01 0.000000e+00 0s
2 3.4000000e+03 0.000000e+00 0.000000e+00 0s
Solved in 2 iterations and 0.03 seconds
Optimal objective 3.400000000e+03
目标函数值是: 3400.0
Variable X
-------------------------
x_2 160
x_4 30
x_6 40
参考文献
数学模型(第五版) .高等教育出版社 --姜启源、谢金星、叶俊 ↩︎
Python最优化算法实战 北京大学出版社 --苏振裕 ↩︎