parent
ab8bd7dfae
commit
7b70265a0d
@ -0,0 +1,23 @@
|
|||||||
|
import time
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
from scipy.optimize import linprog
|
||||||
|
start = time.time()
|
||||||
|
c = [-110,-120,-130,-110,-115,150]
|
||||||
|
c = (-np.array(c)).tolist()
|
||||||
|
A=[[1,1,0,0,0,0],
|
||||||
|
[0,0,1,1,1,0],
|
||||||
|
[8.8,6.1,2.0,4.2,5.0,-6],
|
||||||
|
[8.8,6.1,2.0,4.2,5.0,-3]
|
||||||
|
]
|
||||||
|
A[3]=(-np.array(A[3])).tolist()
|
||||||
|
b=[[200],[250],[0],[0]]
|
||||||
|
Aeq =[[1,1,1,1,1,-1]]
|
||||||
|
beq = [[0]]
|
||||||
|
LB= [0]*len(c)
|
||||||
|
UB= [None]*len(c)
|
||||||
|
bounds= tuple(zip(LB,UB))
|
||||||
|
res = linprog(c,A,b,Aeq,beq,bounds)
|
||||||
|
end = time.time()
|
||||||
|
print("最优解:\n",res.x)
|
||||||
|
print("目标函数最小值:\n",-res.fun)
|
Loading…
Reference in new issue