KKT Optimality Conditions
Constrained optima balance the objective pull against active constraint pushes. KKT writes that balance as four checkable equations.
Why Does This Exist?
Unconstrained optima set the gradient to zero. Constrained optima usually sit on the boundary where the gradient is not zero: the objective pulls outward while the wall pushes back. Declaring "gradient nonzero so not optimal" misses every boundary solution, which is most of them.
Karush-Kuhn-Tucker writes the standoff as four conditions on (x^\\star, \\lambda^\\star, \\nu^\\star): stationarity, primal feasibility, dual feasibility, complementary slackness. Under convexity plus constraint qualification they certify global optimality. It sharpens Lagrange multipliers and duality into the checker for convex optimization.
The one idea you need first
A constraint is active when g(x^\\star) = 0 (on the wall) and inactive when strictly inside. Only active walls push, priced by multipliers . Inactive walls price zero.
Think of It Like This
A dog on a leash at the fence
A dog runs toward a squirrel (objective pull) until the leash snaps taut at the fence (active constraint). At rest, pull plus leash tension balance: stationarity. The leash only pulls when taut (slackness), never pushes the dog outward (dual feasibility ), and the dog stays inside the yard (primal feasibility).
A loose leash prices zero. Where it stops: leashes are single and smooth, while real problems stack many walls with kinks needing constraint qualifications.
How It Actually Works
For minimize subject to , with differentiable functions: stationarity ; primal ; dual ; slackness . SVMs read off support vectors as active constraints with . Constraint qualifications (Slater, LICQ) rule out degenerate wall tangles where multipliers misbehave.
Worked example
Minimize subject to (write ). Lagrangian . Stationarity: . Guess active: x^\\star = 1, then gives \\lambda^\\star = 4 \\geq 0. Checks: primal feasible, slackness , dual . Certified constrained optimum with value and wall price 4. Inactive guess would give , violating : correctly rejected.
Code
x, lam = 1.0, 4.0stat = 2 * (x - 3) + lam # stationarity residualprint(round(stat, 6)) # -> 0.0print(x <= 1, lam >= 0, round(lam * (x - 1), 6)) # -> True True 0.0Residual zero with feasibility, sign, and slackness all passing. Four numbers certify the point.
Watch Out For
Trusting KKT without constraint qualification
Degenerate constraints (duplicated walls, cusps) admit KKT points that are not optimal, or optima with no multipliers. Solvers return "KKT satisfied" on such models and teams stop.
Verify Slater (strictly feasible point for convex) or LICQ (independent active gradients). If walls are redundant or kinky, reformulate before certifying.
Reading inactive multipliers as influence
means the wall did not push: removing it changes nothing locally. Teams regularize or price constraints by and chase zeros.
Rank active constraints by only. Sensitivity dp^\\star/db_i = -\\lambda_i holds at active walls under regularity, nowhere else.
The Quick Version
- KKT balances objective pull against active wall pushes with four checks.
- Example left of 1 certifies x^\\star = 1, \\lambda^\\star = 4, value 4.
- Slackness pairs prices with walls: positive price means on the wall.
- Convex plus qualified makes KKT sufficient for global optimality.
- SVM support vectors are exactly the active set with positive multipliers.
- Without qualification, KKT neither certifies nor prices reliably.