4.10.19Advanced Topics (Elite Level)

KKT conditions for constrained optimization

2,013 words9 min readdifficulty · medium3 backlinks

WHAT problem are we solving?

WHY this form? Any problem can be massaged into it: g(x)0g(x)\ge 0 becomes g(x)0-g(x)\le 0; maximizing ff is minimizing f-f. So this single template covers all smooth constrained optimization.


HOW we derive KKT — from Lagrange to inequalities

Step 1: Recall equality-only Lagrange

With only hj(x)=0h_j(x)=0, the minimum sits where the gradient of ff is a combination of constraint gradients: f(x)+jμjhj(x)=0.\nabla f(x^*) + \sum_j \mu_j \nabla h_j(x^*) = 0.

Why? If f\nabla f had any component along the constraint surface, you could slide that way and decrease ff while staying feasible. So at a minimum f\nabla f must be ⟂ to the surface, i.e. a combination of the hj\nabla h_j (the normals).

Step 2: Add an inequality g(x)0g(x)\le 0

Two cases for each inequality at the optimum:

  • Inactive (gi(x)<0g_i(x^*)<0, strictly inside): the fence isn't touched. Locally it's as if the constraint doesn't exist → its multiplier must be 00.
  • Active (gi(x)=0g_i(x^*)=0, on the fence): it behaves like an equality, but with a sign restriction.

Why the sign? To stay feasible we can only move where gig_i decreases or stays (gi0g_i\le0). For xx^* to be a minimum, ff must not decrease in any feasible direction. Pushing into the fence, gi-\nabla g_i points to the feasible interior; f\nabla f must point "outward" to block escape. This forces the multiplier λi0\lambda_i \ge 0.

Why complementary slackness (λigi=0\lambda_i g_i = 0)?

It's the unifying statement of Step 2. Either:

  • gi<0g_i<0 (inactive) → forces λi=0\lambda_i=0, or
  • λi>0\lambda_i>0 (active multiplier) → forces gi=0g_i=0.

Both can't be "loose" at once. The product being zero encodes "a fence only pushes back when you're touching it."


A subtle but essential ingredient: Constraint Qualification

WHY needed? If the active gradients are degenerate (e.g. two fences meeting in a cusp), the multipliers may not exist even though xx^* is optimal. LICQ guarantees the multipliers exist and are unique.


Worked Examples


Common Mistakes (Steel-manned)


Active Recall

Recall The four KKT conditions (cover and recite)
  1. Stationarity xL=0\nabla_x\mathcal L=0 · 2. Primal feasibility (g0,h=0g\le0,h=0) · 3. Dual feasibility (λ0\lambda\ge0) · 4. Complementary slackness (λigi=0\lambda_i g_i=0).
Recall Why must

λi0\lambda_i\ge0? Because a feasible move keeps gi0g_i\le0; for xx^* to be a min, f\nabla f must oppose escape into the feasible region, forcing the multiplier non-negative. Equality multipliers have no such restriction.

Recall When are KKT sufficient for a global min?

When the problem is convex (ff, gig_i convex; hjh_j affine).

Recall Feynman: explain to a 12-year-old

You roll a marble in a bowl, but there are walls. The marble stops at the lowest spot it can reach. If it stops away from a wall, the ground there is flat. If it stops against a wall, the wall is pushing on it — and a wall only pushes when you're touching it (that's "complementary slackness"). KKT is just the rulebook that says: at the stopping place, the downhill pull is exactly balanced by flat ground plus the walls you're leaning on.



Connections

  • Lagrange Multipliers — the equality-only special case (λ=0\lambda=0 everywhere, only μ\mu).
  • Convex Optimization — where KKT become necessary and sufficient.
  • Duality and the Dual Problemλ,μ\lambda,\mu are the dual variables; strong duality ↔ KKT.
  • Support Vector Machines — KKT + slackness identify the support vectors (active constraints).
  • Gradient Descent and Projected Gradient — algorithmic cousins for finding KKT points.
  • Constraint Qualifications (LICQ, Slater) — when multipliers are guaranteed to exist.

