TExcelTAD

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 P⊆RnP \subseteq \mathbb{R}^n and we know that PP lies inside a ball of radius RR. Keep an ellipsoid EkE_k that is guaranteed to contain PP. Query its center aka_k:

  • if ak∈Pa_k \in P, stop;
  • otherwise get a violated constraint cTx≤βc^T x \le \beta with cTak>βc^T a_k > \beta. Then PP lies in the half-ellipsoid Ek∩{x:cTx≤cTak}E_k \cap \{ x : c^T x \le c^T a_k \}. Replace EkE_k by the smallest ellipsoid containing this half, and repeat.

An ellipsoid is E(a,A)={x:(x−a)TA−1(x−a)≤1}E(a, A) = \{ x : (x - a)^T A^{-1} (x - a) \le 1 \} for a center aa and a positive definite matrix AA. For n≥2n \ge 2, the smallest ellipsoid containing the half E(a,A)∩{x:cTx≤cTa}E(a, A) \cap \{ x : c^T x \le c^T a \} is E(a′,A′)E(a', A') with

b=AccTAc,a′=a−1n+1 b,A′=n2n2−1(A−2n+1 b bT).b = \frac{A c}{\sqrt{c^T A c}}, \qquad a' = a - \frac{1}{n + 1}\, b, \qquad A' = \frac{n^2}{n^2 - 1} \left( A - \frac{2}{n + 1}\, b\, b^T \right).

The new ellipsoid is smaller in volume by a fixed factor that depends only on the dimension:

vol⁡(E′)vol⁡(E)=nn+1(n2n2−1)n−12<e−12(n+1).\frac{\operatorname{vol}(E')}{\operatorname{vol}(E)} = \frac{n}{n + 1} \left( \frac{n^2}{n^2 - 1} \right)^{\frac{n - 1}{2}} < e^{-\frac{1}{2(n + 1)}} .
text
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 P

An implementation in the plane

The program searches for a point of the lab's "thin triangle" {−3x+4y≤1.5, 3x+4y≤25.5, y≥0}\{ -3x + 4y \le 1.5,\ 3x + 4y \le 25.5,\ y \ge 0 \} (also x≥0x \ge 0), starting from the disc of radius 15 around (10,10)(10, 10), which contains the triangle. It prints the center, the violated constraint and the area of each ellipsoid; the area of E(a,A)E(a, A) in the plane is πdet⁡A\pi \sqrt{\det A}.

python · try it yourself
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 23⋅(43)1/2≈0.770\frac{2}{3} \cdot (\frac{4}{3})^{1/2} \approx 0.770, whatever the constraint. The triangle, with corners (0,0)(0, 0), (8.5,0)(8.5, 0), (4,3.375)(4, 3.375) and (0,0.375)(0, 0.375), 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 2×22 \times 2 ellipsoid, followed by the same search.

cpp · try it yourself
#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 nn grows: in dimension nn it takes at most 2(n+1)2(n + 1) steps, and about 2n2n for large nn, to shrink the volume by a factor ee. The program evaluates the exact factor and the bound e−1/(2(n+1))e^{-1/(2(n+1))}.

python · try it yourself
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 P⊆RnP \subseteq \mathbb{R}^n be convex, contained in a ball of radius RR, and either empty or containing a ball of radius rr. Then the ellipsoid method either finds a point of PP or correctly reports that PP is empty after at most

K=⌈2n(n+1)ln⁡Rr⌉K = \left\lceil 2n(n + 1) \ln \frac{R}{r} \right\rceil

iterations. Proof. After kk steps, vol⁡(Ek)<e−k/(2(n+1))RnVn\operatorname{vol}(E_k) < e^{-k / (2(n+1))} R^n V_n, with VnV_n the volume of the unit ball. If PP is non-empty it contains a ball of volume rnVnr^n V_n and stays inside every EkE_k, so e−k/(2(n+1))Rn>rne^{-k/(2(n+1))} R^n > r^n, that is, k<2n(n+1)ln⁡(R/r)k < 2n(n+1) \ln(R/r). □\square

For an LP with integer data of total bit length LL, standard estimates give R≤2O(L)R \le 2^{O(L)} for a ball containing a vertex, and, after perturbing the right-hand side by 2−O(L)2^{-O(L)} (which keeps feasibility exactly equivalent), a radius r≥2−O(L)r \ge 2^{-O(L)}. So O(n2L)O(n^2 L) 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 O(n2)O(n^2) arithmetic operations plus one oracle call. Khachiyan showed that the arithmetic can be carried out with O(L)O(L) 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: O(n4L)O(n^4 L)-ish operations with large constants, and the method needs about n2Ln^2 L iterations on every input, while simplex usually stops after a few times mm pivots. Whether LP has a strongly polynomial algorithm, with a number of arithmetic operations polynomial in nn and mm alone (independent of LL), 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?

  1. The full list of constraints
  2. A separation oracle: whether the center is feasible, and if not, one violated constraint
  3. The optimal basis
  4. A starting vertex

By what factor does the volume shrink in one step in dimension nn, at least?

  1. 12\frac{1}{2}
  2. e−12(n+1)e^{-\frac{1}{2(n+1)}}
  3. 1n\frac{1}{n}
  4. e−ne^{-n}

If PP lies in a ball of radius RR and contains a ball of radius rr, how many iterations suffice?

  1. O(log⁡(R/r))O(\log(R/r))
  2. O(n2log⁡(R/r))O(n^2 \log(R/r))
  3. O(2n)O(2^n)
  4. O(R/r)O(R/r)