Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from scipy.optimize import linprog
- def linear(M, b, x,bounds, maxi):
- if maxi:
- res = linprog([i * -1 for i in x], A_ub=M, b_ub=b, bounds = bounds ,options={"disp": False}).x
- else:
- res = linprog(x, A_ub=M, b_ub=b, bounds = bounds ,options={"disp": False}).x
- return res
- M = [[2, 1, -9000], [1, 1, -5500],
- [1, 2.5, -10000], [-1, 0, 100], [0,-1,100],
- [36.8, 65.7, 0], [-36.8, -65.7, 0]]
- b = [0, 0, 0, 0, 0, 1, -1]
- z1 = [150,130,0]
- bounds= [(0,None),(0,None),(0,None)]
- res = linear(M, b, z1, bounds,True)
- print(res)
- x1 = res[0]/res[2]
- print("A:")
- print(round(x1))
- x2 = res[1]/res[2]
- print("B:")
- print(round(x2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement