Hyoungseo Son
Convex Optimization
Contents · Convex Optimization

Part 0 · Convexity

Part 1 · Quadratic Programs

Part 2 · Duality

  • Duality and the KKT Conditions

Part 2 · Duality

Duality and the KKT Conditions

Every inequality constraint carries a shadow price. It stays zero while the constraint is slack and turns on the instant the constraint binds. Those prices are the dual variables, and at an optimum they and the primal solution satisfy the KKT conditions. In physics the same prices come back with a physical name: they are the constraint forces that hold contacts and joints together.

The Lagrangian and the dual

Take the problem minxf(x)\min_x f(x) subject to gi(x)0g_i(x) \le 0 for i=1,,mi = 1,\dots,m. Fold the constraints into the objective with one multiplier each:

L(x,μ)=f(x)+i=1mμigi(x),μi0.\mathcal{L}(x,\mu) = f(x) + \sum_{i=1}^m \mu_i\, g_i(x), \qquad \mu_i \ge 0 .

Each μi\mu_i charges a penalty proportional to the violation gi(x)g_i(x). Minimizing L\mathcal{L} over xx for a fixed price vector gives the dual function

q(μ)=infxL(x,μ).q(\mu) = \inf_x\, \mathcal{L}(x,\mu) .

For any feasible xx (so gi(x)0g_i(x) \le 0) and any μ0\mu \ge 0, the penalty sum is nonpositive, hence L(x,μ)f(x)\mathcal{L}(x,\mu) \le f(x) and

q(μ)    L(x,μ)    f(x).q(\mu) \;\le\; \mathcal{L}(x,\mu) \;\le\; f(x) .

Taking the infimum over feasible xx gives weak duality, q(μ)pq(\mu) \le p^\star, where pp^\star is the primal optimum. The dual problem sharpens this lower bound, d=maxμ0q(μ)pd^\star = \max_{\mu \ge 0} q(\mu) \le p^\star. The difference pd0p^\star - d^\star \ge 0 is the duality gap. When ff and the gig_i are convex and a strictly feasible point exists (Slater's condition), the gap closes: d=pd^\star = p^\star, which is strong duality.1

The KKT conditions

At a primal-dual optimum (x,μ)(x^\star,\mu^\star) under strong duality, four conditions hold together:

stationarity:f(x)+iμigi(x)=0,primal feasibility:gi(x)0,dual feasibility:μi0,complementary slackness:μigi(x)=0.\begin{aligned} &\text{stationarity:} && \nabla f(x^\star) + \sum_i \mu_i^\star\, \nabla g_i(x^\star) = 0, \\ &\text{primal feasibility:} && g_i(x^\star) \le 0, \\ &\text{dual feasibility:} && \mu_i^\star \ge 0, \\ &\text{complementary slackness:} && \mu_i^\star\, g_i(x^\star) = 0 . \end{aligned}

Complementary slackness is the hinge. For each constraint either gi=0g_i = 0 (tight, and it may carry a positive price) or μi=0\mu_i = 0 (slack, and its price vanishes), never both. Stationarity reads geometrically: f-\nabla f is a nonnegative combination of the active constraint gradients, so the steepest-descent direction is exactly cancelled by the constraints that push back. For convex programs these four conditions are not only necessary but sufficient for optimality.

A worked example

Minimize 12(x12+x22)\tfrac12(x_1^2 + x_2^2) subject to x1+x21x_1 + x_2 \ge 1, written as g(x)=1x1x20g(x) = 1 - x_1 - x_2 \le 0. The gradients are

f=[x1x2],g=[11].\nabla f = \begin{bmatrix} x_1 \\ x_2 \end{bmatrix}, \qquad \nabla g = \begin{bmatrix} -1 \\ -1 \end{bmatrix}.

Stationarity f+μg=0\nabla f + \mu \nabla g = 0 gives x1=μx_1 = \mu and x2=μx_2 = \mu. Complementary slackness μ(1x1x2)=0\mu\,(1 - x_1 - x_2) = 0 leaves two branches. If μ=0\mu = 0 then x=0x = 0, but g(0)=1>0g(0) = 1 > 0 is infeasible, so that branch is rejected. The other branch takes the constraint active, x1+x2=1x_1 + x_2 = 1:

2μ=1        μ=12,x=[1212],f=14.2\mu = 1 \;\implies\; \mu = \tfrac12, \qquad x^\star = \begin{bmatrix} \tfrac12 \\ \tfrac12 \end{bmatrix}, \qquad f^\star = \tfrac14 .

Dual feasibility μ=120\mu = \tfrac12 \ge 0 and primal feasibility g(x)=0g(x^\star) = 0 both check, so this is the optimum. The dual confirms it. Minimizing L=12(x12+x22)+μ(1x1x2)\mathcal{L} = \tfrac12(x_1^2 + x_2^2) + \mu(1 - x_1 - x_2) over xx at x1=x2=μx_1 = x_2 = \mu gives

q(μ)=μμ2,μ0,q(\mu) = \mu - \mu^2, \qquad \mu \ge 0,

which is maximized at μ=12\mu = \tfrac12 with q(12)=14=pq(\tfrac12) = \tfrac14 = p^\star. The gap is zero: strong duality holds.

KKT geometryinteractive

objective bowl + feasible halfspace (drag to move c)

cx*
c (uncon. min)
(0.00, 0.00)
x* (optimum)
(0.50, 0.50)
g(x*) = 1−x1−x2
0.00
μ (multiplier)
0.50
μ · g(x*)
0.00 = 0

constraint active: g(x*) = 0, μ > 0. −∇f (dark) lies along ∇g (yellow), so −∇f = μ∇g.

Complementary slackness forces μ·g(x*) = 0: either the constraint is tight and priced (μ > 0), or slack and free (μ = 0). Never both.

Drag c, the unconstrained minimum (center of the circular level sets). If c is feasible, x* = c and μ = 0. Otherwise x* is c projected onto the boundary: the active level set is tangent there, and −∇f (dark) lies along the constraint gradient ∇g (yellow) with −∇f = μ∇g, μ ≥ 0. The default c at the origin gives x* = (0.5, 0.5), μ = 0.5.

Constraint forces are the multipliers

In rigid-body dynamics the nonpenetration constraint at contact ii is gi(x)=ϕi0g_i(x) = -\phi_i \le 0, where ϕi0\phi_i \ge 0 is the gap. Its multiplier μi\mu_i is nothing other than the normal contact force (or impulse) λi\lambda_i, and the three complementarity pieces of KKT read as physical laws:

λi0,ϕi0,λiϕi=0.\lambda_i \ge 0, \qquad \phi_i \ge 0, \qquad \lambda_i\, \phi_i = 0 .

Dual feasibility λi0\lambda_i \ge 0 is one-sidedness: a contact pushes and never pulls. Complementary slackness λiϕi=0\lambda_i \phi_i = 0 is the Signorini condition: a force acts only when the gap is closed. Stationarity is the equation of motion, with each constraint force λigi\lambda_i \nabla g_i acting along the surface normal and scaled by its multiplier. So the geometric statement from the demo, that the multiplier scales the constraint normal, is literally the statement that a contact force points along the normal with magnitude set by how hard the constraint is pressed. KKT is the optimization face of the same complementarity that governs contact.

Footnotes

  1. Boyd & Vandenberghe, Convex Optimization (2004).