Linear Programming
Linear Programming
107x1 + 53.2x2 ≥ 90
47x1 + 276x2 + 40x3 ≥ 1000
91x1 + 87x2 + 87x3 ≥ 3700
Goal:
Design a diet of minimum cost satisfying health requirements
LP problem
Minimize cT x (cost of the diet)
Subject to Ax ≥ b (health requirements)
x ≥0 (non-negative amount of amount of food)
This alternative to least squares is more resistant to outliers, but the function to
be minimized is not differentiable.
−ei ≤ asi + b − ti ≤ ei
Send flow through a network from a source to a target with constraints on the
edges.
Maximize cT x
Subject to Ax = b
x ≥0
A is m × n of rank m ≤ n,
x is an n-column vector, and
b is an m-column vector.
From a standard LP to an LP in equational form
ai1 x1 + · · · + ain xn ≤ bi
ai1 x1 + · · · + ain xn + yi = bi .
Maximize cT x
Subject to Ax = b
x ≥0
A basic feasible solution of the linear program is x such that, for some m–element
subset B ⊂ [n],
x is a feasible solution,
xi = 0 for i ∈
/ B, and
AB is nonsingular
Theorem
Let P be the set of feasible solutions of a linear program in equational form. Then
v is a vertex of the polyhedron P if and only if v is a basic feasible solution of the
linear program.
Theorem
Let P be the set of feasible solutions of a linear program in equational form. Then
v is a vertex of the polyhedron P if and only if v is a basic feasible solution of the
linear program.
Theorem
An optimal solution of a linear program in equational form is achieved by a basic
feasible solution, that is, in a vertex of the polyhedron P of feasible solutions.
Maximize x1 + x2
Subject to −x1 + x2 ≤ 1
x1 ≤ 3
x2 ≤ 2
x1 , x2 ≥ 0
Maximize x1 +x2
Subject to −x1 +x2 +x3 =1
x1 +x4 =3
x2 +x5 =2
x1 , x2 , x3 , x4 , x5 ≥0
Maximize x1 +x2
Subject to −x1 +x2 +x3 =1
x1 +x4 =3
x2 +x5 =2
x1 , x2 , x3 , x4 , x5 ≥0
x3 ≥ 0 →x2 ≤ 1
x4 ≥ 0 →x2 < ∞
x5 ≥ 0 →x2 ≤ 2
x3 leaving
Step 3: Increase the entering variable as much as possible (x2 = 1), update
the tableau
Return x1 = 3, x2 = 2 and z = 5.
Maximize x1 +x2
Subject to −x1 +x2 +x3 =1
x1 +x4 =3
x2 +x5 =2
x1 , x2 , x3 , x4 , x5 ≥0
x1 ≥ 0
x1 ≤ 3
x2 ≤ 2
x2 ≥ 0
3 Increase entering variable. Update Tableau and current basic feasible solution.
5 Output solution.
Handling troubles
0 Put the problem in equational form.
1 Find a basic feasible solution. Initialize the Tableau.
Infeasibility: no solutions?
2 Pivot step: Select leaving and entering variables.
Rules of choice
3 Increase entering variable. Update Tableau and current basic feasible solution.
Degeneracy: what if no choice increases objective function?
4 Repeat steps 2 and 3 while possible.
Unboundeedness: what if no maximum exists?
5 Output solution.
Unboundedness
x1 = 1 +x2 −x3
x4 =3 −x3
z = 1 +x2 −x3
Unfeasibility
Maximize c T x
Subject to Ax ≤ b, x ≥ 0
But:
Maximize c T x
Subject to Ax = b, x ≥ 0
Maximize c T x
Subject to Ax = b, x ≥ 0
Assume all bi ≥ 0
Introduce an auxiliary variable yi for each equation.
(if we set all variables to 0, by how much they fail to satisfy the equation.)
Write a Linear Programming problem for maximization of
−y1 − y2 · · · − ym
Maximize x1 + 2x2
Subject to x1 + 3x2 + x3 = 4
2x2 + x3 = 2
x1 , x2 ≥ 0
Introduce auxiliary variables x4 and x5 and write new Linear Program problem:
Maximize − x4 − x5
Subject to x1 + 3x2 + x3 + x4 =4
2x2 + x3 + x5 = 2
x1 , x2 x3 , x4 , x5 ≥ 0
Maximize x1 + 2x2
Subject to x1 + 3x2 + x3 = 4
2x2 + x3 = 2
x1 , x2 ≥ 0
x4 = 4 − x1 − 3x2 − x3
x5 = 2 − 2x2 − x3
z = −6 + x1 + 5x2 + 2x3
Maximize x1 + 2x2
Subject to x1 + 3x2 + x3 = 4
2x2 + x3 = 2
x1 , x2 ≥ 0
x1 = 4 − 3x2 − x3 − x4
x5 = 2 − 2x2 − x3
z = −2 + 2x2 + x3 − x4
▶ x3 in x5 out
x1 = 2 − x2 − x4 + x5
x3 = 2 − 2x2 − x5
z = 0 − x4 − x5
Maximize x1 + 2x2
Subject to x1 + 3x2 + x3 = 4
2x2 + x3 = 2
x1 , x2 ≥ 0
x1 = 2 − x2 − x4 + x5
x3 = 2 − 2x2 − x5
z = 0 − x4 − x5
Maximize x2
Subject to −x1 + x2 ≤ 0
x1 ≤ 2
x1 , x2 ≥ 0
Tableau:
x3 = +x1 −x2
x4 = 2 −x1
z = +x2
x2 enters and x3 leaves, but the value of x2 can not be increased
Maximize x2
Subject to −x1 + x2 ≤ 0
x1 ≤ 2
x1 , x2 ≥ 0
x2 = +x1 −x3
x4 = 2 −x1
z = x1 −x3
Maximize x2
Subject to −x1 + x2 ≤ 0
x1 ≤ 2
x1 , x2 ≥ 0
x1 =2 −x4
x2 = 2 −x3 −x4
z = 2 −x3 −x4
Maximize x2
Subject to −x1 + x2 ≤ 0
x1 ≤ 2
x1 , x2 ≥ 0
It may happen that there are more than one degenerate pivot steps.
It may happen that the degenerate pivot steps cycle to some previous point.
Theorem The simplex method with Bland’s rule is always finite (cycling is
impossible).
The simplex algorithm ranges among the most frequently used in real life.
The simplex algorithm ranges among the most frequently used in real life.
In some examples it may need exponential running time (Klee-Minty
examples, 1972)
In practice it performs very satisfactorily: typically between 2m and 3m steps
to reach the optimum.
The simplex algorithm ranges among the most frequently used in real life.
In some examples it may need exponential running time (Klee-Minty
examples, 1972)
In practice it performs very satisfactorily: typically between 2m and 3m steps
to reach the optimum.
It has been proved that small alterations always brings polynomial time
problems (Spielman-Teng, 2001).
The simplex algorithm ranges among the most frequently used in real life.
In some examples it may need exponential running time (Klee-Minty
examples, 1972)
In practice it performs very satisfactorily: typically between 2m and 3m steps
to reach the optimum.
It has been proved that small alterations always brings polynomial time
problems (Spielman-Teng, 2001).
Most mathematical software systems (Maple, Matlab, Mathematica,...) have
packages implementing the simplex algorithm.
In Python the library scipy.optimize.linprog has several implemented
algorithms for LP problems
https://docs.scipy.org/doc/scipy/reference/generated/scipy.
optimize.linprog.html
XB =p + QXN
z = z0 + r T XN