Simple Algorithm
Machine Learning · Convergence · 28 min

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 min⁡f0(x)\min f_0(\mathbf x) subject to fi(x)≤0f_i(\mathbf x)\le0 for i=1,…,mi=1,\dots,m and Ax=bA\mathbf x=\mathbf b, over a domain D\mathcal D, with optimal value p⋆p^\star. Its Lagrangian and dual function are

L(x,λ,ν)=f0(x)+λ⊤f(x)+ν⊤(Ax−b),q(λ,ν)=inf⁡x∈DL(x,λ,ν),\mathcal L(\mathbf x,\boldsymbol\lambda,\boldsymbol\nu)=f_0(\mathbf x)+\boldsymbol\lambda^\top\mathbf f(\mathbf x)+\boldsymbol\nu^\top(A\mathbf x-\mathbf b),\qquad q(\boldsymbol\lambda,\boldsymbol\nu)=\inf_{\mathbf x\in\mathcal D}\mathcal L(\mathbf x,\boldsymbol\lambda,\boldsymbol\nu),

where f=(f1,…,fm)\mathbf f=(f_1,\dots,f_m). The dual function is concave and may equal −∞-\infty. Weak duality, d⋆=sup⁡λ≥0,νq≤p⋆d^\star=\sup_{\boldsymbol\lambda\ge\mathbf 0,\boldsymbol\nu}q\le p^\star (proved in Convexity & Duality), holds for every problem, and the duality gap is p⋆−d⋆≥0p^\star-d^\star\ge0. Two facts make the dual useful even when the gap is positive: any dual-feasible point certifies a candidate x~\tilde{\mathbf x}, since f0(x~)−p⋆≤f0(x~)−q(λ,ν)f_0(\tilde{\mathbf x})-p^\star\le f_0(\tilde{\mathbf x})-q(\boldsymbol\lambda,\boldsymbol\nu), and the dual is a convex problem whatever the primal is.

