Interior point methods

Where Simplex crawls the boundary, an interior point method (IPM) cuts straight through the middle: it keeps every iterate strictly inside the constraints and follows a smooth arc to the optimum. lpviz implements a Mehrotra-style primal-dual predictor–corrector method — the algorithm at the core of most modern LP solvers.

A smooth interior point trajectory starting outside a polygon, entering it, and curving through the interior to the optimal vertex.
An infeasible start: the first iterates may sit outside the region, then the path bends inward and converges to the optimal vertex.

The idea

For the LP maximize cᵀx s.t. Ax ≤ b, introduce a slack s = b − Ax ≥ 0 and a dual multiplier yi ≥ 0 for each constraint. A point is optimal exactly when the KKT conditions hold:

Ax + s = b,   Aᵀy = c,   si yi = 0 for all i,   s, y ≥ 0.

The hard part is complementarity (siyi = 0): it forces every constraint to be either exactly tight or carry zero price, which is combinatorial. IPMs relax it to siyi = µ for a positive parameter µ, solve that smooth system approximately with Newton's method, and drive µ → 0. The solutions of the relaxed system, traced over µ, form the central path — the smooth curve the iterates loosely follow. This is what makes IPMs polynomial-time in theory (the line of work started by Karmarkar in 1984) and remarkably consistent in practice: iteration counts barely grow with problem size.

What one iteration does

lpviz's IPM keeps a triple (x, s, y) with s, y > 0 and, at every iteration, measures the average complementarity µ = sᵀy/m, then:

  1. Predictor. Solve the Newton (KKT) system for the affine-scaling direction — the step aiming straight at µ = 0 — via a dense LU factorization of the full (n + 2m)-dimensional system.
  2. Step length. Compute the largest steps that keep s and y strictly positive (the fraction-to-boundary rule), separately for the primal and dual.
  3. Corrector (adaptive). If the predictor can move nearly unimpeded — both step ratios at least the corrector threshold — lpviz just takes the affine step. Otherwise it adds Mehrotra's corrector: a second solve with the same matrix that (a) recenters toward the central path with weight σ = (µaff/µ)³, where µaff is the complementarity the predictor would reach, and (b) compensates for the second-order error ΔsiΔyi the linearization ignores. When the predictor did well, σ is tiny (barely center); when it got blocked, σ approaches 1 (retreat toward the path).
  4. Move. Update (x, s, y) using the fraction-to-boundary steps scaled by the αmax slider.

Convergence is declared when the primal residual, the dual residual, and the relative duality gap are all below 10⁻⁵.

Infeasible start

The method starts at x = 0 (the canvas origin) with s = y = 1 — which typically does not satisfy Ax + s = b. That's deliberate: this is an infeasible-start IPM, and the Newton steps shrink the constraint violation and the duality gap simultaneously. Watch the Infeas column of the log: it decays to zero alongside µ. If your polygon doesn't contain the origin, the first few iterates visibly sit outside the region before the path dives in.

The controls

ControlDefaultWhat it does
αmax (max step size ratio) 0.1 Scales every step. The default is intentionally tiny so you get a long, smooth trajectory to look at. Real solvers use ≈ 0.99; try it to see the algorithm converge in a dozen iterations, cutting corners the small-step arc never would. At exactly 1, iterates may land on the boundary itself.
Corrector threshold 0.9 The step quality above which the corrector is skipped. Raise it toward 0.999 and nearly every iteration is corrected — the path stays well-centered. Lower it and the method degenerates toward pure affine scaling — greedier steps that hug the boundary and can stall near corners.
Maximum iterations 1,000 Iteration cap (log scale, up to 100k). Small αmax values need more iterations to converge.

αmax, and what a step size ratio buys

The same polygon crossed by two interior point trajectories from one starting point: a dense trail of small steps following a gentle arc, and a path of four long steps cutting straight across to the optimal vertex. αmax = 0.1 a long, readable trail αmax = 0.99 what a real solver does
Same directions, same algorithm — only the fraction of each step that is actually taken differs. The small-step path traces the geometry; the large-step path cuts corners the small one never reaches.

Every iteration computes how far it could move before s or y hits zero, then multiplies that distance by αmax. At the default 0.1 you are watching a deliberately slowed-down solver: the trajectory is dense enough to see its curvature, and it stays well inside the region because it never spends more than a tenth of its available room. At 0.99 — what production solvers use — each step lands within one percent of the boundary, the arc collapses into a few chords, and the run finishes in about a dozen iterations. Nothing about the search direction changed; only the appetite.

The corrector threshold

Two panels. On the left a narrowing corridor blocks a straight affine step, and a second curved step stays centred and travels further. On the right a wide corridor lets a single straight step run almost the whole way. step ratio below threshold affine step blocked; corrector recentres, goes further step ratio above threshold nothing in the way; corrector skipped
The threshold is a test on the predictor's step ratio, not on the objective: it asks whether the affine direction was blocked, and only pays for a second solve when it was.

The corrector costs a second solve with the same factorized matrix, so it is worth skipping when the predictor is already doing well. The threshold is where "well" is drawn: at the default 0.9, any predictor that can move at least 90% of the way to the boundary in both the primal and the dual is taken as-is. Below that, Mehrotra's corrector is added, and its centering weight σ = (µaff/µ)³ scales with how badly the predictor did — barely centering when it was almost free, retreating hard toward the central path when it was blocked at a corner. Raising the threshold toward 0.999 corrects nearly every iteration; lowering it approaches pure affine scaling, which takes the greedy direction and lets the corners deal with the consequences.

Reading the log

 Iter        x        y        Obj     Infeas          µ
    1     0.00     0.00    0.0e+0    2.4e+1    1.0e+0
    2     1.13     0.62    1.4e+1    1.1e+1    4.2e-1

Behavior to watch for