Lagrange Duality & KKT Conditions
Dual problems, strong duality and complementary slackness.
Every constrained problem casts a shadow: a concave maximization problem whose values bound it from below. When the two meet, the shadow certifies optimality, puts a price on every constraint and exposes structure the original problem hides, from the support vectors of an SVM to the active set of the lasso. This lesson proves when they meet, and puts the machinery to work on the problems of machine learning.
What you’ll learn
- Derive Lagrange duals, prove weak duality, and use the dual of a hard nonconvex problem as a computable bound.
- State Slater's theorem, prove strong duality with a separating hyperplane, and exhibit a convex problem with a positive duality gap.
- Prove that the KKT conditions are necessary under strong duality and sufficient for convex problems, and read complementary slackness in the SVM and lasso duals.
- Compute Fenchel conjugates and dualize regularized empirical risk minimization, the basis of dual coordinate ascent.
The dual problem and weak duality
Consider subject to for and , over a domain , with optimal value . Its Lagrangian and dual function are
where . The dual function is concave and may equal . Weak duality, (proved in Convexity & Duality), holds for every problem, and the duality gap is . Two facts make the dual useful even when the gap is positive: any dual-feasible point certifies a candidate , since , and the dual is a convex problem whatever the primal is.
Split items into two groups, , to minimize for a symmetric . With a graph's weighted adjacency matrix this is max-cut, so the problem is NP-hard. Write the constraints as and form the Lagrangian:
A quadratic form is bounded below only if its matrix is positive semidefinite, and then its infimum is :
Maximizing subject to is a semidefinite program, solvable to any accuracy in polynomial time, and its value bounds the NP-hard optimum from below. Even the crude choice is feasible:
The dual of this dual replaces by a positive semidefinite matrix with unit diagonal. Goemans & Williamson (1995) rounded its solution with a random hyperplane and obtained cuts whose expected weight is at least times the maximum cut, the first approximation algorithm built on semidefinite programming.
Take and , so the cost is . What lower bound does give?
Show the answer
-2
The eigenvalues of are , so the bound is . The true optimum is also (give the two items opposite signs), so here the bound is tight. For larger it usually is not: this problem is nonconvex, and its duality gap can be positive.
Strong duality: Slater's theorem
Collect every achievable pair of constraint values and objective value, with slack allowed upward. The set is convex because the are, and is the lowest height at which it meets the vertical axis:
The convex set does not meet , so a hyperplane separates them: some and satisfy the inequalities below. Since is closed upward in every coordinate, and , and letting gives .
If , divide by and apply the first inequality to . The multipliers then satisfy , and weak duality turns this into equality:
Slater's point rules out a vertical hyperplane. If , then is nonzero and on all of , yet every :
Multipliers are prices. The optimal value of the perturbed problem, , is convex in . Under strong duality, for every feasible for the perturbed problem, , and taking the infimum,
with wherever is differentiable. A large means loosening constraint would pay a lot; means it does not matter at the margin.
For subject to (so , , ), tighten the constraint to , which is . What does the bound predict for the new optimal value?
Show the answer
1.2
. The true value is , above the prediction as the global inequality guarantees; the difference is second order in .
The KKT conditions, support vectors and the lasso
Necessity. Chain the definitions. The two ends agree, so every inequality in between is an equality:
Equality on the left says minimizes , so its gradient vanishes there. Equality on the right says , a sum of nonpositive terms, so each term is zero:
Sufficiency. With and affine , the function is convex, so stationarity makes its global minimizer. Complementary slackness and feasibility then make a dual value equal a primal value, which certifies both as optimal:
With labels and slack variables , the soft-margin SVM (Cortes & Vapnik, 1995) minimizes subject to and : a convex quadratic program with affine constraints, so strong duality holds. Attach to the margin constraints and to :
Stationarity in , and each :
Substituting back eliminates , and . The data enter only through inner products, which a kernel can replace (The SVM Dual & Support Vectors solves this problem with SMO):
Complementary slackness, and with , sorts the training points into three kinds:
The lasso dual. For , introduce and dualize. Minimizing over is a quadratic, and minimizing over is bounded only when every column satisfies . The dual is a projection,
is the Euclidean projection of onto a polytope, and it equals the optimal residual . Stationarity reads : every active feature has residual correlation exactly , and forces .
Two practical tools follow. Any gives a dual-feasible point by rescaling its residual to , so the gap is a computable stopping certificate. And because the dual objective is -strongly concave, : a ball known to contain . Whenever , feature is provably zero at the solution and can be dropped before the problem is solved, an idea called safe screening.
Fenchel conjugates and the dual of regularized ERM
| Where it appears | ||
|---|---|---|
| ridge; the only self-conjugate function | ||
| , | Gaussian log-likelihoods, preconditioning | |
| a norm | if , else | the box in the lasso dual |
| indicator of a set | (support function) | constraints |
| on the probability simplex, else | softmax and negative entropy | |
| on | logistic loss and binary entropy | |
| on , else | hinge loss and the SVM's box constraint |
Take with convex losses , for example . Introduce with multipliers :
Minimizing over each produces a conjugate, by definition, and minimizing over is a ridge-like quadratic:
The dual has one variable per example, and the primal solution is a weighted sum of the inputs: the representer form that makes kernels possible. For the hinge loss, with ; writing recovers the SVM dual without a bias term, the box playing the role of with .
Stochastic dual coordinate ascent (Shalev-Shwartz & Zhang, 2013) maximizes one at a time, each step touching a single example while is updated incrementally. For smooth losses it converges linearly, and at every step the duality gap certifies the accuracy, something primal SGD cannot provide:
What is the Fenchel conjugate of ?
- if , and otherwise
- if , and otherwise
Show the answer
B. if , and otherwise
separates over coordinates. If every , each term is at most , attained at . If some , push to infinity with the sign of and the supremum is . This indicator of the ball is exactly the constraint in the lasso dual.
Key takeaways
- The dual function is concave for every problem and bounds from below; for hard nonconvex problems it yields computable relaxations, such as the semidefinite bound behind Goemans–Williamson.
- Slater's theorem: a convex problem with a strictly feasible point has zero duality gap and an attained dual optimum; the proof separates the achievable set from the points below . Without the condition, even convex problems can have a gap.
- Under strong duality the KKT conditions are necessary; for convex problems they are also sufficient. Complementary slackness explains SVM support vectors ( only on or inside the margin) and the lasso's active set (residual correlation exactly ), and multipliers are the sensitivities .
- Fenchel conjugates dualize regularized ERM into a problem with one variable per example and ; duality gaps give stopping certificates and safe screening.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
A convex problem has feasible points, but none of them satisfies the nonaffine inequality constraints strictly. What can you conclude about strong duality?
- It holds anyway, because the problem is convex
- The dual problem must be unbounded
- A positive gap is possible, as in subject to , but the gap may also be zero: Slater's condition is sufficient, not necessary
- The KKT conditions can have no solution, so the primal has no minimizer
Show the answer
C. A positive gap is possible, as in subject to , but the gap may also be zero: Slater's condition is sufficient, not necessary
Slater's condition is one sufficient constraint qualification. Without it, subject to has and ; other problems without strictly feasible points still have zero gap.
In a soft-margin SVM solution, a training point has dual variable . Where does it lie?
- Strictly outside the margin, correctly classified
- On the wrong side of the decision boundary
- Inside the margin, with positive slack
- Exactly on the margin:
Show the answer
D. Exactly on the margin:
makes the multiplier of positive, , so ; and makes the margin constraint tight, . These margin support vectors are also how is recovered: any of them gives .
At the lasso solution, the dual point (the optimal residual ) satisfies for feature . What follows?
- Feature has the largest coefficient in magnitude
- Nothing, until the primal is solved exactly
Show the answer
A.
Stationarity says . If the subdifferential is , which would force . Safe screening applies the same test to a ball around an approximate dual point.
A point satisfies the KKT conditions of a nonconvex problem whose constraints satisfy a constraint qualification. What can you conclude?
- It is the global minimizer
- It is at least a local minimizer
- It is a candidate only: it may be a local minimum, a saddle point or a local maximum
- Strong duality holds at that point
Show the answer
C. It is a candidate only: it may be a local minimum, a saddle point or a local maximum
Under a constraint qualification, the KKT conditions are necessary for local optimality, so every local minimizer satisfies them. Sufficiency used the convexity of , which is lost here; second-order conditions are needed to tell the cases apart.
Further reading
- S. Boyd & L. Vandenberghe, Convex Optimization (Cambridge University Press, 2004), chapter 5.
- R. T. Rockafellar, Convex Analysis (Princeton University Press, 1970).
- M. X. Goemans & D. P. Williamson, "Improved approximation algorithms for maximum cut and satisfiability problems using semidefinite programming," Journal of the ACM 42(6), 1115–1145 (1995).
- S. Shalev-Shwartz & T. Zhang, "Stochastic dual coordinate ascent methods for regularized loss minimization," Journal of Machine Learning Research 14, 567–599 (2013).