Module contents
Lesson 16 of 27Advanced 120 min

Interior-point methods

Explain the internals of solvers for LP, QP, SOCP and SDP: logarithmic barrier, central path and Newton barrier method. Introduce self-concordance and its problem-independent complexity bounds, and the primal-dual method used by solvers such as Clarabel and HiGHS.

After this lesson you can

  • Construct the logarithmic barrier for inequality constraints and derive the central path.
  • Use duality to prove a central-path point at parameter t is m/t-suboptimal.
  • Implement the barrier method with phase I and domain-preserving damped Newton.
  • Define self-concordance and explain the Newton iteration bound independent of conditioning.
  • Implement a primal-dual interior-point method for LP and compare with scipy.optimize.linprog.

Before you start

Motivation: what a solver does when you call CVXPY

You write a portfolio problem in ten lines of CVXPY, call prob.solve(verbose=True), and a fraction of a second later see a table with twenty rows: one per iteration, with primal cost, dual cost, their difference, and two residuals falling from 10010^{0} to 10−910^{-9}. The problem had thousands of variables and constraints, yet the row count barely depends on them: double the size and hardly any rows appear.

Behind the table is an interior-point method. CVXPY rewrites your model as a conic convex problem (an LP, QP, SOCP or SDP, as in lesson 4) and passes it to a solver such as Clarabel, MOSEK or HiGHS. They do, with variations, the same:

  • Replace inequality constraints with a barrier infinite at the boundary, making the problem smooth and unconstrained apart from equalities.
  • Solve that smooth problem with Newton’s method, converging in a handful of steps.
  • Gradually reduce barrier weight, following a curve of approximate solutions, the central path, to the optimum.
  • At each iteration they know exactly how far they remain: they carry primal and dual points whose difference certifies suboptimality.

This lesson builds that machinery from scratch: logarithmic barrier, central path and its m/tm/t certificate, barrier method with phase I, self-concordance theory (explaining why Newton iteration count is independent of conditioning), and the primal-dual method real solvers use. You will be able to read that table, know when to trust status: optimal, and write an LP solver matching HiGHS in about thirty lines.

Simplex versus interior point: a complexity history

An LP reaches its optimum at a vertex of the feasible polyhedron. Dantzig’s (1947) simplex method moves along edges from vertex to vertex, improving cost each jump. It is extremely fast in practice, but in 1972 Klee and Minty constructed distorted dimension-nn cubes where Dantzig’s pivot rule visits all 2n2^n vertices. Such examples are known for nearly every proposed pivot rule, and whether a rule with polynomially many steps exists remains open.

Khachiyan resolved whether linear programming is in P in 1979 with the ellipsoid method: polynomial in input bit count LL, but too slow in practice to compete with simplex. In 1984 Karmarkar published a “projective” algorithm using O(n3.5L)\bigO(n^{3.5}L) arithmetic operations, competitive on large problems. Two years later Gill, Murray, Saunders, Tomlin and Wright showed it equivalent to a logarithmic barrier method with projected Newton, a 1960s idea (Frisch, Fiacco and McCormick) abandoned for numerical issues. Renegar (1988) gave the first path-following method with O(m L)\bigO(\sqrt{m}\,L) iterations, Kojima, Mizuno and Yoshise (1989) formulated primal-dual methods, Mehrotra (1992) added the predictor-corrector used by most current codes, and Nesterov and Nemirovskii (1994) used self-concordance to explain why it works and extend it to SOCP and SDP.

Both worlds coexist. Interior point often wins on large sparse LPs; simplex yields exact vertex solutions and warm-starts well, indispensable in integer programming branch-and-bound. Many solvers run interior point then a crossover to a vertex. SOCP and SDP have no simplex: interior point is the method.

The logarithmic barrier

Start with a convex inequality-constrained problem,

min⁡xf0(x)subject tofi(x)≤0,i=1,…,m,Ax=b,\begin{aligned} \min_{\vb{x}} \quad & f_0(\vb{x}) \\ \text{subject to} \quad & f_i(\vb{x}) \le 0, \quad i = 1, \dots, m, \\ & \mat{A}\vb{x} = \vb{b}, \end{aligned}

with f0,…,fmf_0, \dots, f_m convex and twice differentiable, A∈Rp×n\mat{A} \in \R^{p\times n} of rank pp, attained optimum p⋆p^\star and a strictly feasible point (Slater’s condition, ensuring strong duality). Equalities do not trouble Newton, handled by a linear KKT system; inequalities do, introducing combinatorial choices (which constraints are active) no second-order method sees.

Hide inequalities in the objective. With indicator I−(u)=0I_-(u) = 0 if u≤0u \le 0 and I−(u)=+∞I_-(u) = +\infty if u>0u > 0, the problem is equivalent to minimizing f0(x)+∑iI−(fi(x))f_0(\vb{x}) + \sum_i I_-(f_i(\vb{x})) with Ax=b\mat{A}\vb{x} = \vb{b}. The indicator is nondifferentiable, but can be approximated by a smooth function also diverging at the boundary:

I^−(u)=−1tlog⁡(−u),u<0,\hat{I}_-(u) = -\frac{1}{t}\log(-u), \qquad u < 0,

with t>0t > 0. It is convex, increasing and tends to +∞+\infty as u→0−u \to 0^-; as tt grows it flattens for u<0u < 0 and approaches the indicator.

ϕ\phi is convex because −log⁡(−u)-\log(-u) is convex and increasing and each fif_i is convex. Its derivatives are

∇ϕ(x)=∑i=1m1−fi(x)∇fi(x),∇2ϕ(x)=∑i=1m1fi(x)2∇fi(x)∇fi(x)⊤+∑i=1m1−fi(x)∇2fi(x).\grad\phi(\vb{x}) = \sum_{i=1}^m \frac{1}{-f_i(\vb{x})}\grad f_i(\vb{x}), \qquad \hess\phi(\vb{x}) = \sum_{i=1}^m \frac{1}{f_i(\vb{x})^2}\grad f_i(\vb{x})\grad f_i(\vb{x})\T + \sum_{i=1}^m \frac{1}{-f_i(\vb{x})}\hess f_i(\vb{x}).

For an LP in inequality form, fi(x)=a~i⊤x−bif_i(\vb{x}) = \tilde{\vb{a}}_i\T\vb{x} - b_i, and with slacks si=bi−a~i⊤x>0s_i = b_i - \tilde{\vb{a}}_i\T\vb{x} > 0 everything is written with matrix products:

ϕ(x)=−∑ilog⁡si,∇ϕ=A⊤d,di=1si,∇2ϕ=A⊤diag⁡(1si2)A.\phi(\vb{x}) = -\sum_i \log s_i, \qquad \grad\phi = \mat{A}\T\vb{d}, \quad d_i = \frac{1}{s_i}, \qquad \hess\phi = \mat{A}\T\diag\Big(\frac{1}{s_i^2}\Big)\mat{A}.

The Hessian sums outer products a~ia~i⊤\tilde{\vb{a}}_i\tilde{\vb{a}}_i\T weighted by 1/si21/s_i^2: near-active constraints dominate curvature. This geometry deforms in the next figure: far from the boundary the barrier is nearly flat; near an edge its curvature grows without bound normally and barely tangentially.

The central path and the m/tm/t certificate

For each t>0t > 0, let x⋆(t)\vb{x}^\star(t) minimize tf0+ϕt f_0 + \phi with Ax=b\mat{A}\vb{x} = \vb{b} (assume it exists uniquely; existence follows, for example, when the feasible set is bounded because tf0+ϕt f_0 + \phi tends to +∞+\infty at the boundary; uniqueness also needs tf0+ϕt f_0 + \phi strictly convex on {x:Ax=b}\{\vb{x} : \mat{A}\vb{x} = \vb{b}\}, as in an LP with bounded polyhedron).

