...

/

Solving Linear Problems

Solving Linear Problems

Learn to use SciPy to solve linear problems.

Solving linear problems is easier with SciPy. It includes the function linprog (from linear programming) that allows us to solve any linear optimization problem. In this lesson, we’re going to learn how to use this special feature of SciPy.

First linear optimization problem

The best way to learn is with a practical example, so let’s solve the following linear optimization problem:

minx,y4x+3y+1s.t.:x+y<10x>5\min_{x, y} 4x + 3y + 1\\ s.t.: x + y < 10\\ x > 5\\

Note: The last term of the target function is a constant. This constant doesn’t affect the optimization problem. This means that removing it doesn’t modify the optimal value. The minimum of 4x+3y4x + 3y is the same as the minimum of 4x+3y+14x + 3y + 1 ...