TExcelTAD
Home › Linear Programming & Duality for Algorithms › Separation Oracles and Exponentially Many Constraints

Separation Oracles and Exponentially Many Constraints

Many of the strongest LP relaxations in combinatorial optimization have exponentially many constraints: one for every subset of vertices, every cut, every odd set. Writing them down is out of the question, yet they can be solved in polynomial time. The reason is the property of the ellipsoid method noted in the previous lesson: it only ever asks for one violated constraint at a time. If that question can be answered quickly, the LP can be solved quickly, no matter how long its constraint list is. This lesson defines separation oracles, states the equivalence of separation and optimization, and builds a working oracle for the subtour-elimination LP of the travelling salesman problem.

The separation problem

A separation oracle for a polyhedron P⊆RnP \subseteq \mathbb{R}^n takes a point xˉ\bar x and either

  • confirms xˉ∈P\bar x \in P, or
  • returns a separating hyperplane: a vector aa and a number β\beta with aTx≤βa^T x \le \beta for all x∈Px \in P but aTxˉ>βa^T \bar x > \beta.

For a polyhedron given by an explicit list of mm inequalities, checking them one by one is an oracle running in time O(mn)O(mn). The interesting case is a polyhedron given implicitly, by a rule that generates constraints, where a clever algorithm finds a violated one without looking at all of them.

Theorem (Grötschel, Lovász and Schrijver, 1981; book 1988). For a family of rational polyhedra whose facets have bounded encoding length, the optimization problem ("maximize cTxc^T x over PP") can be solved in polynomial time if and only if the separation problem can. The direction "separation ⇒\Rightarrow optimization" is the ellipsoid method with a sliding objective, plus care with precision and with polyhedra that are not full-dimensional. The converse uses the ellipsoid method on the polar polyhedron.

The theorem is a statement about polynomial time, not about practical speed. In practice the same oracles drive cutting-plane methods: solve the LP with the constraints found so far (by simplex), ask the oracle about the optimum, add the violated constraint, repeat. That is what this lesson runs.

The subtour-elimination LP

For a complete graph with edge lengths cec_e, a tour uses exactly two edges at each vertex and crosses every cut at least twice. The subtour-elimination LP (Dantzig, Fulkerson and Johnson, 1954) is

min⁡∑ecexes.t.x(δ(v))=2for every vertex vx(δ(S))≥2for every ∅≠S⊊V0≤xe≤1,\begin{aligned} \min \quad & \sum_{e} c_e x_e \\ \text{s.t.} \quad & x(\delta(v)) = 2 && \text{for every vertex } v \\ & x(\delta(S)) \ge 2 && \text{for every } \emptyset \ne S \subsetneq V \\ & 0 \le x_e \le 1, \end{aligned}

where x(δ(S))x(\delta(S)) is the total value on edges with exactly one end in SS. There are 2n−22^n - 2 cut constraints. Without them, the optimum of the degree constraints alone is often a union of disjoint short cycles, the subtours.

Separation. Given xˉ\bar x satisfying the degree equations and bounds, a violated cut constraint exists exactly when the graph with edge capacities xˉe\bar x_e has a cut of capacity below 2. A global minimum cut finds the smallest one: n−1n - 1 maximum-flow computations from a fixed vertex, or one run of the Stoer-Wagner algorithm (1997) in O(nm+n2log⁡n)O(nm + n^2 \log n) time. So the oracle is polynomial, and by the theorem the subtour LP is solvable in polynomial time.

A cutting-plane loop

The program solves the LP for seven cities, starting with the degree constraints only. After each solve it calls the oracle (here a brute-force minimum cut over all 2n−1−12^{n-1} - 1 vertex sets, fine for n=7n = 7; the C++ version below is the real algorithm), adds the violated constraint, and re-solves.

python · try it yourself
import math
from itertools import combinations
from scipy.optimize import linprog

pts = [(0, 0), (2, 0.3), (0.4, 1.7), (9, 0.2), (11, 1.1), (9.6, 2.4), (5, 6)]
n = len(pts)
E = list(combinations(range(n), 2))
w = [math.dist(pts[u], pts[v]) for u, v in E]

def oracle(x):
    """Minimum cut x(delta(S)) over sets S not containing vertex 0 (brute force)."""
    best = None
    for r in range(1, n):
        for S in combinations(range(1, n), r):
            val = sum(x[k] for k, (u, v) in enumerate(E) if (u in S) != (v in S))
            if best is None or val < best[0] - 1e-9:
                best = (val, set(S))
    return best

