Lagrangian duality is the principle that every constrained optimization problem, called the primal problem, has an associated dual problem built from its Lagrangian, and that the optimal value of the dual always provides a lower bound on the primal optimum for minimization. In optimization for artificial intelligence, Lagrange duality underpins support vector machines, constrained reinforcement learning, fairness-constrained training and many distributed solvers.
The idea converts hard constraints into weighted penalties. Each constraint receives a Lagrange multiplier, and the dual problem searches for the multipliers that make the penalized problem as informative as possible. When the gap between the two optimal values closes, solving the dual is equivalent to solving the original task.
How the Lagrangian dual problem is constructed
The dual problem is constructed in three steps: form the Lagrangian, minimize it over the primal variables, then maximize the result over the multipliers. For a problem that minimizes f(x) subject to inequality constraints g_i(x) ≤ 0 and equality constraints h_j(x) = 0, the Lagrangian is L(x, λ, ν) = f(x) + Σ λ_i g_i(x) + Σ ν_j h_j(x), with λ_i ≥ 0 for every inequality.
Minimizing the Lagrangian over x for fixed multipliers yields the dual function g(λ, ν). This function is always concave, even when the primal problem is non-convex, because it is a pointwise infimum of affine functions in the multipliers. The dual problem maximizes this concave function, so it is a convex optimization problem regardless of the structure of the original task.
The following table summarizes the components of the construction and their roles.
| Component | Definition | Role |
|---|---|---|
| Primal problem | Minimize f(x) under constraints | The task that must actually be solved |
| Lagrangian | Objective plus weighted constraints | Relaxes constraints into penalties |
| Dual function | Infimum of the Lagrangian over x | Produces a lower bound for each multiplier choice |
| Dual problem | Maximize the dual function, λ ≥ 0 | Finds the tightest available bound |
| Duality gap | Primal optimum minus dual optimum | Measures how much the bound loses |
Weak duality, strong duality and the duality gap
Weak duality states that the dual optimum d* never exceeds the primal optimum p*, so d* ≤ p* holds for every problem. The proof is short: for any feasible x and any λ ≥ 0, the penalty terms are non-positive, so the Lagrangian cannot exceed f(x), and its infimum cannot either.
Strong duality means that the gap is exactly zero, d* = p*. It does not hold in general, but it does hold for convex problems that satisfy a constraint qualification. The best-known one is Slater’s condition: the problem is convex and some point strictly satisfies every non-affine inequality constraint. Linear programs enjoy strong duality whenever either problem has a finite optimum.
The table below contrasts the three situations a practitioner encounters.
| Problem class | Typical gap | Practical consequence |
|---|---|---|
| Linear programming | Zero when an optimum exists | Dual solves the primal exactly |
| Convex with Slater point | Zero | Dual solution recovers primal solution |
| Convex without qualification | Possibly positive | Dual bound may be loose |
| Non-convex problems | Often positive | Dual gives a relaxation bound only |
| Integer programs | Usually positive | Used for bounds in branch and bound |
When strong duality holds and both optima are attained, the primal and dual solutions satisfy the Karush-Kuhn-Tucker conditions. The most informative of these is complementary slackness: λ_i g_i(x) = 0, so a multiplier can be positive only when its constraint is active at the optimum.
Why multipliers act as shadow prices
An optimal Lagrange multiplier measures the sensitivity of the optimal value to its constraint. If constraint i is relaxed from g_i(x) ≤ 0 to g_i(x) ≤ u, the optimal value changes at a rate of roughly minus λ_i per unit of u under standard regularity. Economists call this a shadow price: the marginal value of one more unit of a scarce resource.
This interpretation is useful in machine learning. In a fairness-constrained classifier, a large multiplier on a demographic parity constraint signals that the constraint is costing substantial accuracy. In a constrained Markov decision process, the multiplier on a safety budget tells the engineer how much reward is sacrificed to keep expected violations under the limit.
Where Lagrange duality appears in machine learning
Duality changes which variables an algorithm works with, and that change is often the source of a computational advantage. The dual of the soft-margin support vector machine depends on the data only through inner products, which is exactly what allows the kernel trick. The dual also has one variable per training example, which favors problems with many features and moderate sample counts.
The next table lists common applications and what duality contributes to each.
| Application | What the dual provides | Typical method |
|---|---|---|
| Support vector machines | Kernelized quadratic program | Sequential minimal optimization |
| Constrained reinforcement learning | Adaptive penalty on cost budgets | Primal-dual policy gradient |
| Fair and robust training | Learned constraint weights | Gradient descent-ascent |
| Distributed optimization | Separable subproblems per node | Dual decomposition, ADMM |
| Optimal transport | Potential functions instead of a plan | Sinkhorn iterations on the entropic dual |
| Combinatorial relaxation | Bounds for pruning a search tree | Subgradient method on the dual |
Dual decomposition deserves special mention. When the objective is a sum of terms coupled only through linear constraints, the Lagrangian separates into independent pieces, so each machine or agent can solve its own piece while a coordinator updates the shared multipliers. ADMM refines this scheme with an augmented penalty that improves convergence.
Limitations and common mistakes
Duality is powerful but easy to misapply. The most frequent error is to assume strong duality without checking convexity or a constraint qualification, which can produce a dual solution that does not correspond to any feasible primal point.
| Pitfall | Cause | Remedy |
|---|---|---|
| Unrecoverable primal solution | Gap is positive or minimizer is not unique | Add a proximal or augmented term |
| Oscillating multipliers | Non-smooth dual function | Use averaging or diminishing step sizes |
| Unbounded dual function | Lagrangian has no finite minimum in x | Add bounds or regularization to x |
| Sign errors on multipliers | Inequalities written in the wrong direction | Standardize constraints as g(x) ≤ 0 |
Another misconception is that a zero duality gap guarantees a fast algorithm. The dual function is frequently non-differentiable, so plain subgradient ascent converges slowly, at a rate of about O(1/√k) after k iterations. Smoothing, augmented Lagrangian methods and interior-point approaches are usually preferred when precision matters.
In plain words
Many problems ask for the best answer while obeying rules. Lagrangian duality turns each rule into a price for breaking it. You then look for the best answer when breaking rules costs money.
Next, you adjust the prices. A rule that is broken too often gets a higher price. A rule that is never close to breaking gets a price of zero. The best prices give a guaranteed floor under the true answer. For well-behaved problems, that floor is exactly the true answer.
So duality gives two views of the same problem. One view searches for the answer. The other view searches for the fair prices of the rules.
A real-world example
A logistics team trains a delivery-routing policy with reinforcement learning. The goal is to maximize on-time deliveries, but the expected number of late-night driving hours must stay below 40 hours per week across the fleet. Writing this as a constrained Markov decision process, the team introduces one Lagrange multiplier for the driving-hours budget.
Training alternates two updates. The policy improves its reward minus the multiplier times the excess driving hours, and the multiplier rises whenever the measured hours exceed 40 and falls when they stay under. After several thousand episodes, the multiplier settles near a stable value and the policy meets the 40-hour budget while losing only a few percent of on-time deliveries.
The settled multiplier also serves the planning managers. Its value states how many on-time deliveries each additional permitted hour would buy, which gives them a quantitative basis for negotiating the budget with drivers.