1 · Motivation — a smoother way through constraints
Most real decisions are constrained. You want the cheapest, lightest, fastest, or most stable design, subject to limits on mass, stress, energy, actuator force, or timing. Interior-point methods (IPMs) are the dominant family of algorithms for solving such problems, and they take a deliberately indirect route: instead of walking along the constraint boundary, they tunnel through the interior of the feasible region and steer a parameter to zero.
The two solvers this page teaches share that single idea but sit at opposite ends of the spectrum:
Before IPM, the standard tool for a QP or NLP was an active-set method: guess which constraints are tight, solve an equality-constrained subproblem, then shuffle one constraint in or out. That combinatorial guess-and-flip is efficient in warm-started control loops but can explode in the worst case, and it is brittle on large problems. IPM replaces the combinatorics with a smooth homotopy: a single Newton solve per iteration on a system whose only job is to follow a curve.
2 · The problem each solver is built to solve
Both solvers reduce their target problem to the same standard shape, so we can teach one algorithm and then specialize. HPIPM works on a convex quadratic program:
with \(y\in\mathbb{R}^{n_y}\) the decision variables, \(H\succeq 0\) the Hessian, \(g\) the linear cost, \(Ay=b\) the equalities, and \(Cy\ge d\) the inequalities. IPOPT instead handles the general nonlinear program, which it casts into the form
where \(x\in\mathbb{R}^{n}\), \(f:\mathbb{R}^{n}\to\mathbb{R}\) is the (possibly nonconvex) objective, and \(c:\mathbb{R}^{n}\to\mathbb{R}^{m}\) collects the equalities. Any general inequality \(g(x)\ge 0\) is converted to a bound by introducing a slack: \(g(x)-s=0,\ s\ge 0\). So in both cases the "hard" constraints are of the simple nonnegativity kind — and that is the only part the barrier must handle.
3 · The barrier idea and the central path
The obstacle is the hard constraint \(x_i\ge 0\). The barrier trick replaces it with a smooth penalty that blows up as \(x_i\downarrow 0\), so that a minimizer of the penalized problem is automatically kept strictly positive. The workhorse penalty is the logarithmic barrier:
As \(x_i\to 0^{+}\), \(-\ln(x_i)\to +\infty\), erecting an infinitely tall "wall" at the boundary; deep in the interior the penalty is small and \(-(\text{small})\cdot\mu\) barely perturbs \(f\). The scalar \(\mu>0\) is the barrier parameter: it weighs the wall's influence against the real objective.
For each fixed \(\mu\), the barrier problem \(\min_x \varphi_{\mu}(x)\ \text{s.t.}\ c(x)=0\) has a (generically unique) minimizer. As \(\mu\) varies, these minimizers trace a curve — the central path — that starts deep inside the feasible region and ends at the true solution of the original problem in the limit \(\mu\to 0\):
4 · Primal–dual form — turn the path into an equation system
We could just minimize \(\varphi_{\mu}\) with a barrier-only method. But the state of the art — and what both HPIPM and IPOPT actually implement — is the primal–dual formulation, which is cleaner, faster, and more robust. The idea: write the first-order optimality conditions of the barrier problem as a square system of equations and drive it with Newton's method.
Attach a multiplier \(\lambda\in\mathbb{R}^{m}\) to \(c(x)=0\). The stationarity of the barrier Lagrangian gives, together with feasibility, the barrier KKT conditions:
Here \(z\in\mathbb{R}^{n}\) is the multiplier for the bound \(x\ge 0\), \(X=\operatorname{diag}(x)\), \(Z=\operatorname{diag}(z)\), and \(e=(1,\dots,1)\). The third line, written componentwise, is \(x_i z_i = \mu\) for every \(i\). This is the single most important equation in the whole subject.
HPIPM arrives at exactly the same system from a different door — it writes the KKT conditions of the QP directly and relaxes the complementarity \(t_i\lambda_i=0\) to \(t_i\lambda_i=\tau\) (their notation for the barrier parameter). The two viewpoints are identical; they differ only in emphasis: barrier theory (IPOPT) vs. Newton-on-KKT (HPIPM).
5 · The Newton step — one linear solve per iteration
We have a system of equations \(F_\mu(w)=0\) in the stacked variable \(w=(x,\lambda,z)\). Newton's method linearizes it at the current iterate \(w_k\) and solves for a direction. For IPOPT's barrier-KKT system this gives the primal–dual (KKT) linear system:
Here \(W_k = \nabla^2_{xx}\bigl(f(x_k)+\lambda_k^{T}c(x_k)\bigr)\) is the Hessian of the Lagrangian, \(A_k = \nabla c(x_k)\) is the constraint Jacobian, and \(\Sigma_k\) is the diagonal "barrier curvature." The \(d_z\) direction is then recovered from the linearized complementarity equation. The matrix is symmetric but indefinite — a KKT matrix — which is why both solvers lean on specialized factorizations.
HPIPM's generic QP produces a directly comparable system. Writing \(t=Cy-d\ge 0\) for the inequality slacks and \(\lambda\ge 0\) for their multipliers, the relaxed Newton system is (their delta form):
Notice the shared anatomy: a Hessian (or \(H\)) in the \((1,1)\) block, constraint matrices in the off-diagonal blocks, and a diagonal complementarity block \(T_k,\Lambda_k\) (or \(\Sigma_k\)) in the corner. The diagonal complementarity block is the IPM's signature.
The \((1,1)\) block \(H + C^{T}T_k^{-1}\Lambda_k C\) is the QP's answer to IPOPT's \(W_k+\Sigma_k\): the objective Hessian plus a barrier term that grows as any inequality slack \(t_i\to 0\). This "blown-up Hessian" is what keeps the step pointed into the interior.
6 · Mehrotra's predictor–corrector — the fast, standard variant
A naive IPM recomputes \(\mu\), solves the Newton system once, and steps. Mehrotra's insight — used by both HPIPM (as its default "fast" variant) and IPOPT (optional, and the model for its correction machinery) — is that you can get a much better direction with one extra right-hand-side solve, reusing the same factorization.
- Predictor (affine-scaling step). Solve the Newton system with \(\mu=0\), i.e. target exact complementarity. This pure step \(\Delta_{\mathrm{aff}}\) aggressively tries to reach the solution.
- Step to the boundary. Find the largest \(\alpha_{\mathrm{aff}}\) that keeps \(x,z\) positive. This reveals how much progress toward \(xz=0\) is actually possible.
- Set the centering parameter. Compare the achievable duality gap \(\mu_{\mathrm{aff}}=\frac{(x+\alpha\Delta x)^{T}(z+\alpha\Delta z)}{n}\) with the current \(\mu\), and set \(\sigma = \left(\mu_{\mathrm{aff}}/\mu\right)^{3}\). If the pure step made big progress, \(\sigma\) is small (aggressive); if it made little, \(\sigma\approx 1\) (center instead).
- Corrector. Solve once more with the target \(\sigma\mu e\) and a second-order term \(-\Delta X_{\mathrm{aff}}\,\Delta z_{\mathrm{aff}}\, e\) on the complementarity right-hand side. This term compensates for the curvature of the hyperbola \(xz=\mu\) that the linearization dropped.
7 · Staying inside — fraction-to-boundary and line search
Newton's direction is only a direction; taking the full step can drive \(x\) or \(z\) negative, which kills the log barrier (log of a negative number is undefined). Both solvers therefore clip the step and then decide how much of it to accept. The clipping is the fraction-to-boundary rule: keep a fixed fraction \((1-\tau)\) of the distance to the boundary, with
HPIPM applies exactly this rule to its slacks \(t\) and multipliers \(\lambda\) (keeping both strictly positive), then runs a line search on a merit function. IPOPT is more elaborate, because it must handle nonconvex NLPs where a pure merit function can fail.
IPOPT's filter line search
The core difficulty: when the problem is nonconvex, reducing the objective and reducing the constraint violation can conflict. IPOPT treats the two as a bi-objective problem — \((\theta,\varphi) = (\|c(x)\|_1,\ \varphi_{\mu}(x))\) — and maintains a filter: a set of pairs that are "forbidden" because an earlier iterate already beat them on both counts. A trial point is accepted if it improves either the constraint violation or the objective (sufficiently), while not being dominated by anything in the filter.
If the line search shrinks the step below a threshold without finding an acceptable point, IPOPT enters a feasibility-restoration phase: it temporarily abandons the objective and minimizes \(\theta(x)\) alone to claw its way back into a region where progress is possible, then resumes. It also applies second-order corrections — extra steps that reduce constraint violation using the constraint curvature — to rescue a good primal step that was rejected only because it overshot a nonlinear constraint.
8 · Shrinking the barrier — the \(\mu\) schedule
The last ingredient is when and how fast to reduce \(\mu\). IPOPT's update rule (with constants \(\kappa_\mu\in(0,1)\), \(\theta_\mu\in(1,2)\); defaults \(0.2\) and \(1.5\)) is:
The inner \(\min\) gives superlinear decrease of \(\mu\) once the barrier subproblem is solved accurately; the outer \(\max\) floors \(\mu\) at a small multiple of the tolerance so the algorithm never chases a barrier value far smaller than the requested accuracy (which would only invite numerical trouble at the very end). A barrier subproblem is considered "solved" when its own KKT error is below \(\kappa\,\mu_j\), at which point \(\mu\) drops and the filter is reset.
9 · HPIPM — exploiting QP structure for real-time speed
HPIPM is not "IPM, but faster hardware." It is a family of IPMs whose distinguishing feature is structure exploitation: it knows the QP is a chain (optimal control) or a tree, and it uses that knowledge to factorize the KKT matrix in linear time in the horizon instead of cubically.
The optimal-control QP and its banded KKT
An OCP-structured QP has dynamics \(x_{n+1}=A_n x_n+B_n u_n+b_n\) coupling consecutive stages \(n=0,\dots,N\). When we stack all stage variables and write the KKT system, the equality (dynamics) blocks form a banded, arrow-shaped matrix — consecutive stages only talk to their neighbors:
The Riccati recursion is the same machinery as the discrete-time LQR/Riccati equation: it eliminates stage variables one at a time, propagating a cost-to-go \(P_n\). HPIPM offers a classical version (needs the reduced Hessian positive definite, allows an indefinite full-space Hessian) and a square-root version (Cholesky-based, fewer flops, needs the full-space Hessian positive definite). For constant state/input dimensions the cost is \(O\bigl(N(n_x+n_u)^3\bigr)\) — linear in the horizon.
Two more HPIPM features worth knowing
Delta vs. absolute formulation. The "delta" system solves for the step; the "absolute" system solves for the next iterate directly, avoiding the residual matrix–vector products and making each solve \(O(n)\) cheaper in the vector part — a real win on small problems. The trade-off is cancellation error near the solution, so HPIPM picks per problem. It also offers a few iterative refinement steps to clean up the Newton direction when the KKT system is ill-conditioned (late iterations). And its slack variables carry diagonal Hessians, so soft constraints (L1/L2 penalties) are added essentially for free.
Condensing. HPIPM can also "condense" an OCP QP into a dense QP (eliminating the states) or partially condense it to a shorter horizon, then solve with the dense IPM and expand back. This lets an application choose the speed/robustness point on the condense-vs-structure spectrum.
10 · IPOPT — robustness machinery for general NLPs
IPOPT must survive problems that are nonconvex, poorly scaled, and potentially infeasible — a much harsher world than HPIPM's convex QPs. Four mechanisms do the heavy lifting.
Inertia correction
The reduced KKT matrix must factor as \(L D L^{T}\) with a specific inertia — for a system with \(n\) primal variables and \(m\) equality multipliers, the correct inertia is \(n\) positive and \(m\) negative eigenvalues — or else the Newton direction is not a descent direction. When the actual Hessian \(W_k\) is nonconvex or the iterate is far from a solution, the matrix can have the wrong inertia. IPOPT corrects it by shifting the diagonal:
increasing \(\delta_w,\delta_c\) until the factorization reports the right inertia. This guarantees the direction is a legitimate descent step even when the local curvature is "wrong."
Hessian choice
If exact second derivatives are supplied (via automatic differentiation), IPOPT uses them — this is what gives superlinear local convergence. Otherwise it falls back to a BFGS quasi-Newton approximation of the Lagrangian Hessian, which is cheaper per iteration but only linearly convergent.
Scaling and the dual step
IPOPT scales the variables, objective, and constraints (NLP scaling) so the error estimate is well-balanced, and it may take a different step length for the bound multipliers \(z\) than for the primal variables \(x\) — keeping the dual positive without over-restricting the primal.
11 · Side by side
| HPIPM | IPOPT | |
|---|---|---|
| Problem class | Convex QP (dense / OCP / tree) | General NLP (nonconvex) |
| Derivation viewpoint | Newton on relaxed KKT | Barrier method + KKT |
| Core step | Riccati / Cholesky on reduced KKT | \(LDL^{T}\) + inertia correction on reduced KKT |
| Complementarity relax | \(t_i\lambda_i=\tau\) | \(x_i z_i=\mu\) |
| Step control | Fraction-to-boundary + merit line search | Fraction-to-boundary + filter + SOC + restoration |
| Hessian | Exact \(H\) (problem data) | Exact or BFGS |
| Specialty | Structure: \(O(N)\) Riccati, condensing, BLASFEO | Robustness: inertia correction, scaling, restoration |
| Typical home | Embedded MPC (acados), real-time | Offline large-scale NLP (AMPL, CasADi, Pyomo…) |
12 · A worked example, end to end
Let's solve the tiny QP
The unconstrained optimum is \((2,1)\), but it violates the constraint \((2+1>1)\), so the true answer lies on the line \(x_1+x_2=1\). Introduce slack \(s=1-x_1-x_2\ge 0\) and multiplier \(\lambda\ge 0\). The barrier-KKT conditions (with barrier parameter \(\mu\)) are:
Substituting \(x_1=2-\lambda,\ x_2=1-\lambda\) into the slack gives \(s=1-(3-2\lambda)=2\lambda-2\). Complementarity then reads \(\lambda(2\lambda-2)=\mu\), i.e. \(\lambda = \tfrac{1+\sqrt{1+2\mu}}{2}\). The central path is therefore
As \(\mu\to 0\), \(\lambda\to 1\), so \(x\to(1,0)\), \(s\to 0\) — the constraint is tight, exactly the projection of \((2,1)\) onto the line. The reader can confirm the KKT sign conditions hold. The demo below sweeps \(\mu\) and shows the barrier landscape morphing and the central path marching to that boundary point.
13 · Complexity, theory, and the bigger picture
Why does IPM scale so well? The answer is captured by the theory of self-concordant barriers (Nesterov–Nemirovskii). A barrier function whose third derivative is bounded by its second derivative to the \(3/2\) power — the log barrier is the canonical example — guarantees that Newton's method converges in a number of iterations independent of the problem's conditioning, as long as the step stays within a fixed fraction of the boundary.
For a linear program in standard form the log barrier has \(\nu=n\) (the number of inequalities), so a path-following IPM needs \(O(\sqrt{n}\log(1/\epsilon))\) iterations — polynomial time, in sharp contrast to the simplex method's exponential worst case. This theoretical guarantee is why IPMs became the default for large LPs and QPs, and why they generalize to conic optimization (semidefinite programs, second-order cones) with the log-determinant and analogous barriers.
14 · The whole picture
HPIPM runs steps 3–5 with a Riccati-recursion linear algebra tuned to OCP QPs; IPOPT runs the same loop with a filter line search, inertia correction, and restoration for general NLPs. Once you see the shared core — barrier + relaxed complementarity + Newton — both solvers become variations on a single, elegant theme.