cuts = []
for rnd in range(1, 10):
    A_eq = [[1 if v in e else 0 for e in E] for v in range(n)]
    A_ub = [[-1 if (u in S) != (v in S) else 0 for u, v in E] for S in cuts]
    res = linprog(w, A_eq=A_eq, b_eq=[2] * n, A_ub=A_ub or None, b_ub=[-2] * len(cuts) or None,
                  bounds=[(0, 1)] * len(E), method="highs")
    support = [E[k] for k, v in enumerate(res.x) if v > 1e-6]
    cut_value, S = oracle(res.x)
    print(f"round {rnd}: LP value {float(res.fun):.4f}, edges used {support}")
    if cut_value >= 2 - 1e-9:
        print(f"  oracle: every cut has value >= 2 (minimum {cut_value:.4f}); the LP optimum is feasible")
        break
    print(f"  oracle: x(delta(S)) = {cut_value:.4f} < 2 for S = {sorted(S)}; add this constraint")
    cuts.append(S)
round 1: LP value 22.8853, edges used [(0, 1), (0, 2), (1, 2), (3, 4), (3, 6), (4, 5), (5, 6)]
  oracle: x(delta(S)) = 0.0000 < 2 for S = [3, 4, 5, 6]; add this constraint
round 2: LP value 22.8909, edges used [(0, 1), (0, 2), (1, 6), (2, 6), (3, 4), (3, 5), (4, 5)]
  oracle: x(delta(S)) = 0.0000 < 2 for S = [3, 4, 5]; add this constraint
round 3: LP value 27.0112, edges used [(0, 1), (0, 2), (1, 3), (2, 6), (3, 4), (4, 5), (5, 6)]
  oracle: every cut has value >= 2 (minimum 2.0000); the LP optimum is feasible

Two cuts were enough. The first LP optimum is a triangle and a 4-cycle, the second a different pair of subtours (the far city 6 joins the left cluster), and the third is a single tour: an integral point of the subtour LP is a tour, so this tour is optimal for the TSP instance, certified by the LP bound. On larger instances the LP optimum is usually fractional, and the gap must be closed with branching or further families of cuts (combs, for example), which is how modern exact TSP solvers work.

In C++

The oracle itself: the Stoer-Wagner global minimum cut on a capacity matrix, applied to two points. The first is the LP optimum of round 1 (two subtours), the second a fractional point that satisfies every degree equation: two triangles with 34\frac{3}{4} on their edges, joined by three edges carrying 12\frac{1}{2}.

cpp · try it yourself
#include <algorithm>
#include <cstdio>
#include <vector>

// Stoer-Wagner: returns the minimum cut value and fills `side` with one shore of a minimum cut.
double min_cut(std::vector<std::vector<double>> w, std::vector<int>& side) {
    int n = w.size();
    std::vector<std::vector<int>> members(n);
    for (int v = 0; v < n; v++) members[v] = {v};
    std::vector<bool> merged(n, false);
    double best = 1e18;
    for (int phase = 0; phase < n - 1; phase++) {
        std::vector<double> key(n, 0);
        std::vector<bool> added(n, false);
        int prev = -1, last = -1;
        for (int k = 0; k < n - phase; k++) {           // maximum-adjacency order
            int sel = -1;
            for (int v = 0; v < n; v++)
                if (!merged[v] && !added[v] && (sel < 0 || key[v] > key[sel])) sel = v;
            added[sel] = true;
            prev = last; last = sel;
            for (int v = 0; v < n; v++) if (!merged[v] && !added[v]) key[v] += w[sel][v];
        }
        if (key[last] < best) { best = key[last]; side = members[last]; }   // cut of the phase
        for (int v = 0; v < n; v++) { w[prev][v] += w[last][v]; w[v][prev] = w[prev][v]; }
        members[prev].insert(members[prev].end(), members[last].begin(), members[last].end());
        merged[last] = true;
    }
    return best;
}

void report(const char* name, int n, const std::vector<std::vector<double>>& edges) {
    std::vector<std::vector<double>> w(n, std::vector<double>(n, 0));
    for (auto& e : edges) { w[(int)e[0]][(int)e[1]] += e[2]; w[(int)e[1]][(int)e[0]] += e[2]; }
    std::vector<int> side;
    double c = min_cut(w, side);
    std::sort(side.begin(), side.end());
    std::printf("%s: minimum cut %.4f, S = {", name, c);
    for (size_t i = 0; i < side.size(); i++) std::printf("%s%d", i ? ", " : "", side[i]);
    std::printf("} -> %s\n", c < 2 - 1e-9 ? "violated subtour constraint" : "all cut constraints hold");
}

