Purpose

A reference for constrained optimization: what convexity buys, how the Lagrangian and dual problem arise, and what the KKT conditions say. Linear Programming is the special case where everything is affine, and resource allocation under constraints — as in scheduling — uses the dual-variables-as-prices idea without naming it. Section and equation references are to Boyd and Vandenberghe, cited as B&V.

Convex sets and functions

A set is convex if the segment between any two of its points stays inside: and imply (B&V §2.1). A function is convex if its domain is convex and

chords lie above the graph (B&V §3.1). Two equivalent tests for differentiable : the first-order condition , the tangent plane is a global underestimator, and the second-order condition .

Convexity changes what optimization can promise. For a convex over a convex set, every local minimum is global, and the first-order condition turns a zero gradient from a stationarity statement into a certificate of optimality. Without convexity, all the machinery below still produces necessary conditions, but nothing certifies you found the minimum.

The Lagrangian and the dual

Standard form (B&V §4.2, §5.1):

convex when are convex and the affine. The Lagrangian prices the constraints instead of enforcing them:

with multipliers for inequalities and free for equalities. The dual function minimizes out :

For any feasible and any , the penalty terms are nonpositive, so , and therefore , the primal optimum. Every dual point is a lower bound; this is weak duality, and it holds with no convexity at all (B&V §5.1.3). Maximizing the bound gives the dual problem, always concave regardless of the primal, with optimum . The gap closes for convex problems under mild conditions: Slater’s condition, existence of a strictly feasible point with , guarantees strong duality (B&V §5.2.3).

flowchart TD
    P["Primal problem: minimize f0 over the feasible set"] --> L["Lagrangian: replace constraints with prices lambda, nu"]
    L --> G["Dual function: minimize the Lagrangian over x"]
    G --> D["Dual problem: maximize the lower bound"]
    D -- "always" --> W["Weak duality: dual optimum below primal optimum"]
    D -- "convex plus Slater" --> S["Strong duality: dual optimum equals primal optimum"]
    style P fill:#e3f2fd
    style D fill:#e3f2fd
    style W fill:#f9d0d0
    style S fill:#e8f5e9

Boyd’s interpretation in EE364a lecture 9: the optimal are shadow prices. If constraint is relaxed from to , the optimal value moves at rate in (B&V §5.6.3). A large multiplier marks a constraint the objective is straining against; a zero multiplier marks one you could delete.

KKT conditions

For differentiable problems, the Karush-Kuhn-Tucker conditions bundle everything a primal-dual optimal pair must satisfy (B&V §5.5.3):

  1. Primal feasibility: , .
  2. Dual feasibility: .
  3. Complementary slackness: for every .
  4. Stationarity: .

When strong duality holds, any primal-dual optimal pair satisfies KKT (necessity). For convex problems, any point satisfying KKT is optimal (sufficiency), so with Slater’s condition, KKT exactly characterizes the solution (B&V §5.5.3).

Complementary slackness is the reading key: either a constraint is inactive and its price is zero, or it binds and may carry a positive price. Stationarity says the objective gradient is a nonnegative combination of active constraint gradients, geometrically, at the optimum there is no feasible descent direction, because every way downhill exits the feasible set.

KKT as a checklist

To verify a candidate pair , check four things:

  1. is feasible: and .
  2. Prices are legal: .
  3. Every product : inactive constraints carry zero price.
  4. The Lagrangian gradient in vanishes: .

For a convex problem satisfying Slater’s condition, passing all four is a proof of optimality, not just a necessary condition. The practical solve pattern, as in water-filling below: case-split on which constraints are active, use slackness to zero out multipliers, and solve stationarity in each case.

Worked example: water-filling

The classic KKT exercise, from B&V §5.5.3, allocating power to channels with noise levels :

As a minimization of , introduce for and for the budget. KKT:

  • Stationarity: for each .
  • Complementary slackness: .
  • Feasibility: , , .

Case split on channel . If , then and stationarity gives . If , then requires . Both cases compress into

with set by the budget . The picture that names the method: draw bars of height and pour in one unit of water; the water settles at level , filling the low-noise channels and leaving channels with above the waterline dry. The dual variable is literally the water level, and solving the problem reduces to a one-dimensional search for it.

import numpy as np
 
alpha = np.array([0.3, 0.6, 1.1, 2.0])
 
def waterfill(level):                      # total water below `level`
    return np.maximum(0.0, level - alpha).sum()
 
lo, hi = alpha.min(), alpha.min() + 1.0    # bisection on the water level
for _ in range(60):
    mid = (lo + hi) / 2
    lo, hi = (lo, mid) if waterfill(mid) > 1.0 else (mid, hi)
 
x = np.maximum(0.0, hi - alpha)
print(np.round(x, 4))    # [0.65 0.35 0.   0.  ] - two channels stay dry
print(x.sum())           # 1.0000...

The two noisy channels () sit above the water level and get nothing, matching the KKT case analysis: check that and both wet channels end at .

Where this shows up

Lagrangian duality is the backbone of more than optimization theory. SVM training is a quadratic program whose dual reveals the support vectors as the points with nonzero multipliers. Regularized regression swaps a constraint for a penalty , the Lagrangian view of the same problem. Utility-maximizing resource allocation, congestion control, and fair queueing all inherit the price interpretation: a scarce resource earns a positive multiplier, and the multiplier tells you what one more unit of the resource is worth. Linear Programming duality is the same theory with every function affine, where strong duality holds without Slater’s condition.

Sources