For an LP, centrality is force balance: tc+∑ia~i/si=0t\vb{c} + \sum_i \tilde{\vb{a}}_i/s_i = \vb{0}. The objective pulls x\vb{x} with constant force −tc-t\vb{c}; each constraint pushes inward with force −a~i/si-\tilde{\vb{a}}_i/s_i, magnitude ∥a~i∥/si\norm{\tilde{\vb{a}}_i}/s_i, exactly the inverse distance si/∥a~i∥s_i/\norm{\tilde{\vb{a}}_i} from x\vb{x} to its hyperplane. With small tt the barrier wins and the point stays central; with large tt it approaches the boundary until nearly active constraints balance the pull.

InteractiveThe central path
analytic center
  • central path
  • x⋆(t)\vb{x}^\star(t)
  • contours of t c⊤x+ϕ(x)t\,\vb{c}\T\vb{x} + \phi(\vb{x})
  • analytic center and optimal vertex
t = 2
Constraints mm5
Bound m/tm/t2.5
Suboptimality c⊤x⋆(t)−p⋆\vb{c}\T\vb{x}^\star(t) - p^\star0.68
Dual gap ∑iλisi\sum_i \lambda_i s_i2.5
Minimum slack0.589
Net force at x⋆(t)\vb{x}^\star(t)3·10⁻¹¹
λi=wi/(tsi)\lambda_i = w_i/(t s_i): 0.26 0.38 0.85 0.6 0.22
As tt grows the objective gains weight and x⋆(t)\vb{x}^\star(t) approaches the optimal vertex without touching the boundary.
A planar LP: minimize c⊤x\vb{c}\T\vb{x} in the polygon, one constraint per edge. Red point is x⋆(t)\vb{x}^\star(t), minimizing t c⊤x−∑ilog⁡sit\,\vb{c}\T\vb{x} - \sum_i \log s_i; orange curve is the full central path from analytic center to optimal vertex. Move tt: purple barrier contours deform and close around the vertex. Enable forces to check balance. Set tt to 10001000 and inspect suboptimality: almost exactly 2/t2/t, not m/tm/t. Repeat an edge ten times: the polygon is unchanged but the path is not. Drag vertices and the corner's −c-\vb{c} arrow.

A free dual point

Centrality resembles stationarity of a Lagrangian. Divide by tt and define

λi⋆(t)=−1t fi(x⋆(t))>0,ν⋆(t)=ν^t.\lambda_i^\star(t) = -\frac{1}{t\,f_i(\vb{x}^\star(t))} > 0, \qquad \vb{\nu}^\star(t) = \frac{\hat{\vb{\nu}}}{t}.

Then ∇f0(x⋆)+∑iλi⋆∇fi(x⋆)+A⊤ν⋆=0\grad f_0(\vb{x}^\star) + \sum_i \lambda_i^\star\grad f_i(\vb{x}^\star) + \mat{A}\T\vb{\nu}^\star = \vb{0}: x⋆(t)\vb{x}^\star(t) minimizes Lagrangian L(⋅,λ⋆(t),ν⋆(t))L(\cdot, \vb{\lambda}^\star(t), \vb{\nu}^\star(t)), convex in x\vb{x} because λ⋆(t)>0\vb{\lambda}^\star(t) > \vb{0}. Thus we have a dual feasible point and evaluate its dual function without another solve.

The short proof is reconstructed in the final guided exercise; the missing ingredient is weak duality, p⋆≥g(λ,ν)p^\star \ge g(\vb{\lambda}, \vb{\nu}). The bound depends on neither data, dimension nn, nor conditioning; only constraint count. To guarantee suboptimality ε\eps, center at t=m/εt = m/\eps.

Perturbed KKT conditions

Another reading of the central path generalizes to primal-dual methods. The original problem’s KKT conditions are primal and dual feasibility, stationarity and complementary slackness −λifi(x)=0-\lambda_i f_i(\vb{x}) = 0. A point x\vb{x} lies on the central path iff λ,ν\vb{\lambda}, \vb{\nu} exist with

fi(x)≤0,  Ax=b,λ⪰0,∇f0(x)+∑iλi∇fi(x)+A⊤ν=0,−λifi(x)=1/t,i=1,…,m.\begin{aligned} f_i(\vb{x}) \le 0,\ \ \mat{A}\vb{x} = \vb{b}, \qquad & \vb{\lambda} \succeq \vb{0}, \\ \grad f_0(\vb{x}) + \textstyle\sum_i \lambda_i\grad f_i(\vb{x}) + \mat{A}\T\vb{\nu} = \vb{0}, \qquad & -\lambda_i f_i(\vb{x}) = 1/t, \quad i = 1, \dots, m. \end{aligned}

These are KKT with complementary slackness replaced by −λifi=1/t-\lambda_i f_i = 1/t: each constraint contributes exactly 1/t1/t to the gap, totaling m/tm/t. As t→∞t \to \infty we recover KKT. Primal-dual methods attack this system directly.

Actual suboptimality is smaller than the bound

The figure shows something the bound does not: if the optimal vertex is nondegenerate (exactly nn active constraints) and strict complementarity holds (λi⋆>0\lambda_i^\star > 0 for all of them), actual LP central-path suboptimality is almost exactly n/tn/t at large tt, not m/tm/t. To see why, let λ⋆\vb{\lambda}^\star be the dual optimum, with c=−A⊤λ⋆\vb{c} = -\mat{A}\T\vb{\lambda}^\star and λi⋆=0\lambda_i^\star = 0 outside active set I\mathcal{I} of optimal vertex x⋆\vb{x}^\star. Then

c⊤x−p⋆=c⊤(x−x⋆)=∑i∈Iλi⋆(bi−a~i⊤x)=∑i∈Iλi⋆si.\vb{c}\T\vb{x} - p^\star = \vb{c}\T(\vb{x} - \vb{x}^\star) = \sum_{i\in\mathcal{I}} \lambda_i^\star\big(b_i - \tilde{\vb{a}}_i\T\vb{x}\big) = \sum_{i\in\mathcal{I}} \lambda_i^\star s_i.

On the central path, λi(t) si(t)=1/t\lambda_i(t)\,s_i(t) = 1/t and since the dual solution is unique (guaranteed by vertex nondegeneracy), λi(t)→λi⋆>0\lambda_i(t) \to \lambda_i^\star > 0. Thus t (c⊤x⋆(t)−p⋆)=∑i∈Iλi⋆/λi(t)→∣I∣=nt\,(\vb{c}\T\vb{x}^\star(t) - p^\star) = \sum_{i\in\mathcal{I}} \lambda_i^\star/\lambda_i(t) \to \abs{\mathcal{I}} = n. Inactive constraints also contribute 1/t1/t each to gap m/tm/t, but that part is dual-side slack: p⋆−g(λ(t))≈(m−n)/tp^\star - g(\vb{\lambda}(t)) \approx (m - n)/t. The code cell checks this for an LP with m=100m = 100 and n=50n = 50.

The barrier method

The theorem suggests a one-step algorithm: center at t=m/εt = m/\eps. Theoretically valid, but with huge tt the centering problem is badly conditioned (the barrier only matters within 1/t1/t of the boundary), and Newton starting far away needs many damped steps. Follow the central path in stages, using each center to start the next.

Each centering uses lesson 13’s damped Newton with two special details. The equality-constrained Newton step solves the KKT system

[t∇2f0+∇2ϕA⊤A0][Δxw]=−[t∇f0+∇ϕ0],\begin{bmatrix} t\hess f_0 + \hess\phi & \mat{A}\T \\ \mat{A} & \mat{0} \end{bmatrix} \begin{bmatrix} \Delta\vb{x} \\ \vb{w} \end{bmatrix} = -\begin{bmatrix} t\grad f_0 + \grad\phi \\ \vb{0} \end{bmatrix},

and the stopping criterion uses Newton decrement λ(x)2=−(t∇f0+∇ϕ)⊤Δx\lambda(\vb{x})^2 = -(t\grad f_0 + \grad\phi)\T\Delta\vb{x}, affine invariant. The second detail is domain: backtracking starts with a full step and must first shrink it until strictly feasible, only then checking Armijo. Evaluating ϕ\phi outside its domain makes log⁡\log of a negative number nan; since nan > a is false, Armijo comparison “accepts” it. In an LP the maximum step inside the domain is closed-form, sup⁡{τ:τ a~i⊤Δx<si ∀i}=min⁡i:a~i⊤Δx>0si/(a~i⊤Δx)\sup\{\tau : \tau\,\tilde{\vb{a}}_i\T\Delta\vb{x} < s_i\ \forall i\} = \min_{i : \tilde{\vb{a}}_i\T\Delta\vb{x} > 0} s_i/(\tilde{\vb{a}}_i\T\Delta\vb{x}), and one starts at a fraction, e.g. 99%.

