TheAceHome

Untitled

Mar 12th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import pulp as p
  2.  
  3. Lp_prob = p.LpProblem('Problem', p.LpMaximize)
  4.  
  5. x = p.LpVariable("x", cat='Integer', lowBound = 0) # Create a variable x >= 0
  6. y = p.LpVariable("y", cat='Integer', lowBound = 0) # Create a variable y >= 0
  7.  
  8. Lp_prob += 1 * x + 5 * y
  9.  
  10. Lp_prob += -x + y <= 2
  11. Lp_prob += x + y <= 7
  12.  
  13. print(Lp_prob)
  14.  
  15. status = Lp_prob.solve()
  16. print(p.LpStatus[status])
  17.  
  18.  
  19. print(p.value(x), p.value(y), p.value(Lp_prob.objective))
Advertisement
Add Comment
Please, Sign In to add comment