DerivationA semidefinite bound for an NP-hard problem
  1. L(x,ν)=x⊤Wx+∑i=1nνi(xi2−1)=x⊤(W+diag⁡(ν))x−1⊤ν\mathcal L(\mathbf x,\boldsymbol\nu)=\mathbf x^\top W\mathbf x+\sum_{i=1}^n\nu_i(x_i^2-1)=\mathbf x^\top\big(W+\diag(\boldsymbol\nu)\big)\mathbf x-\mathbf 1^\top\boldsymbol\nu

    Split nn items into two groups, xi∈{−1,+1}x_i\in\{-1,+1\}, to minimize x⊤Wx\mathbf x^\top W\mathbf x for a symmetric WW. With WW a graph's weighted adjacency matrix this is max-cut, so the problem is NP-hard. Write the constraints as xi2=1x_i^2=1 and form the Lagrangian:

  2. q(ν)={−1⊤ν,W+diag⁡(ν)⪰0−∞,otherwiseq(\boldsymbol\nu)=\begin{cases}-\mathbf 1^\top\boldsymbol\nu, & W+\diag(\boldsymbol\nu)\succeq0\\ -\infty, & \text{otherwise}\end{cases}

    A quadratic form is bounded below only if its matrix is positive semidefinite, and then its infimum is 00:

  3. p⋆ ≥ d⋆ ≥ n λmin⁡(W)p^\star\ \ge\ d^\star\ \ge\ n\,\lambda_{\min}(W)

    Maximizing −1⊤ν-\mathbf 1^\top\boldsymbol\nu subject to W+diag⁡(ν)⪰0W+\diag(\boldsymbol\nu)\succeq0 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 ν=−λmin⁡(W)1\boldsymbol\nu=-\lambda_{\min}(W)\mathbf 1 is feasible:

  4. min⁡Z Tr⁡(WZ)subject toZ⪰0,  Zii=1  (i=1,…,n)\min_{Z}\ \Tr(WZ)\quad\text{subject to}\quad Z\succeq0,\ \ Z_{ii}=1\ \ (i=1,\dots,n)

    The dual of this dual replaces xx⊤\mathbf x\mathbf x^\top by a positive semidefinite matrix ZZ with unit diagonal. Goemans & Williamson (1995) rounded its solution with a random hyperplane and obtained cuts whose expected weight is at least 0.8780.878 times the maximum cut, the first approximation algorithm built on semidefinite programming.

Predict before you look

Take n=2n=2 and W=(0110)W=\begin{pmatrix}0&1\\1&0\end{pmatrix}, so the cost is 2x1x22x_1x_2. What lower bound does n λmin⁡(W)n\,\lambda_{\min}(W) give?

Show the answer

-2

The eigenvalues of WW are ±1\pm1, so the bound is 2⋅(−1)=−22\cdot(-1)=-2. The true optimum is also −2-2 (give the two items opposite signs), so here the bound is tight. For larger WW it usually is not: this problem is nonconvex, and its duality gap can be positive.

Strong duality: Slater's theorem

DerivationProof (inequality constraints only, $p^star$ finite)
  1. A={(u,t)∈Rm×R: ∃ x∈D, fi(x)≤ui ∀i, f0(x)≤t},p⋆=inf⁡{t:(0,t)∈A}\mathcal A=\big\{(\mathbf u,t)\in\R^m\times\R:\ \exists\,\mathbf x\in\mathcal D,\ f_i(\mathbf x)\le u_i\ \forall i,\ f_0(\mathbf x)\le t\big\},\qquad p^\star=\inf\{t:(\mathbf 0,t)\in\mathcal A\}

    Collect every achievable pair of constraint values and objective value, with slack allowed upward. The set A\mathcal A is convex because the fif_i are, and p⋆p^\star is the lowest height at which it meets the vertical axis:

  2. λ~⊤u+μt ≥ α  for (u,t)∈A,μs ≤ α  for (0,s)∈B\tilde{\boldsymbol\lambda}^\top\mathbf u+\mu t\ \ge\ \alpha\ \ \text{for }(\mathbf u,t)\in\mathcal A,\qquad\mu s\ \le\ \alpha\ \ \text{for }(\mathbf 0,s)\in\mathcal B

    The convex set B={(0,s):s<p⋆}\mathcal B=\{(\mathbf 0,s):s<p^\star\} does not meet A\mathcal A, so a hyperplane separates them: some (λ~,μ)≠0(\tilde{\boldsymbol\lambda},\mu)\ne\mathbf 0 and α\alpha satisfy the inequalities below. Since A\mathcal A is closed upward in every coordinate, λ~≥0\tilde{\boldsymbol\lambda}\ge\mathbf 0 and μ≥0\mu\ge0, and letting s↑p⋆s\uparrow p^\star gives μp⋆≤α\mu p^\star\le\alpha.

  3. f0(x)+λ⋆⊤f(x) ≥ αμ ≥ p⋆  for all x∈D⟹q(λ⋆)=p⋆=d⋆f_0(\mathbf x)+\boldsymbol\lambda^{\star\top}\mathbf f(\mathbf x)\ \ge\ \frac\alpha\mu\ \ge\ p^\star\ \ \text{for all }\mathbf x\in\mathcal D\qquad\Longrightarrow\qquad q(\boldsymbol\lambda^\star)=p^\star=d^\star

    If μ>0\mu>0, divide by μ\mu and apply the first inequality to (f(x),f0(x))∈A(\mathbf f(\mathbf x),f_0(\mathbf x))\in\mathcal A. The multipliers λ⋆=λ~/μ\boldsymbol\lambda^\star=\tilde{\boldsymbol\lambda}/\mu then satisfy q(λ⋆)≥p⋆q(\boldsymbol\lambda^\star)\ge p^\star, and weak duality turns this into equality:

  4. μ=0⟹0 ≤ λ~⊤f(x~) < 0, a contradiction\mu=0\quad\Longrightarrow\quad0\ \le\ \tilde{\boldsymbol\lambda}^\top\mathbf f(\tilde{\mathbf x})\ <\ 0,\ \text{a contradiction}

    Slater's point rules out a vertical hyperplane. If μ=0\mu=0, then λ~≥0\tilde{\boldsymbol\lambda}\ge\mathbf 0 is nonzero and λ~⊤f(x)≥α≥0\tilde{\boldsymbol\lambda}^\top\mathbf f(\mathbf x)\ge\alpha\ge0 on all of D\mathcal D, yet every fi(x~)<0f_i(\tilde{\mathbf x})<0:

Multipliers are prices. The optimal value of the perturbed problem, p⋆(u)=inf⁡{f0(x):fi(x)≤ui ∀i}p^\star(\mathbf u)=\inf\{f_0(\mathbf x):f_i(\mathbf x)\le u_i\ \forall i\}, is convex in u\mathbf u. Under strong duality, for every x\mathbf x feasible for the perturbed problem, p⋆(0)=q(λ⋆)≤f0(x)+λ⋆⊤f(x)≤f0(x)+λ⋆⊤up^\star(\mathbf 0)=q(\boldsymbol\lambda^\star)\le f_0(\mathbf x)+\boldsymbol\lambda^{\star\top}\mathbf f(\mathbf x)\le f_0(\mathbf x)+\boldsymbol\lambda^{\star\top}\mathbf u, and taking the infimum,

p⋆(u) ≥ p⋆(0)−λ⋆⊤ufor all u,p^\star(\mathbf u)\ \ge\ p^\star(\mathbf 0)-\boldsymbol\lambda^{\star\top}\mathbf u\qquad\text{for all }\mathbf u,

with ∂p⋆/∂ui=−λi⋆\partial p^\star/\partial u_i=-\lambda_i^\star wherever p⋆p^\star is differentiable. A large λi⋆\lambda_i^\star means loosening constraint ii would pay a lot; λi⋆=0\lambda_i^\star=0 means it does not matter at the margin.

Predict before you look

For min⁡x2\min x^2 subject to x≥1x\ge1 (so f1=1−xf_1=1-x, p⋆=1p^\star=1, λ⋆=2\lambda^\star=2), tighten the constraint to x≥1.1x\ge1.1, which is u=−0.1u=-0.1. What does the bound p⋆(0)−λ⋆up^\star(0)-\lambda^\star u predict for the new optimal value?

Show the answer

1.2

1−2⋅(−0.1)=1.21-2\cdot(-0.1)=1.2. The true value is 1.12=1.211.1^2=1.21, above the prediction as the global inequality guarantees; the difference is second order in uu.

The KKT conditions, support vectors and the lasso

DerivationProof
  1. f0(x⋆)=q(λ⋆,ν⋆)=inf⁡xL(x,λ⋆,ν⋆) ≤ L(x⋆,λ⋆,ν⋆) ≤ f0(x⋆)f_0(\mathbf x^\star)=q(\boldsymbol\lambda^\star,\boldsymbol\nu^\star)=\inf_{\mathbf x}\mathcal L(\mathbf x,\boldsymbol\lambda^\star,\boldsymbol\nu^\star)\ \le\ \mathcal L(\mathbf x^\star,\boldsymbol\lambda^\star,\boldsymbol\nu^\star)\ \le\ f_0(\mathbf x^\star)

    Necessity. Chain the definitions. The two ends agree, so every inequality in between is an equality:

  2. ∇xL(x⋆,λ⋆,ν⋆)=0,λi⋆fi(x⋆)=0  for every i\nabla_{\mathbf x}\mathcal L(\mathbf x^\star,\boldsymbol\lambda^\star,\boldsymbol\nu^\star)=\mathbf 0,\qquad\lambda_i^\star f_i(\mathbf x^\star)=0\ \ \text{for every }i

    Equality on the left says x⋆\mathbf x^\star minimizes L(⋅,λ⋆,ν⋆)\mathcal L(\cdot,\boldsymbol\lambda^\star,\boldsymbol\nu^\star), so its gradient vanishes there. Equality on the right says ∑iλi⋆fi(x⋆)=0\sum_i\lambda_i^\star f_i(\mathbf x^\star)=0, a sum of nonpositive terms, so each term is zero:

  3. q(λ~,ν~)=L(x~,λ~,ν~)=f0(x~)+∑iλ~ifi(x~)+∑jν~jhj(x~)=f0(x~)q(\tilde{\boldsymbol\lambda},\tilde{\boldsymbol\nu})=\mathcal L(\tilde{\mathbf x},\tilde{\boldsymbol\lambda},\tilde{\boldsymbol\nu})=f_0(\tilde{\mathbf x})+\sum_i\tilde\lambda_if_i(\tilde{\mathbf x})+\sum_j\tilde\nu_jh_j(\tilde{\mathbf x})=f_0(\tilde{\mathbf x})

    Sufficiency. With λ~≥0\tilde{\boldsymbol\lambda}\ge\mathbf 0 and affine hjh_j, the function L(⋅,λ~,ν~)\mathcal L(\cdot,\tilde{\boldsymbol\lambda},\tilde{\boldsymbol\nu}) is convex, so stationarity makes x~\tilde{\mathbf x} its global minimizer. Complementary slackness and feasibility then make a dual value equal a primal value, which certifies both as optimal:

DerivationThe soft-margin SVM dual
  1. L=12∥w∥2+C∑iξi−∑iαi[yi(w⊤xi+b)−1+ξi]−∑iriξi\mathcal L=\tfrac12\norm{\mathbf w}^2+C\sum_i\xi_i-\sum_i\alpha_i\big[y_i(\mathbf w^\top\mathbf x_i+b)-1+\xi_i\big]-\sum_ir_i\xi_i

    With labels yi∈{−1,+1}y_i\in\{-1,+1\} and slack variables ξi\xi_i, the soft-margin SVM (Cortes & Vapnik, 1995) minimizes 12∥w∥2+C∑iξi\frac12\norm{\mathbf w}^2+C\sum_i\xi_i subject to yi(w⊤xi+b)≥1−ξiy_i(\mathbf w^\top\mathbf x_i+b)\ge1-\xi_i and ξi≥0\xi_i\ge0: a convex quadratic program with affine constraints, so strong duality holds. Attach αi≥0\alpha_i\ge0 to the margin constraints and ri≥0r_i\ge0 to ξi≥0\xi_i\ge0:

  2. w=∑iαiyixi,∑iαiyi=0,αi+ri=C  ⟹  0≤αi≤C\mathbf w=\sum_i\alpha_iy_i\mathbf x_i,\qquad\sum_i\alpha_iy_i=0,\qquad\alpha_i+r_i=C\ \ \Longrightarrow\ \ 0\le\alpha_i\le C

    Stationarity in w\mathbf w, bb and each ξi\xi_i:

  3. max⁡α ∑iαi−12∑i,jαiαjyiyj xi⊤xjsubject to0≤αi≤C,  ∑iαiyi=0\max_{\boldsymbol\alpha}\ \sum_i\alpha_i-\frac12\sum_{i,j}\alpha_i\alpha_jy_iy_j\,\mathbf x_i^\top\mathbf x_j\quad\text{subject to}\quad0\le\alpha_i\le C,\ \ \sum_i\alpha_iy_i=0

    Substituting back eliminates w\mathbf w, bb and ξ\boldsymbol\xi. The data enter only through inner products, which a kernel can replace (The SVM Dual & Support Vectors solves this problem with SMO):

  4. αi=0 ⇒ yif(xi)≥1,0<αi<C ⇒ yif(xi)=1,αi=C ⇒ yif(xi)≤1\alpha_i=0\ \Rightarrow\ y_if(\mathbf x_i)\ge1,\qquad0<\alpha_i<C\ \Rightarrow\ y_if(\mathbf x_i)=1,\qquad\alpha_i=C\ \Rightarrow\ y_if(\mathbf x_i)\le1

    Complementary slackness, αi[yif(xi)−1+ξi]=0\alpha_i\big[y_if(\mathbf x_i)-1+\xi_i\big]=0 and (C−αi)ξi=0(C-\alpha_i)\xi_i=0 with f(x)=w⊤x+bf(\mathbf x)=\mathbf w^\top\mathbf x+b, sorts the training points into three kinds:

The lasso dual. For min⁡w12∥y−Xw∥2+λ∥w∥1\min_{\mathbf w}\frac12\norm{\mathbf y-X\mathbf w}^2+\lambda\norm{\mathbf w}_1, introduce z=Xw\mathbf z=X\mathbf w and dualize. Minimizing over z\mathbf z is a quadratic, and minimizing over w\mathbf w is bounded only when every column satisfies ∣xj⊤θ∣≤λ\abs{\mathbf x_j^\top\boldsymbol\theta}\le\lambda. The dual is a projection,

max⁡θ 12∥y∥2−12∥y−θ∥2subject to∣xj⊤θ∣≤λ  (j=1,…,d):\max_{\boldsymbol\theta}\ \tfrac12\norm{\mathbf y}^2-\tfrac12\norm{\mathbf y-\boldsymbol\theta}^2\quad\text{subject to}\quad\abs{\mathbf x_j^\top\boldsymbol\theta}\le\lambda\ \ (j=1,\dots,d):

θ⋆\boldsymbol\theta^\star is the Euclidean projection of y\mathbf y onto a polytope, and it equals the optimal residual y−Xw⋆\mathbf y-X\mathbf w^\star. Stationarity reads xj⊤θ⋆∈λ ∂∣wj⋆∣\mathbf x_j^\top\boldsymbol\theta^\star\in\lambda\,\partial\abs{w_j^\star}: every active feature has residual correlation exactly ±λ\pm\lambda, and ∣xj⊤θ⋆∣<λ\abs{\mathbf x_j^\top\boldsymbol\theta^\star}<\lambda forces wj⋆=0w_j^\star=0.

Two practical tools follow. Any w\mathbf w gives a dual-feasible point by rescaling its residual r=y−Xw\mathbf r=\mathbf y-X\mathbf w to θ=rmin⁡(1,λ/∥X⊤r∥∞)\boldsymbol\theta=\mathbf r\min\big(1,\lambda/\norm{X^\top\mathbf r}_\infty\big), so the gap P(w)−D(θ)P(\mathbf w)-D(\boldsymbol\theta) is a computable stopping certificate. And because the dual objective is 11-strongly concave, ∥θ−θ⋆∥≤2 (P(w)−D(θ))\norm{\boldsymbol\theta-\boldsymbol\theta^\star}\le\sqrt{2\,(P(\mathbf w)-D(\boldsymbol\theta))}: a ball known to contain θ⋆\boldsymbol\theta^\star. Whenever ∣xj⊤θ∣+∥xj∥2 (P−D)<λ\abs{\mathbf x_j^\top\boldsymbol\theta}+\norm{\mathbf x_j}\sqrt{2\,(P-D)}<\lambda, feature jj 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

fff∗f^*Where it appears
12∥x∥22\frac12\norm{\mathbf x}_2^212∥s∥22\frac12\norm{\mathbf s}_2^2ridge; the only self-conjugate function
12x⊤Qx\frac12\mathbf x^\top Q\mathbf x, Q≻0Q\succ012s⊤Q−1s\frac12\mathbf s^\top Q^{-1}\mathbf sGaussian log-likelihoods, preconditioning
a norm ∥x∥\norm{\mathbf x}00 if ∥s∥∗≤1\norm{\mathbf s}_*\le1, else +∞+\inftythe box ∥X⊤θ∥∞≤λ\norm{X^\top\boldsymbol\theta}_\infty\le\lambda in the lasso dual
indicator of a set CCsup⁡x∈Cs⊤x\sup_{\mathbf x\in C}\mathbf s^\top\mathbf x (support function)constraints
log⁡∑iexi\log\sum_ie^{x_i}∑isilog⁡si\sum_is_i\log s_i on the probability simplex, else +∞+\inftysoftmax and negative entropy
log⁡(1+ez)\log(1+e^z)slog⁡s+(1−s)log⁡(1−s)s\log s+(1-s)\log(1-s) on [0,1][0,1]logistic loss and binary entropy
max⁡(0,1−z)\max(0,1-z)ss on [−1,0][-1,0], else +∞+\inftyhinge loss and the SVM's box constraint
∥s∥∗=sup⁡∥x∥≤1s⊤x\norm{\mathbf s}_*=\sup_{\norm{\mathbf x}\le1}\mathbf s^\top\mathbf x is the dual norm: ℓ1\ell_1 and ℓ∞\ell_\infty are dual to each other, and ℓ2\ell_2 is dual to itself. Entropy is the conjugate of log-sum-exp, which is why maximum-entropy models and log-linear models are dual descriptions of the same fit (Mirror Descent & Natural Gradient uses the same pair).
DerivationThe dual of regularized empirical risk minimization
  1. L(w,z,α)=1n∑i=1n[ϕi(zi)+αi(zi−xi⊤w)]+λ2∥w∥2\mathcal L(\mathbf w,\mathbf z,\boldsymbol\alpha)=\frac1n\sum_{i=1}^n\Big[\phi_i(z_i)+\alpha_i\big(z_i-\mathbf x_i^\top\mathbf w\big)\Big]+\frac\lambda2\norm{\mathbf w}^2

    Take P(w)=1n∑i=1nϕi(xi⊤w)+λ2∥w∥2P(\mathbf w)=\frac1n\sum_{i=1}^n\phi_i(\mathbf x_i^\top\mathbf w)+\frac\lambda2\norm{\mathbf w}^2 with convex losses ϕi\phi_i, for example ϕi(z)=max⁡(0,1−yiz)\phi_i(z)=\max(0,1-y_iz). Introduce zi=xi⊤wz_i=\mathbf x_i^\top\mathbf w with multipliers αi/n\alpha_i/n:

  2. inf⁡zi(ϕi(zi)+αizi)=−ϕi∗(−αi),w(α)=1λn∑i=1nαixi\inf_{z_i}\big(\phi_i(z_i)+\alpha_iz_i\big)=-\phi_i^*(-\alpha_i),\qquad\mathbf w(\boldsymbol\alpha)=\frac1{\lambda n}\sum_{i=1}^n\alpha_i\mathbf x_i

    Minimizing over each ziz_i produces a conjugate, by definition, and minimizing over w\mathbf w is a ridge-like quadratic:

  3. D(α)=1n∑i=1n−ϕi∗(−αi)−λ2∥1λn∑i=1nαixi∥2D(\boldsymbol\alpha)=\frac1n\sum_{i=1}^n-\phi_i^*(-\alpha_i)-\frac\lambda2\Big\lVert\frac1{\lambda n}\sum_{i=1}^n\alpha_i\mathbf x_i\Big\rVert^2

    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, −ϕi∗(−αi)=yiαi-\phi_i^*(-\alpha_i)=y_i\alpha_i with yiαi∈[0,1]y_i\alpha_i\in[0,1]; writing βi=yiαi\beta_i=y_i\alpha_i recovers the SVM dual without a bias term, the box 0≤βi≤10\le\beta_i\le1 playing the role of 0≤αi≤C0\le\alpha_i\le C with C=1/(λn)C=1/(\lambda n).

  4. P(w(α))−D(α) ≥ P(w(α))−P⋆ ≥ 0P\big(\mathbf w(\boldsymbol\alpha)\big)-D(\boldsymbol\alpha)\ \ge\ P\big(\mathbf w(\boldsymbol\alpha)\big)-P^\star\ \ge\ 0

    Stochastic dual coordinate ascent (Shalev-Shwartz & Zhang, 2013) maximizes DD one αi\alpha_i at a time, each step touching a single example while w(α)\mathbf w(\boldsymbol\alpha) is updated incrementally. For smooth losses it converges linearly, and at every step the duality gap certifies the accuracy, something primal SGD cannot provide:

Check your understanding

What is the Fenchel conjugate of f(x)=λ∥x∥1f(\mathbf x)=\lambda\norm{\mathbf x}_1?

  1. λ∥s∥∞\lambda\norm{\mathbf s}_\infty
  2. 00 if ∥s∥∞≤λ\norm{\mathbf s}_\infty\le\lambda, and +∞+\infty otherwise
  3. 1λ∥s∥1\frac1\lambda\norm{\mathbf s}_1
  4. 00 if ∥s∥1≤λ\norm{\mathbf s}_1\le\lambda, and +∞+\infty otherwise
Show the answer

B. 00 if ∥s∥∞≤λ\norm{\mathbf s}_\infty\le\lambda, and +∞+\infty otherwise

sup⁡x(s⊤x−λ∥x∥1)\sup_{\mathbf x}\big(\mathbf s^\top\mathbf x-\lambda\norm{\mathbf x}_1\big) separates over coordinates. If every ∣si∣≤λ\abs{s_i}\le\lambda, each term sixi−λ∣xi∣s_ix_i-\lambda\abs{x_i} is at most 00, attained at x=0\mathbf x=\mathbf 0. If some ∣si∣>λ\abs{s_i}>\lambda, push xix_i to infinity with the sign of sis_i and the supremum is +∞+\infty. This indicator of the ℓ∞\ell_\infty ball is exactly the constraint in the lasso dual.

Key takeaways

  • The dual function q(λ,ν)=inf⁡xLq(\boldsymbol\lambda,\boldsymbol\nu)=\inf_{\mathbf x}\mathcal L is concave for every problem and bounds p⋆p^\star 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 p⋆p^\star. 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 (αi>0\alpha_i>0 only on or inside the margin) and the lasso's active set (residual correlation exactly ±λ\pm\lambda), and multipliers are the sensitivities −∂p⋆/∂ui-\partial p^\star/\partial u_i.
  • Fenchel conjugates dualize regularized ERM into a problem with one variable per example and w=1λn∑iαixi\mathbf w=\frac1{\lambda n}\sum_i\alpha_i\mathbf x_i; 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.

Question 1

A convex problem has feasible points, but none of them satisfies the nonaffine inequality constraints strictly. What can you conclude about strong duality?

  1. It holds anyway, because the problem is convex
  2. The dual problem must be unbounded
  3. A positive gap is possible, as in min⁡e−x\min e^{-x} subject to x2/y≤0x^2/y\le0, but the gap may also be zero: Slater's condition is sufficient, not necessary
  4. The KKT conditions can have no solution, so the primal has no minimizer
Show the answer

C. A positive gap is possible, as in min⁡e−x\min e^{-x} subject to x2/y≤0x^2/y\le0, but the gap may also be zero: Slater's condition is sufficient, not necessary

Slater's condition is one sufficient constraint qualification. Without it, e−xe^{-x} subject to x2/y≤0x^2/y\le0 has p⋆=1p^\star=1 and d⋆=0d^\star=0; other problems without strictly feasible points still have zero gap.

Question 2

In a soft-margin SVM solution, a training point has dual variable 0<αi<C0<\alpha_i<C. Where does it lie?

  1. Strictly outside the margin, correctly classified
  2. On the wrong side of the decision boundary
  3. Inside the margin, with positive slack
  4. Exactly on the margin: yi(w⊤xi+b)=1y_i(\mathbf w^\top\mathbf x_i+b)=1
Show the answer

D. Exactly on the margin: yi(w⊤xi+b)=1y_i(\mathbf w^\top\mathbf x_i+b)=1

αi<C\alpha_i<C makes the multiplier of ξi≥0\xi_i\ge0 positive, ri=C−αi>0r_i=C-\alpha_i>0, so ξi=0\xi_i=0; and αi>0\alpha_i>0 makes the margin constraint tight, yif(xi)=1−ξi=1y_if(\mathbf x_i)=1-\xi_i=1. These margin support vectors are also how bb is recovered: any of them gives b=yi−w⊤xib=y_i-\mathbf w^\top\mathbf x_i.

Question 3

At the lasso solution, the dual point (the optimal residual θ⋆=y−Xw⋆\boldsymbol\theta^\star=\mathbf y-X\mathbf w^\star) satisfies ∣xj⊤θ⋆∣<λ\abs{\mathbf x_j^\top\boldsymbol\theta^\star}<\lambda for feature jj. What follows?

  1. wj⋆=0w_j^\star=0
  2. wj⋆=±λw_j^\star=\pm\lambda
  3. Feature jj has the largest coefficient in magnitude
  4. Nothing, until the primal is solved exactly
Show the answer

A. wj⋆=0w_j^\star=0

Stationarity says xj⊤θ⋆∈λ ∂∣wj⋆∣\mathbf x_j^\top\boldsymbol\theta^\star\in\lambda\,\partial\abs{w_j^\star}. If wj⋆≠0w_j^\star\ne0 the subdifferential is {sign⁡wj⋆}\{\sign w_j^\star\}, which would force ∣xj⊤θ⋆∣=λ\abs{\mathbf x_j^\top\boldsymbol\theta^\star}=\lambda. Safe screening applies the same test to a ball around an approximate dual point.

Question 4

A point satisfies the KKT conditions of a nonconvex problem whose constraints satisfy a constraint qualification. What can you conclude?

  1. It is the global minimizer
  2. It is at least a local minimizer
  3. It is a candidate only: it may be a local minimum, a saddle point or a local maximum
  4. 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 L(⋅,λ,ν)\mathcal L(\cdot,\boldsymbol\lambda,\boldsymbol\nu), 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).