The Geometry of Linear Programs
The feasible set of an LP is a polyhedron, and a linear objective is a direction. Sliding a hyperplane perpendicular to that direction until it last touches the polyhedron shows the central fact of linear programming: if an LP has an optimum, it has one at a vertex. The simplex method is a walk along the vertices.
Vertices and basic feasible solutions
A point of a polyhedron is a vertex (extreme point) if it is not the midpoint of two other points of . Algebraically, for in , is a vertex if it is feasible and linearly independent constraints are active there. For the standard form , with of size , vertices are the basic feasible solutions: choose independent columns , solve , set the rest to zero, and keep the result if .
The fundamental theorem
If an LP in standard form has an optimal solution, then it has an optimal basic feasible solution. Proof idea: if an optimal is not a vertex, it is the midpoint of inside ; linearity forces , so you can slide along without changing the cost until another variable hits zero, ending at a point with more active constraints.
Brute force: enumerate all vertices
For small problems you can list every basis. This makes the theorem concrete (and shows why it is not an algorithm: there are bases):
import numpy as np
from itertools import combinations
# max 3a + 5b s.t. a + 2b <= 8, 2a + b <= 10, a, b >= 0, in standard form with slacks s1, s2
A = np.array([[1.0, 2.0, 1.0, 0.0], [2.0, 1.0, 0.0, 1.0]]); b = np.array([8.0, 10.0])
c = np.array([-3.0, -5.0, 0.0, 0.0])
best = None
for basis in combinations(range(4), 2):
AB = A[:, basis]
if abs(np.linalg.det(AB)) < 1e-12:
continue
x = np.zeros(4); x[list(basis)] = np.linalg.solve(AB, b)
feasible = np.all(x >= -1e-12)
print(f"basis {basis}: (a, b) = {np.round(x[:2], 4) + 0}, feasible: {feasible}, profit: {-c @ x:.1f}")
if feasible and (best is None or c @ x < c @ best):
best = x
print("best vertex (a, b):", best[:2])basis (0, 1): (a, b) = [4. 2.], feasible: True, profit: 22.0
basis (0, 2): (a, b) = [5. 0.], feasible: True, profit: 15.0
basis (0, 3): (a, b) = [8. 0.], feasible: False, profit: 24.0
basis (1, 2): (a, b) = [ 0. 10.], feasible: False, profit: 50.0
basis (1, 3): (a, b) = [0. 4.], feasible: True, profit: 20.0
basis (2, 3): (a, b) = [0. 0.], feasible: True, profit: 0.0
best vertex (a, b): [4. 2.]
Six bases, four feasible vertices , , , , and the best is , matching the course intro.
Unbounded and degenerate cases
- Unbounded: if the polyhedron is unbounded in a direction with , the cost goes to .
- Multiple optima: if is perpendicular to an edge or face, every point on it is optimal (but a vertex is still among them).
- Degeneracy: more than constraints active at a vertex (in 2D, three lines through one point). Different bases describe the same vertex, and the simplex method can make "steps" of length zero; in rare cases it cycles without care.
import numpy as np
from scipy.optimize import linprog
# multiple optima: objective parallel to the edge a + 2b = 8
r = linprog([-1, -2], A_ub=[[1, 2], [2, 1]], b_ub=[8, 10], bounds=[(0, None)] * 2, method="highs")
print("optimum value:", -r.fun, " one optimal vertex:", np.round(r.x, 4))
for t in (0.0, 0.5, 1.0): # every point between (0, 4) and (4, 2) is optimal
p = (1 - t) * np.array([0, 4]) + t * np.array([4, 2])
print(" point", p, "value", p @ [1, 2])optimum value: 8.0 one optimal vertex: [0. 4.]
point [0. 4.] value 8.0
point [2. 3.] value 8.0
point [4. 2.] value 8.0
How many vertices?
A polyhedron defined by inequalities in dimensions can have up to roughly vertices. The Klee-Minty cube is a squashed -cube on which a classic simplex pivot rule visits all vertices. In practice the simplex method visits a small multiple of vertices, and interior-point methods have polynomial worst-case bounds.
In software
- Simplex-based solvers return a basic solution (a vertex); interior-point solvers return a point near the centre of the optimal face, followed by a crossover step to a vertex if requested.
- The basis is what makes warm starts possible: after a small change, re-solving from the old basis takes a few pivots.
Exercises
Exercise 1: Count bases
How many candidate bases does a standard-form LP with and have?
Answer
.
Solution
Each basis is a choice of 3 of the 7 columns. Some may be singular or infeasible, so the number of vertices is at most 35.
Exercise 2: Vertex or not?
For the constraints , , , is a vertex? Is ?
Answer
is on one edge but is not a vertex; is.
Solution
At only is active (since ), one constraint in 2D. At , and are active: two independent constraints.
Exercise 3: An unbounded LP (code)
Minimize subject to , . What does the solver report, and along which direction does the cost decrease forever?
Answer
Unbounded, for instance along .
Solution
from scipy.optimize import linprog
r = linprog([-1, -1], A_ub=[[1, -1]], b_ub=[1], bounds=[(0, None)] * 2, method="highs")
print(r.status, r.message.split(".")[0])3 The problem is unbounded
Moving along keeps unchanged and lowers the cost by 2 per unit.
Test yourself
If an LP has an optimal solution, then…
- it is unique
- an optimal solution exists at a vertex
- it is in the interior of the feasible set
- all vertices are optimal
A basic feasible solution of , ( is ) has at most… non-zero variables.
- 1
Degeneracy means…
- the LP is infeasible
- more constraints are active at a vertex than needed to define it
- the objective is zero
- there are no vertices