Stage count and factor μ\mu

After initial centering at t0t_0, stage kk centers at t0μkt_0\mu^k, so the method finishes after

⌈log⁡(m/(εt0))log⁡μ⌉\left\lceil \frac{\log\big(m/(\eps t_0)\big)}{\log\mu} \right\rceil

updates of tt, plus initial centering. With m=100m = 100, t0=1t_0 = 1, ε=10−6\eps = 10^{-6} and μ=10\mu = 10 there are ⌈log⁡10108⌉=8\lceil \log_{10} 10^8\rceil = 8 updates and nine centerings. Large μ\mu reduces stages, but each starts farther from its target and needs more Newton steps. Small μ\mu gives one- or two-step centerings but many stages. Where is the balance?

InteractiveNewton iterations per centering
Gap bound m/tm/t versus cumulative Newton iterations
  • μ = 2
  • μ = 10
  • μ = 50
  • μ = 200
  • μ = 20 (custom)
Total iterations to m/t≤10−6m/t \le 10^{-6} by μ\mu
Problem
Update factors
20
μ=2\mu = 227 centering steps, 65 Newton (2.3 per stage)
μ=10\mu = 109 centering steps, 52 Newton (6 per stage)
μ=50\mu = 506 centering steps, 40 Newton (7.2 per stage)
μ=200\mu = 2005 centering steps, 38 Newton (8.5 per stage)
μ=20\mu = 20 (custom)7 centering steps, 39 Newton (5.8 per stage)
With μ=2\mu = 2 there are 27 centering steps of about 2.3 iterations; with μ=200\mu = 200, 5 steps of about 8.5. The lowest displayed total is 38, at μ=200\mu = 200.
Barrier method on a random LP with t0=1t_0 = 1, starting strictly feasible but off-center, until m/t≤10−6m/t \le 10^{-6}. Left, gap bound versus cumulative Newton iterations: each horizontal step is a centering (during it the available certificate is the prior center's); each vertical drop updates tt. Right, total iterations versus μ\mu. Compare the fine staircase at μ=2\mu = 2 with long steps at μ=200\mu = 200; move free μ\mu below 2 and above 100; switch to the large problem and see the change in total when mm triples.

The right curve is the practical lesson: except when μ\mu is very close to 1, total work is nearly flat over a huge range. With μ\mu between 10 and 200 the method needs 35–60 total Newton iterations, and tripling constraints adds at most about fifteen (1–14 depending on μ\mu). Large-μ\mu centerings cost more but not proportionally to μ\mu: Newton from the prior center soon reaches its quadratic phase. Theory below is much more pessimistic and recommends μ=1+1/m\mu = 1 + 1/\sqrt{m}, giving the polynomial guarantee rather than the practical choice.

Phase I: finding a strictly feasible point

The method must start inside ϕ\phi‘s domain. If no such point is known, solve another convex problem for which one is known: phase I:

min⁡x,s ssubject tofi(x)≤s,  i=1,…,m,Ax=b.\min_{\vb{x}, s}\ s \quad \text{subject to} \quad f_i(\vb{x}) \le s,\ \ i = 1, \dots, m, \qquad \mat{A}\vb{x} = \vb{b}.

For any x\vb{x} with Ax=b\mat{A}\vb{x} = \vb{b} (e.g. the minimum-norm solution), pair (x,s)(\vb{x}, s) with s>max⁡ifi(x)s > \max_i f_i(\vb{x}) is strictly feasible, so solve by the same barrier method. If its optimum pˉ⋆\bar{p}^\star is negative, the original is strictly feasible and stopping as soon as s<0s < 0 suffices; phase I need not finish. If pˉ⋆>0\bar{p}^\star > 0, the original is infeasible and the phase-I dual gives a certificate (an alternative from the duality lesson). If pˉ⋆=0\bar{p}^\star = 0, no strictly feasible points exist (though feasible ones may) and the barrier method cannot be applied unchanged. A useful variant minimizes the sum of violations, ∑isi\sum_i s_i with fi≤sif_i \le s_i and si≥0s_i \ge 0: when infeasible, it leaves many constraints satisfied and identifies incompatible ones.

Self-concordance and complexity

Lesson 13 bounded damped Newton iterations by (f(x0)−p⋆)/γ+log⁡2log⁡2(1/ε)(f(\vb{x}_0) - p^\star)/\gamma + \log_2\log_2(1/\eps), with γ\gamma depending on strong convexity, Hessian Lipschitz constant and a Hessian upper bound. These constants are disastrous for the barrier: near its boundary ϕ\phi‘s Hessian and Lipschitz constant explode. Yet Newton is affine invariant, so its behavior cannot depend on them. We need an affine-invariant hypothesis.

Why these exponents? Reparameterize f~(y)=f(ay+b)\tilde{f}(y) = f(a y + b): f~′′=a2f′′\tilde{f}'' = a^2 f'' and f~′′′=a3f′′′\tilde{f}''' = a^3 f''', so ratio ∣f′′′∣/(f′′)3/2\abs{f'''}/(f'')^{3/2} is unchanged: the definition is affine invariant, like Newton. Constant 2 normalizes the fundamental example to equality. Geometrically, the third derivative measures curvature change, and the condition says curvature changes slowly on its own scale, natural length 1/f′′1/\sqrt{f''}.

Examples and counterexamples:

  • Linear and convex quadratic: f′′′=0f''' = 0. Self-concordant.
  • f(x)=−log⁡xf(x) = -\log x: f′′(x)=1/x2f''(x) = 1/x^2 and f′′′(x)=−2/x3f'''(x) = -2/x^3, so ∣f′′′∣=2/x3=2(1/x2)3/2\abs{f'''} = 2/x^3 = 2(1/x^2)^{3/2}. Equality holds.
  • f(x)=xlog⁡x−log⁡xf(x) = x\log x - \log x on x>0x > 0: self-concordant (arises adding a barrier to maximum-entropy problems).
  • f(x)=exf(x) = e^x is not: ex≤2e3x/2e^x \le 2e^{3x/2} fails for x<−2log⁡2x < -2\log 2. f(x)=1/xf(x) = 1/x on x>0x > 0 is not either: 6/x4≤2(2/x3)3/26/x^4 \le 2(2/x^3)^{3/2} fails for x>8/9x > 8/9.

Three calculus rules make the class huge: self-concordance is preserved by multiplication by a≥1a \ge 1, adding two self-concordant functions and affine composition, f(Ax+b)f(\mat{A}\vb{x} + \vb{b}). The first is immediate (a∣f′′′∣≤2af′′3/2≤2(af′′)3/2a\abs{f'''} \le 2a f''^{3/2} \le 2(af'')^{3/2} because a≤a3/2a \le a^{3/2}); the other two are the second guided exercise. Together they provide what the barrier method needs: a polyhedron barrier, −∑ilog⁡(bi−a~i⊤x)-\sum_i\log(b_i - \tilde{\vb{a}}_i\T\vb{x}), sums affine compositions of −log⁡-\log, and tc⊤x+ϕ(x)t\vb{c}\T\vb{x} + \phi(\vb{x}) is self-concordant for all tt. Likewise for QP (convex quadratic tf0t f_0) and, as shown later, SOCP and SDP barriers.

Newton on self-concordant functions

The proof (Boyd and Vandenberghe, section 9.6.4) uses two facts: the Dikin ellipsoid {y:(y−x)⊤∇2f(x)(y−x)<1}\{\vb{y} : (\vb{y} - \vb{x})\T\hess f(\vb{x})(\vb{y} - \vb{x}) < 1\} lies inside the domain, and there the Hessian varies by at most factor (1−r)±2(1 - r)^{\pm 2}, with rr distance in the Hessian norm. Compare lesson 13: there γ\gamma depended on μ\mu, MM and conditioning; here it is a universal constant depending only on backtracking parameters. Iteration count depends only on how far the objective must fall.

Constants are pessimistic. With α=0.1\alpha = 0.1 and β=0.8\beta = 0.8, 1/γ=3751/\gamma = 375: the bound guarantees a 1/3751/375 decrease per damped iteration. In practice each barrier centering takes 5–15 iterations.

Barrier-method complexity

To bound the whole method we must know the decrease needed at each centering.

Proof

Let λi=−1/(tfi(x))\lambda_i = -1/(t f_i(\vb{x})) be the central path’s dual point. By definition of ϕ\phi,

ϕ(x)−ϕ(x+)=∑ilog⁡fi(x+)fi(x)=∑ilog⁡(−μtλifi(x+))−mlog⁡μ≤−μt∑iλifi(x+)−m−mlog⁡μ,\phi(\vb{x}) - \phi(\vb{x}^+) = \sum_i \log\frac{f_i(\vb{x}^+)}{f_i(\vb{x})} = \sum_i \log\big(-\mu t\lambda_i f_i(\vb{x}^+)\big) - m\log\mu \le -\mu t\sum_i \lambda_i f_i(\vb{x}^+) - m - m\log\mu,

using log⁡a≤a−1\log a \le a - 1. Adding μt(f0(x)−f0(x+))\mu t(f_0(\vb{x}) - f_0(\vb{x}^+)) on both sides, the right contains −μt(f0(x+)+∑iλifi(x+))=−μt L(x+,λ,ν)≤−μt g(λ,ν)-\mu t\big(f_0(\vb{x}^+) + \sum_i\lambda_i f_i(\vb{x}^+)\big) = -\mu t\,L(\vb{x}^+, \vb{\lambda}, \vb{\nu}) \le -\mu t\,g(\vb{\lambda}, \vb{\nu}) (equalities Ax+=b\mat{A}\vb{x}^+ = \vb{b} cancel the ν\vb{\nu} term). This leaves μt(f0(x)−g(λ,ν))−m−mlog⁡μ=μt⋅mt−m−mlog⁡μ\mu t\big(f_0(\vb{x}) - g(\vb{\lambda}, \vb{\nu})\big) - m - m\log\mu = \mu t\cdot\tfrac{m}{t} - m - m\log\mu.

∎

Newton’s theorem bounds each stage by m(μ−1−log⁡μ)/γ+log⁡2log⁡2(1/ε)m(\mu - 1 - \log\mu)/\gamma + \log_2\log_2(1/\eps) iterations. Choose μ=1+1/m\mu = 1 + 1/\sqrt{m}. Since log⁡(1+u)≥u−u2/2\log(1 + u) \ge u - u^2/2, the numerator is m(μ−1−log⁡μ)≤m⋅12m=12m(\mu - 1 - \log\mu) \le m\cdot\tfrac{1}{2m} = \tfrac12: each stage costs a constant number of Newton steps. Since log⁡(1+u)≥u/2\log(1 + u) \ge u/2 for u∈[0,1]u \in [0, 1], stages number at most 2mlog⁡(m/(t0ε))2\sqrt{m}\log(m/(t_0\eps)). In total,

NNewton=O(m log⁡mt0 ε),N_{\text{Newton}} = \bigO\Big(\sqrt{m}\,\log\frac{m}{t_0\,\eps}\Big),

with universal constants. Each Newton step for a dense LP costs O(mn2)\bigO(mn^2) operations (form A⊤DA\mat{A}\T\mat{D}\mat{A} and factor by Cholesky), so the method is polynomial (in standard asymptotic notation). Express precision in input bits, log⁡(1/ε)=O(L)\log(1/\eps) = \bigO(L), to recover Renegar’s O(m L)\bigO(\sqrt{m}\,L) bound.

Two qualifications. First, the bound requires extremely short centering stages, which nobody uses; theory guarantees and practice (previous figure) supplies speed with μ\mu between 10 and 100 and total almost size-independent. Second, m\sqrt{m} is the square root of the barrier parameter, θ=m\theta = m for mm linear inequalities; generally the bound is O(θlog⁡(θ/(t0ε)))\bigO(\sqrt{\theta}\log(\theta/(t_0\eps))). Nesterov and Nemirovskii proved every closed convex set with interior has a self-concordant barrier (the universal barrier) with parameter O(n)\bigO(n), extending the scheme theoretically to any convex problem. Practice is restricted to cones with closed-form barriers.

The primal-dual method

The barrier method has nested loops and moves only the primal; the dual emerges after each centering. Modern solvers act more directly: treat perturbed KKT as simultaneous nonlinear equations in (x,λ,ν)(\vb{x}, \vb{\lambda}, \vb{\nu}), take one Newton step and update tt every iteration.

Write this for an LP in standard form, as Wright and Nocedal–Wright do:

min⁡x c⊤xsubject toAx=b,  x⪰0,max⁡y,s b⊤ysubject toA⊤y+s=c,  s⪰0,\min_{\vb{x}}\ \vb{c}\T\vb{x} \quad \text{subject to} \quad \mat{A}\vb{x} = \vb{b},\ \ \vb{x} \succeq \vb{0}, \qquad\qquad \max_{\vb{y}, \vb{s}}\ \vb{b}\T\vb{y} \quad \text{subject to} \quad \mat{A}\T\vb{y} + \vb{s} = \vb{c},\ \ \vb{s} \succeq \vb{0},

with A∈Rm×n\mat{A} \in \R^{m\times n}. The gap is c⊤x−b⊤y=x⊤s\vb{c}\T\vb{x} - \vb{b}\T\vb{y} = \vb{x}\T\vb{s}, and complementary slackness is xisi=0x_i s_i = 0. The central path solves

rd=A⊤y+s−c=0,rp=Ax−b=0,xisi=τ,(x,s)≻0,\vb{r}_d = \mat{A}\T\vb{y} + \vb{s} - \vb{c} = \vb{0}, \qquad \vb{r}_p = \mat{A}\vb{x} - \vb{b} = \vb{0}, \qquad x_i s_i = \tau, \quad (\vb{x}, \vb{s}) \succ \vb{0},

for τ>0\tau > 0 (the earlier 1/t1/t). With X=diag⁡(x)\mat{X} = \diag(\vb{x}), S=diag⁡(s)\mat{S} = \diag(\vb{s}) and duality measure μ=x⊤s/n\mu = \vb{x}\T\vb{s}/n (average gap per coordinate; in this section μ\mu means that, not barrier factor), choose target τ=σμ\tau = \sigma\mu with centering parameter σ∈[0,1]\sigma \in [0, 1].

Three observations turn this definition into an efficient, understandable algorithm.

The system reduces to a symmetric positive definite one. Eliminate Δs=−rd−A⊤Δy\Delta\vb{s} = -\vb{r}_d - \mat{A}\T\Delta\vb{y} and Δx\Delta\vb{x} from the third row to obtain the normal equation

ADA⊤ Δy=−rp−ADrd−AS−1rc,D=XS−1,rc=−XS1+σμ1,\mat{A}\mat{D}\mat{A}\T\,\Delta\vb{y} = -\vb{r}_p - \mat{A}\mat{D}\vb{r}_d - \mat{A}\mat{S}\inv\vb{r}_c, \qquad \mat{D} = \mat{X}\mat{S}\inv, \quad \vb{r}_c = -\mat{X}\mat{S}\vb{1} + \sigma\mu\vb{1},

an m×mm\times m positive definite matrix factored by Cholesky. If A\mat{A} is sparse, ADA⊤\mat{A}\mat{D}\mat{A}\T always has the same zero pattern (only D\mat{D} changes), so a fill-reducing ordering is computed once and reused (enabling LPs with millions of variables using sparse matrix formats). Final D\mat{D} ill-conditioning, with entries 10−1010^{-10} and 101010^{10}, is benign because of error structure, a nontrivial fact studied by Wright.

Linear residuals fall exactly by factor 1−α1 - \alpha. Since AΔx=−rp\mat{A}\Delta\vb{x} = -\vb{r}_p, the new residual is A(x+αΔx)−b=(1−α)rp\mat{A}(\vb{x} + \alpha\Delta\vb{x}) - \vb{b} = (1 - \alpha)\vb{r}_p, and likewise rd\vb{r}_d. Thus the method can start outside the feasible set: with x=s=1\vb{x} = \vb{s} = \vb{1} and y=0\vb{y} = \vb{0}, without phase I. Feasibility arrives gradually, completely as soon as a full α=1\alpha = 1 step is taken.

σ\sigma allocates the step between centering and progress. With σ=0\sigma = 0 aim directly at KKT (the affine, or affine-scaling direction): most ambitious, but some products xisix_i s_i reach zero much earlier than others, the boundary step becomes tiny and the method stalls. With σ=1\sigma = 1 aim at the central-path point with the same μ\mu: center without progress. Short-step path-following methods with σ=1−0.4/n\sigma = 1 - 0.4/\sqrt{n} have O(nlog⁡(1/ε))\bigO(\sqrt{n}\log(1/\eps)) iterations, the same as the barrier method, and are just as slow in practice.

InteractivePrimal-dual residuals
  • central path
  • iterates xk\vb{x}_k
  • start x0\vb{x}_0
  • optimal vertex
Residuals and μ\mu (logarithmic scale)
  • primal residual
  • dual residual
  • μ = sᵀz/m
Step length α\alpha and σ\sigma at each iteration
  • step α
  • σ used
iteration 0
0.3
Iteration kk0 of 18
Primal residual ∥rp∥\norm{\vb{r}_p}4.81
Dual residual ∥rd∥\norm{\vb{r}_d}0.441
μ=s⊤z/m\mu = \vb{s}\T\vb{z}/m1
xk\vb{x}_k inside the polygonno
Converged in 18 iterations. ∥rp∥\norm{\vb{r}_p} fell below 10−910^{-9} at iteration 7: from there xk\vb{x}_k is feasible up to rounding.
Primal-dual method on the polygon LP, written min⁡c⊤x\min \vb{c}\T\vb{x} with Ax+s=b\mat{A}\vb{x} + \vb{s} = \vb{b}, s⪰0\vb{s} \succeq \vb{0}, duals z⪰0\vb{z} \succeq \vb{0}. Start with s=z=1\vb{s} = \vb{z} = \vb{1} and draggable x0\vb{x}_0 (default outside polygon): infeasible. Step through and compare red trajectory with dashed central path. Right, ∥rp∥\norm{\vb{r}_p}, ∥rd∥\norm{\vb{r}_d} and μ\mu; below, each iteration's α\alpha and σ\sigma. Return to early iterations to check primal residual falls exactly by 1−α1 - \alpha. Raise σ\sigma to 1 (does μ\mu fall?), lower to 0.05 and enable Mehrotra: how many iterations are saved?

Mehrotra’s predictor-corrector

Which σ\sigma? Mehrotra (1992) proposed choosing each iteration with cheap information. First calculate affine direction (σ=0\sigma = 0) and admissible step αaf\alpha_{\text{af}}; estimate resulting gap μaf=(x+αafΔxaf)⊤(s+αafΔsaf)/n\mu_{\text{af}} = (\vb{x} + \alpha_{\text{af}}\Delta\vb{x}_{\text{af}})\T(\vb{s} + \alpha_{\text{af}}\Delta\vb{s}_{\text{af}})/n, and set

σ=(μafμ)3.\sigma = \Big(\frac{\mu_{\text{af}}}{\mu}\Big)^3.

If the affine direction progresses far, σ\sigma is tiny and exploits it; if it stalls, σ\sigma approaches 1 and centers. It also adds second-order term −ΔXafΔSaf1-\Delta\mat{X}_{\text{af}}\Delta\mat{S}_{\text{af}}\vb{1} to complementarity’s right side: linearizing xisix_i s_i ignores ΔxiΔsi\Delta x_i\Delta s_i, estimated by the predictor. This costs one extra substitution using the same Cholesky factorization, the expensive part. Polynomial complexity is not guaranteed (without safeguards examples take tiny steps or fail to converge), but in practice it saves many iterations (about a third versus fixed σ=0.1\sigma = 0.1 in the code cell), so nearly all LP codes use it with safeguards.

Barriers for cones: SOCP and SDP

Everything above generalizes to conic problems, min⁡c⊤x\min \vb{c}\T\vb{x} with Ax=b\mat{A}\vb{x} = \vb{b} and x∈K\vb{x} \in \mathcal{K}, given a barrier for cone K\mathcal{K}. The m/tm/t certificate works through logarithmic homogeneity: log⁡(sy)=log⁡y+log⁡s\log(s y) = \log y + \log s. ψ\psi is a generalized logarithm of degree θ\theta for K\mathcal{K} is concave, closed, twice differentiable with negative definite Hessian, has domain the interior of K\mathcal{K}, and satisfies ψ(sy)=ψ(y)+θlog⁡s\psi(s\vb{y}) = \psi(\vb{y}) + \theta\log s for s>0s > 0. Lesson 4’s three cones:

ConeBarrier −ψ-\psiDegree θ\thetaGradient of ψ\psi
Orthant R+p\R^p_+−∑ilog⁡yi-\sum_i \log y_ipp(1/y1,…,1/yp)(1/y_1, \dots, 1/y_p)
Second order {(u,w):∥u∥2≤w}\{(\vb{u}, w) : \norm{\vb{u}}_2 \le w\}−log⁡(w2−∥u∥22)-\log(w^2 - \norm{\vb{u}}_2^2)222w2−∥u∥2(−u,w)\tfrac{2}{w^2 - \norm{\vb{u}}^2}(-\vb{u}, w)
Semidefinite S+p\mathbb{S}^p_+−log⁡det⁡X-\log\det\mat{X}ppX−1\mat{X}\inv

For conic constraints fi(x)⪯Ki0\vb{f}_i(\vb{x}) \preceq_{\mathcal{K}_i} \vb{0} of degrees θi\theta_i, the central path gives a dual point with gap ∑iθi/t\sum_i\theta_i/t: total degree replaces mm. An SDP with X∈S100\mat{X} \in \mathbb{S}^{100} has degree 100100 despite 50505050 scalar variables. All three barriers are self-concordant. For −log⁡det⁡-\log\det, restrict to a line: −log⁡det⁡(X+sV)=−log⁡det⁡X−∑ilog⁡(1+sλi)-\log\det(\mat{X} + s\mat{V}) = -\log\det\mat{X} - \sum_i\log(1 + s\lambda_i), where λi\lambda_i are eigenvalues of X−1/2VX−1/2\mat{X}^{-1/2}\mat{V}\mat{X}^{-1/2}, a sum of −log⁡-\log of affine functions of ss.

For semidefinite problems Newton must apply Hessian V↦X−1VX−1\mat{V} \mapsto \mat{X}\inv\mat{V}\mat{X}\inv, and primal-dual methods must linearize XS=τI\mat{X}\mat{S} = \tau\mat{I} while preserving symmetry. The canonical choice is Nesterov–Todd scaling, treating primal and dual symmetrically and available for all symmetric cones (orthant, second order, semidefinite and products). Exponential and power cones are not symmetric and need special techniques; Clarabel and MOSEK include both, ECOS the exponential cone.

Inside a modern solver

A production conic interior-point solver such as Clarabel (Goulart and Chen, 2024), ECOS or MOSEK combines these pieces with numerical engineering (HiGHS’s LP IPM uses a different design, with preconditioned iterative system solves and crossover):

  • Preprocessing. Remove redundant rows, fixed variables and dominated constraints; rescale data to balance norms.
  • Homogeneous embedding (self-dual in ECOS and MOSEK). Instead of phase I, solve an expanded problem with two more scalars κ\kappa and τ\tau, always trivially feasible, whose limit yields either a solution or a primal or dual infeasibility certificate (a proving direction). This permits guaranteed output status infeasible.
  • Sparse KKT system. Rather than normal equations, densified by even one dense column of A\mat{A}, Clarabel and ECOS factor the full KKT system, symmetric indefinite but quasidefinite after small regularization, using sparse LDL⊤\mat{L}\mat{D}\mat{L}\T (Clarabel uses QDLDL) and approximate minimum-degree ordering. Iterative refinement then recovers accuracy lost to regularization.
  • Mehrotra predictor-corrector with Nesterov–Todd scaling and boundary step η≈0.99\eta \approx 0.99.
  • Relative-tolerance stopping on primal residual, dual residual and gap, typically around 10−810^{-8}.

Each iteration costs a sparse factorization, and iteration count (10–50) depends little on size. This makes interior point predictable: total time grows like factorization cost times nearly constant iteration count, without simplex’s possible combinatorial explosions.

Implementation from scratch

Begin with barrier method plus phase I for an inequality-form LP, min⁡c⊤x\min\vb{c}\T\vb{x} with Ax⪯b\mat{A}\vb{x} \preceq \vb{b}. Function centrar accepts any convex objective returning value, gradient and Hessian, so it also serves phase I and a QP. The random LP is constructed so x=0\vb{x} = \vb{0} is not feasible but the dual is (c=−A⊤λ\vb{c} = -\mat{A}\T\vb{\lambda} with λ≻0\vb{\lambda} \succ \vb{0}), ensuring boundedness.

[ ]Barrier method with phase IBrowser
import numpy as np
from scipy.linalg import cho_factor, cho_solve
from scipy.optimize import linprog

def centrar(f0, A, b, t, x, tol=1e-6, alfa=0.01, beta=0.5, max_iter=60, parar=None):
    """Newton amortiguado para t*f0(x) - sum(log(b - A x)); devuelve (x, iteraciones)."""
    F = lambda z: t * f0(z)[0] - np.sum(np.log(b - A @ z))
    for k in range(max_iter):
        s = b - A @ x
        _, g0, H0 = f0(x)
        g = t * g0 + A.T @ (1 / s)
        H = t * H0 + A.T @ ((1 / s**2)[:, None] * A)
        dx = -cho_solve(cho_factor(H), g)
        lam2 = -g @ dx                                   # decremento de Newton al cuadrado
        if lam2 / 2 <= tol:
            return x, k
        Adx = A @ dx                                     # paso máximo dentro del dominio, en cerrado
        sale = Adx > 0
        paso = min(1.0, 0.99 * np.min(s[sale] / Adx[sale])) if np.any(sale) else 1.0
        Fx = F(x)                                        # solo ahora se evalúa F: el paso es factible
        while F(x + paso * dx) > Fx - alfa * paso * lam2 and paso > 1e-12:
            paso *= beta
        x = x + paso * dx
        if parar is not None and parar(x):
            return x, k + 1
    return x, max_iter

def metodo_barrera(f0, A, b, x0, t0=1.0, mu=20.0, eps=1e-6):
    m = len(b)
    if np.any(A @ x0 >= b):
        raise ValueError("x0 debe ser estrictamente factible")
    x, t, etapas = x0.copy(), t0, []
    while True:
        x, k = centrar(f0, A, b, t, x)
        etapas.append(k)
        if m / t <= eps:
            return x, t, etapas
        t *= mu

def fase_uno(A, b, x0):
    """min s  s.a.  A x - s <= b; para en cuanto s < 0."""
    m, n = A.shape
    s0 = np.max(A @ x0 - b) + 1.0
    Ae = np.hstack([A, -np.ones((m, 1))])
    f0 = lambda z: (z[-1], np.r_[np.zeros(n), 1.0], np.zeros((n + 1, n + 1)))
    z, t, total = np.r_[x0, s0], 1.0, 0
    while z[-1] >= 0:
        z, k = centrar(f0, Ae, b, t, z, parar=lambda w: w[-1] < 0)
        total += k
        t *= 20
    return z[:n], total

def lp_aleatorio(m, n, semilla=0):
    rng = np.random.default_rng(semilla)
    A = rng.normal(size=(m, n))
    b = A @ rng.normal(size=n) + rng.uniform(0.5, 1.5, size=m)
    c = -A.T @ rng.uniform(0.1, 1.0, size=m)            # dual factible: el LP está acotado
    return A, b, c

m, n = 100, 50
A, b, c = lp_aleatorio(m, n)
lineal = lambda x: (c @ x, c, np.zeros((n, n)))

x0 = np.zeros(n)
print(f"x = 0 viola alguna restricción en {np.max(A @ x0 - b):.2f}")
xf, it1 = fase_uno(A, b, x0)
print(f"fase I: {it1} pasos de Newton, holgura mínima {np.min(b - A @ xf):.3f}")

x, t, etapas = metodo_barrera(lineal, A, b, xf, t0=1.0, mu=20.0, eps=1e-6)
print("pasos de Newton por centrado:", etapas, " total:", sum(etapas))

ref = linprog(c, A_ub=A, b_ub=b, bounds=(None, None), method="highs")
print(f"HiGHS: {ref.fun:.10f}   barrera: {c @ x:.10f}   diferencia: {c @ x - ref.fun:.1e}   m/t = {m / t:.1e}")

# en cada punto del camino central, lam_i = 1/(t s_i) es dual factible y g(lam) = -b^T lam
print("\n     t    subóptimo   gap c^T x - g(lam)   m/t     |A^T lam + c|   t*subóptimo")
for tt in [1.0, 10.0, 100.0, 1000.0, 1e4]:
    xx, _ = centrar(lineal, A, b, tt, xf, tol=1e-10, max_iter=200)
    lam = 1 / (tt * (b - A @ xx))
    sub = c @ xx - ref.fun
    print(f"{tt:6.0f}   {sub:.4e}   {c @ xx + b @ lam:.6e}     {m / tt:.0e}   {np.linalg.norm(A.T @ lam + c):.1e}       {tt * sub:6.2f}")

Check several things in the output. Phase I finds an interior point in about twenty Newton steps without solving to completion. Centerings take 6–12 steps, about 70 total for a 100×50100\times 50 LP. The solution matches HiGHS within m/tm/t. In the table, dual point λi=1/(tsi)\lambda_i = 1/(t s_i) is feasible up to at most 10−410^{-4} residual (from inexact centering, stopping at λ2/2≤10−10\lambda^2/2 \le 10^{-10}) and its gap equals m/tm/t to six digits. The final column confirms the central-path figure: tt times suboptimality remains around n=50n = 50, half of m=100m = 100.

The same code solves a QP: only f0 changes. For bounded least squares, min⁡12∥Fx−g∥2\min \tfrac12\norm{\mat{F}\vb{x} - \vb{g}}^2 with 0⪯x⪯1\vb{0} \preceq \vb{x} \preceq \vb{1}, SciPy provides an exact reference, lsq_linear.

[ ]The same method for a QPBrowser
import numpy as np
from scipy.optimize import lsq_linear

rng = np.random.default_rng(1)
F = rng.normal(size=(80, 30))
g = F @ rng.uniform(-0.5, 1.5, size=30) + 0.1 * rng.normal(size=80)
P, q = F.T @ F, -F.T @ g
cuadratica = lambda x: (0.5 * x @ P @ x + q @ x, P @ x + q, P)

Ac = np.vstack([np.eye(30), -np.eye(30)])                # x <= 1  y  -x <= 0
bc = np.r_[np.ones(30), np.zeros(30)]
xq, tq, etapas_q = metodo_barrera(cuadratica, Ac, bc, np.full(30, 0.5), mu=20.0, eps=1e-7)

ref = lsq_linear(F, g, bounds=(0, 1), tol=1e-12)
f = lambda x: 0.5 * np.sum((F @ x - g) ** 2)
print("pasos de Newton por centrado:", etapas_q)
print(f"barrera: {f(xq):.10f}   lsq_linear: {f(ref.x):.10f}   diferencia: {f(xq) - f(ref.x):.1e}   m/t = {60 / tq:.1e}")
print("cotas activas en la solución:", int(np.sum(ref.x < 1e-6)), "en 0 y", int(np.sum(ref.x > 1 - 1e-6)), "en 1")

Now self-concordance’s promise in two experiments. First rescale each variable by factors from 10−k10^{-k} to 10k10^{k}: centering is the same problem in different coordinates, the Hessian’s solution condition number explodes, and Newton does not notice. Gradient descent with the same backtracking does. Second, measure total Newton steps of the full barrier method as mm grows.

[ ]Newton ignores conditioningBrowser
import numpy as np

def descenso_gradiente(t, c, A, b, x, tol=1e-6, max_iter=400):
    F = lambda z: t * c @ z - np.sum(np.log(b - A @ z))
    for k in range(max_iter):
        s = b - A @ x
        g = t * c + A.T @ (1 / s)
        H = A.T @ ((1 / s**2)[:, None] * A)
        if g @ np.linalg.solve(H, g) / 2 <= tol:          # mismo criterio que Newton
            return x, k
        p = 1.0
        while np.any(b - A @ (x - p * g) <= 0):
            p *= 0.5
        while F(x - p * g) > F(x) - 0.01 * p * (g @ g):
            p *= 0.5
        x = x - p * g
    return x, max_iter

m, n = 60, 10
A, b, c = lp_aleatorio(m, n, semilla=3)
xf, _ = fase_uno(A, b, np.zeros(n))
print("escala    Newton   cond(hessiano en x*)   gradiente")
for k in [0, 1, 2, 3]:
    D = np.diag(10.0 ** np.linspace(-k, k, n))           # x = D x': mismas soluciones, otras coordenadas
    AD, cD, x0 = A @ D, D @ c, np.linalg.solve(D, xf)
    lineal_D = lambda z: (cD @ z, cD, np.zeros((n, n)))
    xs, it_newton = centrar(lineal_D, AD, b, 10.0, x0)
    s = b - AD @ xs
    cond = np.linalg.cond(AD.T @ ((1 / s**2)[:, None] * AD))
    it_gd = descenso_gradiente(10.0, cD, AD, b, x0)[1] if k <= 1 else "-"
    print(f"10^±{k}      {it_newton:3d}        {cond:9.1e}          {it_gd}")

print("\n  m    n   centrados   Newton total")
for m in [25, 50, 100, 200, 400]:
    n = m // 4
    A, b, c = lp_aleatorio(m, n, semilla=1)
    xf, _ = fase_uno(A, b, np.zeros(n))
    _, _, etapas = metodo_barrera(lambda z: (c @ z, c, np.zeros((n, n))), A, b, xf, mu=20.0, eps=1e-6)
    print(f"{m:4d} {n:4d}   {len(etapas):6d}      {sum(etapas):6d}")

Condition number rises from 10110^1 to 101210^{12} and Newton takes exactly the same steps (the same algorithm in different coordinates); gradient descent fails to converge in 400 iterations under 10±110^{\pm1} rescaling. Multiplying mm by 16 barely changes total Newton steps: one extra stage (starting m/tm/t higher) and a few iterations per stage.

Finally, primal-dual with Mehrotra predictor-corrector for a standard-form LP with data ensuring primal and dual strict feasibility. Start x=s=1\vb{x} = \vb{s} = \vb{1}, y=0\vb{y} = \vb{0} is infeasible, and phase I is unnecessary.

[ ]Primal-dual predictor-corrector for LPBrowser
import time
import numpy as np
from scipy.linalg import cho_factor, cho_solve
from scipy.optimize import linprog

def lp_estandar(m, n, semilla=0):
    rng = np.random.default_rng(semilla)
    A = rng.normal(size=(m, n))
    b = A @ rng.uniform(0.5, 1.5, size=n)                         # x > 0 factible
    c = A.T @ rng.normal(size=m) + rng.uniform(0.5, 1.5, size=n)  # s > 0 factible en el dual
    return A, b, c

def paso_frontera(v, dv):
    neg = dv < 0
    return min(1.0, np.min(-v[neg] / dv[neg])) if np.any(neg) else 1.0

def punto_interior(A, b, c, mehrotra=True, sigma=0.1, tol=1e-8, eta=0.99, max_iter=100):
    m, n = A.shape
    x, y, s = np.ones(n), np.zeros(m), np.ones(n)
    nb, nc = 1 + np.linalg.norm(b), 1 + np.linalg.norm(c)
    for k in range(max_iter):
        rp, rd, mu = A @ x - b, A.T @ y + s - c, x @ s / n
        if np.linalg.norm(rp) / nb < tol and np.linalg.norm(rd) / nc < tol and mu < tol:
            return x, y, s, k
        d = x / s
        fac = cho_factor(A @ (d[:, None] * A.T))                 # la única factorización de la iteración

        def direccion(rc):
            dy = cho_solve(fac, -rp - A @ (d * rd) - A @ (rc / s))
            ds = -rd - A.T @ dy
            return (rc - x * ds) / s, dy, ds

        if mehrotra:
            dxa, _, dsa = direccion(-x * s)                       # predictor: sigma = 0
            aa = min(paso_frontera(x, dxa), paso_frontera(s, dsa))
            sig = ((x + aa * dxa) @ (s + aa * dsa) / n / mu) ** 3
            dx, dy, ds = direccion(-x * s - dxa * dsa + sig * mu)  # corrector
        else:
            dx, dy, ds = direccion(-x * s + sigma * mu)
        a = min(1.0, eta * min(paso_frontera(x, dx), paso_frontera(s, ds)))
        x, y, s = x + a * dx, y + a * dy, s + a * ds
    return x, y, s, max_iter

A, b, c = lp_estandar(30, 60)
x, y, s, k = punto_interior(A, b, c)
ref = linprog(c, A_eq=A, b_eq=b, bounds=(0, None), method="highs")
print(f"{k} iteraciones   primal {c @ x:.8f}   dual {b @ y:.8f}   HiGHS {ref.fun:.8f}")

print("\n   n    m   Mehrotra   sigma=0.1   tiempo   error relativo")
for n in [25, 50, 100, 200, 400]:
    A, b, c = lp_estandar(n // 2, n, semilla=n)
    t0 = time.perf_counter()
    x, y, s, k = punto_interior(A, b, c)
    dt = time.perf_counter() - t0
    k01 = punto_interior(A, b, c, mehrotra=False, sigma=0.1)[3]
    ref = linprog(c, A_eq=A, b_eq=b, bounds=(0, None), method="highs")
    print(f"{n:4d} {n // 2:4d}   {k:6d}     {k01:6d}     {dt:.3f}s   {abs(c @ x - ref.fun) / abs(ref.fun):.1e}")

About thirty lines of method, and iteration count barely changes while nn grows 16-fold: the motivation’s “twenty-row table”. Cost per iteration, however, grows like forming and factoring ADA⊤\mat{A}\mat{D}\mat{A}\T, dense here: O(m2n+m3)\bigO(m^2 n + m^3). Mehrotra saves about one third of iterations versus fixed σ=0.1\sigma = 0.1, with one factorization per iteration in both cases.

The professional version

In Python, scipy.optimize.linprog calls HiGHS. method="highs" lets HiGHS choose; "highs-ds" forces dual simplex and "highs-ipm" interior point (with vertex crossover). Before trusting the result, inspect how it finished: status, message and tolerances.

[ ]linprog: simplex versus interior pointBrowser
import time
import numpy as np
from scipy.optimize import linprog

A, b, c = lp_aleatorio(400, 150, semilla=5)
for metodo in ["highs-ds", "highs-ipm"]:
    t0 = time.perf_counter()
    r = linprog(c, A_ub=A, b_ub=b, bounds=(None, None), method=metodo,
                options={"primal_feasibility_tolerance": 1e-9, "dual_feasibility_tolerance": 1e-9})
    dt = time.perf_counter() - t0
    viol = max(0.0, np.max(A @ r.x - b))
    lam = -r.ineqlin.marginals                          # multiplicadores >= 0 de A x <= b
    print(f"{metodo:10s} estado {r.status} ({r.message.split('(')[0].strip()})  iteraciones {r.nit}  {dt:.3f}s")
    print(f"           objetivo {r.fun:.10f}   violación primal {viol:.1e}   "
          f"residuo dual {np.linalg.norm(A.T @ lam + c):.1e}   gap {c @ r.x + b @ lam:.1e}")

Both calls give the same optimum, but verify rather than assume: primal violation, multiplier-reconstructed dual residual and gap are the three quantities an IPM drives to zero. CVXPY provides a higher-level interface and selectable solver; in current versions Clarabel is the default for many conic problems:

import cvxpy as cp

x = cp.Variable(n)
prob = cp.Problem(cp.Minimize(c @ x), [A @ x <= b])
prob.solve(solver=cp.CLARABEL, verbose=True)     # imprime una fila por iteración
print(prob.status, prob.value)
print(prob.solver_stats.num_iters, prob.solver_stats.solve_time)
lam = prob.constraints[0].dual_value             # multiplicadores de A x <= b

Clarabel’s log has one row per iteration with primal and dual cost, gap, primal and dual residuals, homogeneous-embedding ratio κ/τ\kappa/\tau, μ\mu and step length. You now know each column’s meaning.

Common mistakes

Exercises

NumericA one-dimensional central path
Consider LP min⁡x\min x subject to 0≤x≤10 \le x \le 1, with barrier −log⁡x−log⁡(1−x)-\log x - \log(1 - x). Calculate x⋆(t)x^\star(t) for t=10t = 10.
NumericHow many centerings?
A barrier method with m=100m = 100 constraints starts at t0=1t_0 = 1 and multiplies tt by μ=10\mu = 10 after each centering. How many centerings total, including the initial one at t0t_0, guarantee gap m/t≤10−6m/t \le 10^{-6}?
NumericThe bound in a conic problem
A problem has one semidefinite constraint X∈S+10\mat{X} \in \mathbb{S}^{10}_+, five second-order cone constraints and 20 linear inequalities. What suboptimality bound does a central-path point with t=104t = 10^4 guarantee?
NumericThe universal constant
In the Newton iteration bound for self-concordant functions, γ=αβ(1−2α)2/(20−8α)\gamma = \alpha\beta(1 - 2\alpha)^2/(20 - 8\alpha). With backtracking parameters α=0.1\alpha = 0.1 and β=0.8\beta = 0.8, what is 1/γ1/\gamma?
QuizWhat σ does
In the primal-dual method, what happens at extremes of centering parameter σ\sigma?
QuizThe path depends on the description
Add an exact copy of an LP constraint, a~1⊤x≤b1\tilde{\vb{a}}_1\T\vb{x} \le b_1. The feasible set is unchanged. What changes in the barrier method?
QuizInterior point and neural networks
Why are interior-point methods not used to train deep neural networks? Select all correct reasons.

More than one answer may be correct.

ProofThe m/t certificate
Prove: If x⋆(t)\vb{x}^\star(t) is the central-path point for t>0t > 0, then f0(x⋆(t))−p⋆≤m/tf_0(\vb{x}^\star(t)) - p^\star \le m/t.
0
By centrality, x⋆(t)\vb{x}^\star(t) is strictly feasible and t ∇f0(x⋆)+∑i1−fi(x⋆)∇fi(x⋆)+A⊤ν^=0t\,\grad f_0(\vb{x}^\star) + \sum_i \frac{1}{-f_i(\vb{x}^\star)}\grad f_i(\vb{x}^\star) + \mat{A}\T\hat{\vb{\nu}} = \vb{0} for some ν^\hat{\vb{\nu}}.

Step 1 of 4. Which dual point do you construct?

ProofA polyhedron's barrier is self-concordant
Prove: Function −log⁡x-\log x is self-concordant for x>0x > 0, the sum of two self-concordant functions is too, and therefore ϕ(x)=−∑ilog⁡(bi−a~i⊤x)\phi(\vb{x}) = -\sum_i\log(b_i - \tilde{\vb{a}}_i\T\vb{x}) is self-concordant on its domain.
0
Recall: convex ff is self-concordant if ∣f′′′∣≤2(f′′)3/2\abs{f'''} \le 2(f'')^{3/2} on its domain; on Rn\R^n, if every line restriction is.

Step 1 of 4. How do you check f(x)=−log⁡xf(x) = -\log x is self-concordant?

CodeNewton centering without leaving the domain
Implement newton_centering(t, c, A, b, x0) to minimize t c⊤x−∑ilog⁡(bi−a~i⊤x)t\,\vb{c}\T\vb{x} - \sum_i\log(b_i - \tilde{\vb{a}}_i\T\vb{x}) using damped Newton and return the minimizer. Requirements: raise ValueError if x0 is not strictly feasible; in backtracking, shrink the step until b - A @ (x + paso*dx) > 0 before evaluating objective and Armijo (tests replace np.log with a version raising an error on nonpositive arguments, so out-of-domain evaluation fails); stop when λ2/2≤\lambda^2/2 \le tol. Starter code is naive: it works until the full step crosses a constraint.
import numpy as np

def newton_centering(t, c, A, b, x0, tol=1e-9, alpha=0.01, beta=0.5, max_iter=100):
  """Minimiza t c^T x - sum(log(b - A x)) desde x0 estrictamente factible. Devuelve x."""
  A, b, c = np.asarray(A, dtype=float), np.asarray(b, dtype=float), np.asarray(c, dtype=float)
  x = np.asarray(x0, dtype=float).copy()
  f = lambda z: t * c @ z - np.sum(np.log(b - A @ z))
  for _ in range(max_iter):
      s = b - A @ x
      g = t * c + A.T @ (1 / s)
      H = A.T @ ((1 / s**2)[:, None] * A)
      dx = -np.linalg.solve(H, g)
      lam2 = -g @ dx
      if lam2 / 2 <= tol:
          break
      paso = 1.0
      # tu código: antes de Armijo, el paso debe dejar b - A(x + paso dx) > 0
      while f(x + paso * dx) > f(x) - alpha * paso * lam2:
          paso *= beta
      x = x + paso * dx
  return x
Shift+Enter to run

Summary

Key idea
An interior-point method replaces inequalities with a logarithmic barrier, uses Newton to solve smooth problems whose minimizers form the central path, and at each path point obtains a free dual point certifying an exact m/tm/t gap; barrier self-concordance makes total Newton steps depend not on data but only constraint count and accuracy.
  • Barrier ϕ=−∑ilog⁡(−fi)\phi = -\sum_i\log(-f_i) is convex, smooth and diverges at the boundary; minimizing tf0+ϕt f_0 + \phi better approximates the constrained problem as tt grows.
  • Central path x⋆(t)\vb{x}^\star(t) solves KKT with perturbed complementary slackness −λifi=1/t-\lambda_i f_i = 1/t. Its dual point λi=−1/(tfi)\lambda_i = -1/(t f_i) gives gap m/tm/t; in a nondegenerate LP actual suboptimality is ≈n/t\approx n/t.
  • The barrier method centers with damped Newton (backtracking respects the domain before Armijo), multiplies tt by μ\mu and stops when m/t≤εm/t \le \eps. It needs phase I or a strictly feasible start. In practice, μ\mu between 10 and 100 and a few dozen Newton steps total.
  • Self-concordance, ∣f′′′∣≤2(f′′)3/2\abs{f'''} \le 2(f'')^{3/2}, is affine invariant, preserved by sums and affine composition and gives a Newton iteration bound with universal constants. The barrier method then needs O(mlog⁡(m/(t0ε)))\bigO(\sqrt{m}\log(m/(t_0\eps))) Newton steps.
  • Primal-dual takes one Newton step per iteration on perturbed KKT, starts infeasibly (linear residuals fall by 1−α1 - \alpha), controls centering with σ\sigma and, with Mehrotra predictor-corrector, solves LPs in 10–50 iterations almost independently of size.
  • Generalized logarithms (−log⁡det⁡-\log\det, −log⁡(w2−∥u∥2)-\log(w^2 - \norm{\vb{u}}^2)) similarly solve SOCP and SDP with gap ∑iθi/t\sum_i\theta_i/t. Modern conic solvers (Clarabel, ECOS, MOSEK) add homogeneous embedding, sparse factorization and relative tolerances worth checking.