You will wrap scipy.optimize.linprog in three small functions, so that you can check any problem of this chapter in one line.
The idea. linprog minimises subject to and . To maximise, give it the negative of the objective and negate the answer. A rule with is turned round by multiplying its row and its limit by . The status code is 0 for solved, 2 for no feasible solution and 3 for unbounded.
Your tasks.
maximise(c, A, b). Return (value, x, y), each rounded to decimals.minimise(c, A, b). Return (value, x, y), each rounded to decimals.outcome(c, A, b, maximise_it). Return the text "solved", "no feasible solution" or "unbounded".Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…