int main() {
    report("two subtours", 7, {{0, 1, 1}, {0, 2, 1}, {1, 2, 1}, {3, 4, 1}, {3, 6, 1}, {4, 5, 1}, {5, 6, 1}});
    report("fractional point", 6, {{0, 1, .75}, {1, 2, .75}, {0, 2, .75}, {3, 4, .75}, {4, 5, .75}, {3, 5, .75},
                                   {0, 3, .5}, {1, 4, .5}, {2, 5, .5}});
    report("a tour", 6, {{0, 1, 1}, {1, 2, 1}, {2, 3, 1}, {3, 4, 1}, {4, 5, 1}, {5, 0, 1}});
}
two subtours: minimum cut 0.0000, S = {3, 4, 5, 6} -> violated subtour constraint
fractional point: minimum cut 1.5000, S = {3, 4, 5} -> violated subtour constraint
a tour: minimum cut 2.0000, S = {5} -> all cut constraints hold

A second oracle: the spanning tree polytope

The spanning tree polytope of a graph is {x≥0:x(E)=n−1, x(E(S))≤∣S∣−1 for all ∅≠S⊆V}\{ x \ge 0 : x(E) = n - 1,\ x(E(S)) \le \lvert S \rvert - 1 \text{ for all } \emptyset \ne S \subseteq V \}, where E(S)E(S) are the edges with both ends in SS (Edmonds, 1971). Its vertices are exactly the spanning trees. A point that puts too much weight inside a small vertex set violates one of the exponentially many constraints. The program finds the most violated constraint by brute force for a point on 5 vertices that has the right total, n−1=4n - 1 = 4, but concentrates 2.72.7 on a triangle.

python · try it yourself
from fractions import Fraction as F
from itertools import combinations

n = 5
x = {(0, 1): F(9, 10), (1, 2): F(9, 10), (0, 2): F(9, 10), (2, 3): F(7, 10), (3, 4): F(6, 10)}
print("total weight", sum(x.values()), "= n - 1:", sum(x.values()) == n - 1)

best = None
for k in range(2, n + 1):
    for S in combinations(range(n), k):
        inside = sum(w for (u, v), w in x.items() if u in S and v in S)
        excess = inside - (len(S) - 1)
        if best is None or excess > best[0]:
            best = (excess, S, inside)
excess, S, inside = best
if excess > 0:
    print(f"violated: x(E(S)) = {inside} > |S| - 1 = {len(S) - 1} for S = {S}")
else:
    print("x is in the spanning tree polytope")
total weight 4 = n - 1: True
violated: x(E(S)) = 27/10 > |S| - 1 = 2 for S = (0, 1, 2)

The triangle {0,1,2}\{0, 1, 2\} can hold at most 22 units (a tree uses at most two of its edges), and the point puts 2710\frac{27}{10} there. The polynomial oracle replaces the 2n2^n subsets by a sequence of minimum-cut computations on an auxiliary graph (Cunningham, 1984; Padberg and Wolsey, 1983), which finds the most violated set directly.

More polytopes with polynomial-time separation

Polytope Exponential family of constraints Separation algorithm
subtour LP (TSP), kk-edge-connected subgraphs x(δ(S))≥2x(\delta(S)) \ge 2 (or kk) for all SS global minimum cut
spanning tree polytope (Edmonds, 1971) x(E(S))≤∣S∣−1x(E(S)) \le \lvert S \rvert - 1 for all SS, plus x(E)=n−1x(E) = n - 1 a sequence of min-cut computations (Cunningham, 1984; Padberg and Wolsey, 1983)
perfect matching polytope (Edmonds, 1965) x(δ(S))≥1x(\delta(S)) \ge 1 for all odd SS minimum odd cut via a Gomory-Hu tree (Padberg and Rao, 1982)
matroid polytopes x(S)≤r(S)x(S) \le r(S) for all SS submodular function minimization (Cunningham, 1984, for matroids)

The same idea works for LPs with exponentially many variables: the dual of such an LP has exponentially many constraints, and separating the dual means finding a variable with negative reduced cost (column generation). The configuration LP for bin packing (Gilmore and Gomory, 1961) is the classic example; its oracle is a knapsack problem, solved exactly or approximately.

Note: "Polynomial time via the ellipsoid method" is an existence result about algorithms, used to classify problems. For instance, it proved that the weighted matching problem, the spanning tree polytope and submodular minimization are all polynomial, sometimes years before a combinatorial algorithm was found.

Test yourself

What must a separation oracle return for a point outside the polytope?

  1. The nearest point of the polytope
  2. A constraint valid for the polytope but violated by the point
  3. The optimal vertex
  4. All violated constraints

How do you separate the subtour-elimination constraints x(δ(S))≥2x(\delta(S)) \ge 2?

  1. Check all 2n2^n subsets
  2. Compute a global minimum cut with capacities xˉe\bar x_e; a cut below 2 is a violated constraint
  3. Run Dijkstra's algorithm
  4. Solve the LP again

What does the Grötschel-Lovász-Schrijver theorem say?

  1. Every LP has polynomially many facets
  2. For well-described polyhedra, optimization is polynomial-time solvable iff separation is
  3. Separation is always NP-hard
  4. The simplex method is polynomial with an oracle