Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pulp as p
- Lp_prob = p.LpProblem('Problem', p.LpMaximize)
- x = p.LpVariable("x", cat='Integer', lowBound = 0) # Create a variable x >= 0
- y = p.LpVariable("y", cat='Integer', lowBound = 0) # Create a variable y >= 0
- Lp_prob += 1 * x + 5 * y
- Lp_prob += -x + y <= 2
- Lp_prob += x + y <= 7
- print(Lp_prob)
- status = Lp_prob.solve()
- print(p.LpStatus[status])
- print(p.value(x), p.value(y), p.value(Lp_prob.objective))
Advertisement
Add Comment
Please, Sign In to add comment