Flashcards

What is the standard form of a constrained optimization problem for KKT?
minf(x)\min f(x) s.t. gi(x)0g_i(x)\le0 and hj(x)=0h_j(x)=0.
State the stationarity condition.
f+iλigi+jμjhj=0\nabla f + \sum_i\lambda_i\nabla g_i + \sum_j\mu_j\nabla h_j = 0, i.e. xL=0\nabla_x\mathcal L=0.
What is complementary slackness and what does it mean?
λigi(x)=0\lambda_i g_i(x^*)=0 for all ii; an inequality multiplier is nonzero only if that constraint is active (gi=0g_i=0).
Which KKT multipliers must be non-negative?
Only the inequality multipliers λi0\lambda_i\ge0; equality multipliers μj\mu_j are free in sign.
When are KKT conditions sufficient for a global minimum?
When the problem is convex: ff and gig_i convex, hjh_j affine.
What is a constraint qualification (e.g. LICQ) and why is it needed?
It ensures multipliers exist; LICQ requires active inequality + equality constraint gradients to be linearly independent at xx^*.
A negative λ\lambda appears in your solution — what does it tell you?
Your active-set guess is wrong; that constraint should actually be inactive (or you have a max/saddle, not a min).
Geometrically, what does stationarity say at the optimum?
f-\nabla f lies in the cone spanned by active constraint gradients — every descent direction is blocked.

Concept Map

generalized to inequalities

solved by

packaged via

grad_x L = 0 gives

requires

requires

requires

forces lambda=0

allows lambda>0

feasible-direction argument

balances gradients of

Lagrange for equalities

KKT conditions

Constrained problem: min f s.t. g<=0, h=0

Lagrangian L

Stationarity

Primal feasibility

Dual feasibility: lambda>=0

Complementary slackness: lambda*g=0

Inactive constraint g<0

Active constraint g=0

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Socho tum ek ball ho jo cost ko minimize karna chahti ho — yaani neeche girna chahti ho. Lekin tum ek playground ke andar ho jiske around fences (inequality constraints g0g\le0) aur kuch wires (equality constraints h=0h=0) hain. Ball kahan rukegi? Ya to wahan jahan ground bilkul flat hai (unconstrained minimum), ya phir kisi fence se chipak ke jahan se aage badhna possible hi nahi. KKT conditions bas isi "rukne wali jagah" ka precise mathematical rulebook hain.

Char conditions yaad rakho — S P D C: Stationarity (xL=0\nabla_x\mathcal L=0, yaani downhill pull aur fences ka push balance ho jaye), Primal feasibility (constraints satisfy ho), Dual feasibility (λi0\lambda_i\ge0, sirf inequality wale multipliers), aur Complementary slackness (λigi=0\lambda_i g_i=0). Slackness ka matlab simple hai: ek fence tabhi push karta hai jab tum usse touch kar rahe ho. Agar tum fence se door ho (g<0g<0), to uska multiplier λ=0\lambda=0.

Sabse common galti: log socht hain saare multipliers non-negative hone chahiye. Galat! Sirf λ\lambda (inequality) 0\ge0 hota hai, μ\mu (equality) kisi bhi sign ka ho sakta hai — bilkul normal Lagrange ki tarah. Doosri galti: har constraint ko active maan ke solve karna. Hamesha cases test karo — agar tumhe λ<0\lambda<0 mile, to samajh jao tumhara active-set guess galat tha.

Kyun matter karta hai? Convex problems mein (jaise SVM, machine learning ke optimization) KKT conditions necessary aur sufficient hoti hain — yaani inhe solve kar lo to global minimum guaranteed mil jaata hai. Isiliye SVM mein "support vectors" wahi points hote hain jinka constraint active hai aur λ>0\lambda>0. KKT poori modern optimization ki backbone hai.

Go deeper — visual, from zero

Test yourself — Advanced Topics (Elite Level)

Connections