Polytopes, Vertices and Basic Feasible Solutions
The optimum of an LP sits at a corner of the feasible region. For combinatorial problems this is the central fact: if every corner of the region is an integer point, the LP solves the integer problem for free. This lesson makes "corner" precise in three equivalent ways (geometric, algebraic and in terms of tight constraints), proves the equivalence, and uses it to enumerate the corners of two small matching polytopes, one with only integral corners and one without. The continuous treatment, with the same fundamental theorem, is in The Geometry of Linear Programs.
Polyhedra and polytopes
A polyhedron is a set , an intersection of finitely many half-spaces. A bounded polyhedron is a polytope; by the Minkowski-Weyl theorem a polytope is also the convex hull of finitely many points, so the two descriptions (by inequalities, by corner points) describe the same objects. For a point , call constraint tight if .
Three ways to say that is a corner:
- Vertex: there is a vector such that is the unique maximizer of over .
- Extreme point: is not the midpoint of two other points of ; that is, with forces .
- Basic feasible solution: among the constraints tight at , there are whose normal vectors are linearly independent.
Theorem. For a point of a polyhedron, the three notions coincide.
The lab shows the first definition at work on the "fractional corners" polygon. Turn the objective direction : for almost every direction one vertex is the unique maximizer, and the optimum jumps from vertex to vertex as passes the normal of an edge. At exactly those directions the whole edge is optimal (the lab reports a tie), but even then the optimal set contains vertices.
In equational form with of full row rank , the third notion has a concrete algebraic version. A basis is a set of column indices whose columns are linearly independent. Setting the other variables to zero and solving gives the basic solution of ; it is a basic feasible solution (BFS) if also .
Proof that extreme points and basic feasible solutions coincide (equational form)
Let be feasible and let be its support. Claim: is an extreme point if and only if the columns are linearly independent (and then can be extended to a basis, so is a BFS).
If the columns are dependent, pick with and for . For small both and satisfy and stay non-negative (the entries of on are strictly positive). So is the midpoint of two distinct feasible points: not extreme.
If the columns are independent, suppose with feasible. For , with forces . So , and independence gives ; likewise . So is extreme.
For vertices: if is the unique maximizer of , it cannot be a midpoint of two other points of (one of them would score at least as much). Conversely, for a BFS with basis , the objective (minus one on the non-basic variables, zero elsewhere) is maximized exactly at points with , and has only one solution.
Fundamental theorem of linear programming. If an LP in equational form is feasible and bounded, it has an optimal solution that is a BFS. (Sketch: start from any optimal point; while its support columns are dependent, move along the direction of the proof, which does not change the objective, as the LP is bounded and are both feasible, until some variable hits zero; the support shrinks each time.) Since there are at most bases, an LP can be solved by enumerating them, which is finite but exponential.
Enumerating bases
The workshop LP in equational form has five variables (, and three slacks) and three rows, so there are candidate bases. The program solves each system in exact arithmetic and sorts the outcomes into singular, infeasible and feasible.
from fractions import Fraction as F
from itertools import combinations
def solve(M, rhs):
"""Gauss-Jordan elimination over the rationals; None if M is singular."""
n = len(M)
T = [[F(v) for v in row] + [F(r)] for row, r in zip(M, rhs)]
for col in range(n):
piv = next((r for r in range(col, n) if T[r][col] != 0), None)
if piv is None:
return None
T[col], T[piv] = T[piv], T[col]
for r in range(n):
if r != col and T[r][col] != 0:
f = T[r][col] / T[col][col]
T[r] = [a - f * b for a, b in zip(T[r], T[col])]
return [T[i][n] / T[i][i] for i in range(n)]
names = ["x", "y", "s1", "s2", "s3"]
A = [[2, 1, 1, 0, 0], [1, 3, 0, 1, 0], [1, 0, 0, 0, 1]]
b = [10, 15, 4]
for B in combinations(range(5), 3):
xB = solve([[A[i][j] for j in B] for i in range(3)], b)
label = "{" + ",".join(names[j] for j in B) + "}"
if xB is None:
print(f"{label:12} singular")
continue
full = [F(0)] * 5
for j, v in zip(B, xB):
full[j] = v
status = "BFS" if min(xB) >= 0 else "infeasible"
print(f"{label:12} {status:10} (x, y) = ({full[0]}, {full[1]})"){x,y,s1} infeasible (x, y) = (4, 11/3)
{x,y,s2} BFS (x, y) = (4, 2)
{x,y,s3} BFS (x, y) = (3, 4)
{x,s1,s2} BFS (x, y) = (4, 0)
{x,s1,s3} infeasible (x, y) = (15, 0)
{x,s2,s3} infeasible (x, y) = (5, 0)
{y,s1,s2} singular
{y,s1,s3} BFS (x, y) = (0, 5)
{y,s2,s3} infeasible (x, y) = (0, 10)
{s1,s2,s3} BFS (x, y) = (0, 0)
Five bases are feasible and they give the five corners of the workshop polygon. Four bases give points that violate a sign constraint (intersections of constraint lines outside the polygon), and one basis is singular. Each corner here comes from exactly one basis; at a degenerate vertex, where more than constraints are tight, several bases describe the same point, which is what makes the simplex method stall (Degeneracy, Cycling and Bland's Rule).
Corners of matching polytopes
The fractional matching polytope of a graph is . Its integer points are exactly the matchings. Are its vertices integer points? The program finds all vertices directly from the third definition: choose constraints, solve them as equations, and keep the solutions that satisfy all constraints.
from fractions import Fraction as F
from itertools import combinations
def solve(M, rhs):
n = len(M)
T = [[F(v) for v in row] + [F(r)] for row, r in zip(M, rhs)]
for col in range(n):
piv = next((r for r in range(col, n) if T[r][col] != 0), None)
if piv is None:
return None
T[col], T[piv] = T[piv], T[col]
for r in range(n):
if r != col and T[r][col] != 0:
f = T[r][col] / T[col][col]
T[r] = [a - f * b for a, b in zip(T[r], T[col])]
return [T[i][n] / T[i][i] for i in range(n)]
def matching_vertices(nv, edges):
m = len(edges)
rows = [([1 if v in e else 0 for e in edges], 1) for v in range(nv)] # degree <= 1
rows += [([-1 if k == j else 0 for k in range(m)], 0) for j in range(m)] # -x_e <= 0
found = set()
for S in combinations(rows, m):
x = solve([r for r, _ in S], [r for _, r in S])
if x is not None and all(sum(a * xi for a, xi in zip(r, x)) <= rhs for r, rhs in rows):
found.add(tuple(x))
return sorted(found)
for name, nv, edges in [("4-cycle (bipartite)", 4, [(0, 1), (1, 2), (2, 3), (3, 0)]),
("triangle (odd cycle)", 3, [(0, 1), (1, 2), (0, 2)])]:
verts = matching_vertices(nv, edges)
frac = [v for v in verts if any(c.denominator != 1 for c in v)]
print(f"{name}: {len(verts)} vertices, fractional ones: {[tuple(str(c) for c in v) for v in frac]}")4-cycle (bipartite): 7 vertices, fractional ones: []
triangle (odd cycle): 5 vertices, fractional ones: [('1/2', '1/2', '1/2')]
The 4-cycle's polytope has 7 vertices: the empty matching, four single edges and two perfect matchings, all integral. The triangle's has 5: the empty matching, three single edges and the extra vertex , with value , larger than any matching (one edge). This is the whole story of bipartite matching in miniature: for bipartite graphs the incidence matrix is totally unimodular and every vertex is integral (Totally Unimodular Matrices); odd cycles create half-integral vertices, which Edmonds (1965) removed by adding the odd-set constraints for odd .
How many vertices can there be?
A polytope in with facets has at most vertices, and McMullen's upper bound theorem (1970) gives the exact maximum, which for fixed is of order . The cube already shows the exponential behaviour: constraints, vertices. Any algorithm that looks at all vertices is exponential, which is why the simplex method only walks along a path of improving vertices, the subject of the next lesson.
from math import comb
print(" n constraints cube vertices bound C(2n, n)")
for n in [2, 4, 8, 16, 32]:
print(f"{n:2} {2 * n:11} {2 ** n:13} {comb(2 * n, n):14}") n constraints cube vertices bound C(2n, n)
2 4 4 6
4 8 16 70
8 16 256 12870
16 32 65536 601080390
32 64 4294967296 1832624140942590534
Test yourself
In equational form with rows and variables, how many variables can be non-zero at a basic feasible solution?
- Exactly
- At most
- At least
- Exactly
Why is a feasible point whose support columns are linearly dependent not a vertex?
- It violates a constraint
- Moving by for a dependence on the support keeps feasibility, so the point is a midpoint of two feasible points
- Its objective value is zero
- It has too many tight constraints
Which vertex appears in the fractional matching polytope of a triangle but not of a 4-cycle?
- The all-zero vector
- A half-integral point with on every edge of the odd cycle
- A point with one coordinate equal to 2
- None, both are integral