The Ellipsoid Method
In 1979 Khachiyan settled a famous open question: linear programming can be solved in polynomial time. His algorithm, the ellipsoid method (developed earlier for convex optimization by Shor and by Yudin and Nemirovski in the 1970s), is too slow to compete with simplex in practice, but its theoretical reach is enormous. It never looks at the constraint list as a whole; it only needs, for a query point, either "feasible" or one violated constraint. That makes it possible to optimize over polytopes with exponentially many constraints, the subject of the next lesson. This lesson implements the method in the plane, measures its volume shrinkage and states the iteration bound with its conditions.
The idea: halve, then wrap
Suppose we want a point of a convex set and we know that lies inside a ball of radius . Keep an ellipsoid that is guaranteed to contain . Query its center :
- if , stop;
- otherwise get a violated constraint with . Then lies in the half-ellipsoid . Replace by the smallest ellipsoid containing this half, and repeat.
An ellipsoid is for a center and a positive definite matrix . For , the smallest ellipsoid containing the half is with
The new ellipsoid is smaller in volume by a fixed factor that depends only on the dimension:
ELLIPSOID(separation oracle for P, radius R, steps K)
1 a = 0, A = R^2 I -- the ball of radius R contains P
2 for k = 1 .. K
3 if ORACLE(a) says "a is in P": return a
4 c = the violated constraint's normal -- P is in { x : c^T x <= c^T a }
5 b = A c / sqrt(c^T A c)
6 a = a - b / (n + 1)
7 A = n^2 / (n^2 - 1) * (A - 2 / (n + 1) * b b^T)
8 return "P has volume below vol(E_K)" -- empty, for a full-dimensional PAn implementation in the plane
The program searches for a point of the lab's "thin triangle" (also ), starting from the disc of radius 15 around , which contains the triangle. It prints the center, the violated constraint and the area of each ellipsoid; the area of in the plane is .
import math
cons = [((-3, 4), 1.5, "-3x+4y<=1.5"), ((3, 4), 25.5, "3x+4y<=25.5"), ((0, -1), 0, "y>=0"), ((-1, 0), 0, "x>=0")]
def oracle(p):
for c, beta, name in cons:
if c[0] * p[0] + c[1] * p[1] > beta:
return c, name
return None
n = 2
a = [10.0, 10.0]
A = [[225.0, 0.0], [0.0, 225.0]]
for k in range(1, 40):
area = math.pi * math.sqrt(A[0][0] * A[1][1] - A[0][1] * A[1][0])
hit = oracle(a)
if hit is None:
print(f"step {k:2}: center ({a[0]:.3f}, {a[1]:.3f}) is feasible, area {area:.3f}")
break
c, name = hit
print(f"step {k:2}: center ({a[0]:7.3f}, {a[1]:7.3f}) violates {name:12} area {area:9.3f}")
Ac = [A[0][0] * c[0] + A[0][1] * c[1], A[1][0] * c[0] + A[1][1] * c[1]]
s = math.sqrt(c[0] * Ac[0] + c[1] * Ac[1])
b = [Ac[0] / s, Ac[1] / s]
a = [a[i] - b[i] / (n + 1) for i in range(2)]
A = [[n * n / (n * n - 1) * (A[i][j] - 2 / (n + 1) * b[i] * b[j]) for j in range(2)] for i in range(2)]step 1: center ( 10.000, 10.000) violates -3x+4y<=1.5 area 706.858
step 2: center ( 13.000, 6.000) violates 3x+4y<=25.5 area 544.140
step 3: center ( 8.777, 2.141) violates 3x+4y<=25.5 area 418.879
step 4: center ( 5.962, -0.431) violates y>=0 area 322.453
step 5: center (3.863, 2.800) is feasible, area 248.225
Each step shrinks the area by the factor , whatever the constraint. The triangle, with corners , , and , has area about 15.1, so the method must succeed before the ellipsoid's area drops below that.
In C++
The same iteration, as a step function on a ellipsoid, followed by the same search.
#include <cmath>
#include <cstdio>
struct Ell { double a[2]; double A[2][2]; };
// One central-cut step: keep the half { x : c^T x <= c^T a } and wrap it in the smallest ellipsoid.
Ell step(const Ell& E, const double c[2]) {
const double n = 2;
double Ac[2] = {E.A[0][0] * c[0] + E.A[0][1] * c[1], E.A[1][0] * c[0] + E.A[1][1] * c[1]};
double s = std::sqrt(c[0] * Ac[0] + c[1] * Ac[1]);
double b[2] = {Ac[0] / s, Ac[1] / s};
Ell F;
for (int i = 0; i < 2; i++) {
F.a[i] = E.a[i] - b[i] / (n + 1);
for (int j = 0; j < 2; j++) F.A[i][j] = n * n / (n * n - 1) * (E.A[i][j] - 2 / (n + 1) * b[i] * b[j]);
}
return F;
}
int main() {
const double C[4][2] = {{-3, 4}, {3, 4}, {0, -1}, {-1, 0}};
const double beta[4] = {1.5, 25.5, 0, 0};
Ell E = {{10, 10}, {{225, 0}, {0, 225}}};
for (int k = 1; k < 40; k++) {
int bad = -1;
for (int i = 0; i < 4 && bad < 0; i++)
if (C[i][0] * E.a[0] + C[i][1] * E.a[1] > beta[i]) bad = i;
double area = M_PI * std::sqrt(E.A[0][0] * E.A[1][1] - E.A[0][1] * E.A[1][0]);
if (bad < 0) { std::printf("feasible center (%.3f, %.3f) after %d steps, area %.3f\n", E.a[0], E.a[1], k - 1, area); return 0; }
E = step(E, C[bad]);
}
std::printf("no feasible center found\n");
}feasible center (3.863, 2.800) after 4 steps, area 248.225
Volume shrinkage in higher dimensions
The guaranteed shrink factor gets closer to 1 as grows: in dimension it takes at most steps, and about for large , to shrink the volume by a factor . The program evaluates the exact factor and the bound .
import math
print(" n exact ratio e^(-1/(2(n+1))) steps to shrink volume by e")
for n in [2, 3, 5, 10, 50, 100]:
exact = n / (n + 1) * (n * n / (n * n - 1)) ** ((n - 1) / 2)
bound = math.exp(-1 / (2 * (n + 1)))
print(f"{n:3} {exact:.6f} {bound:.6f} {math.ceil(-1 / math.log(exact))}") n exact ratio e^(-1/(2(n+1))) steps to shrink volume by e
2 0.769800 0.846482 4
3 0.843750 0.882497 6
5 0.904225 0.920044 10
10 0.951150 0.955563 20
50 0.990049 0.990244 100
100 0.995012 0.995062 200
The iteration bound
Theorem. Let be convex, contained in a ball of radius , and either empty or containing a ball of radius . Then the ellipsoid method either finds a point of or correctly reports that is empty after at most
iterations. Proof. After steps, , with the volume of the unit ball. If is non-empty it contains a ball of volume and stays inside every , so , that is, .
For an LP with integer data of total bit length , standard estimates give for a ball containing a vertex, and, after perturbing the right-hand side by (which keeps feasibility exactly equivalent), a radius . So iterations decide feasibility. Optimization reduces to feasibility by binary search on the objective value, or by adding the objective as a cut whenever the center is feasible ("sliding objective"). Each iteration costs arithmetic operations plus one oracle call. Khachiyan showed that the arithmetic can be carried out with bits of precision per number (rounding the ellipsoid up slightly at every step), which makes the whole algorithm polynomial in the bit model.
Note: "Polynomial" here is strongly in favour of theory: -ish operations with large constants, and the method needs about iterations on every input, while simplex usually stops after a few times pivots. Whether LP has a strongly polynomial algorithm, with a number of arithmetic operations polynomial in and alone (independent of ), is still open; Tardos (1986) gave one for LPs whose constraint matrix has small entries, which covers network flows.
The next lesson exploits the one feature that makes the method special: it never needs the list of constraints, only an oracle that returns a violated one.
Test yourself
What does the ellipsoid method need at each iteration?
- The full list of constraints
- A separation oracle: whether the center is feasible, and if not, one violated constraint
- The optimal basis
- A starting vertex
By what factor does the volume shrink in one step in dimension , at least?
If lies in a ball of radius and contains a ball of radius , how many iterations suffice?