Unit 4 of 8 · about 6 hours · derive

Constraints, KKT conditions and proximal methods

Constraints and nonsmooth penalties need more than a zero ordinary gradient. KKT residuals and proximal fixed points provide certificates that an optimizer's loss curve cannot.

You'll be able to

  • Derive a small quadratic program's Lagrangian, dual lower bound and KKT certificate by hand.
  • Explain complementary slackness and where convexity and a constraint qualification enter optimality claims.
  • Derive soft thresholding and the proximal-gradient update for the lasso, then check both examples against independent answers.

Covers

Constrained optimization, Lagrangians and KKT conditionsRegularization and proximal intuition
1

Read

In this order, only the parts listed

0 of 4 done

  1. Lagrangian lower bounds and KKT certificatesConvex Optimization

    Sections 5.1.1 to 5.1.3 (pp. 215 to 216), 5.2.2 to 5.2.3 (pp. 225 to 227), and 5.5.1 to 5.5.3 (pp. 241 to 245)

    Stop 5.5.3 after Example 5.1 on p. 244. Keep only the duality needed to explain weak duality, Slater's condition and the small QP; leave broader duality theory aside.

  2. Solver status and dual valuesCVXPY basic and DCP tutorials

    Changing the problem, Infeasible and unbounded problems, and Other problem statuses

    Use the solver only after deriving the analytic solution. Accept neither optimal_inaccurate nor an iteration cap as an unchecked certificate.

  3. Read multipliers from the solver answerCVXPY basic and DCP tutorials

    Dual variables: constraint.dual_value and the two-scalar example

    Read this heading only; none of the other advanced features are assigned.

  4. Proximal maps, soft thresholding and lassoProximal Algorithms

    Sections 1.1 (p. 124), 4.2 (pp. 148 to 151), 6.5.2 (p. 188, equation 6.9), and 7.1's lasso formulation (p. 196)

    In 4.2 read the basic update and quadratic upper-model interpretation. Skip accelerated methods and ADMM. In 6.5.2 stop before projection onto the ball. Skip 7.1.1 on p. 197: it prints although ; the correct general scaling is . Its Gram rewrite with also fails to preserve the linear term, already for , . Derive lasso's update from 4.2 and 6.5.2 instead.

2

Focus on

  • Write inequalities as and attach nonnegative multipliers. The dual function minimizes the Lagrangian over without imposing the original constraints; weak duality gives a lower bound.
  • KKT comprises primal feasibility, dual feasibility, stationarity and complementary slackness. For a differentiable convex problem with affine equalities, KKT is sufficient; Slater's condition supplies necessity and dual attainment when a primal optimum exists.
  • For , proximal gradient takes , then . The threshold scales with , not just .
  • At zero, the subgradient is the interval . Derive the three scalar cases instead of pretending has a unique derivative there. For the smooth part, gives the quadratic upper-model descent argument.
Common mistakes · 3
  • Giving the wrong multiplier sign. Its standard-form constraint is , so stationarity contains .
  • Inferring a positive multiplier from an active constraint. Complementary slackness only says a positive multiplier implies activity, not the converse.
  • Using ridge's shrinkage as lasso's proximal operator. Ridge scales coordinates continuously; lasso thresholds a whole interval to zero.
3

Try it yourself

Closed-book, before checking anything

By hand minimize with , and . Use . Obtain , , and primal value 1. Derive ; its value at the certificate is 1. In CVXPY 1.9.3 use float64 a, z=cp.Variable(2), constraints=[z>=0,cp.sum(z)==1], objective=cp.Minimize(0.5*cp.sum_squares(z-a)); form prob=cp.Problem(objective,constraints) and call prob.solve(solver='CLARABEL',tol_gap_abs=1e-10,tol_gap_rel=1e-10,tol_feas=1e-10,max_iter=100). Read lam=constraints[0].dual_value and nu=constraints[1].dual_value; lam represents the mathematical , and use z.value for numerical checks. Status is optimal. Measured residuals: max(0,max(-z.value))=8.08e-13, abs(sum(z.value)-1)=1.11e-16, max(0,max(-lam))=0, np.linalg.norm(z.value-a-lam+nu, np.inf)=1.22e-11 and np.linalg.norm(lam*z.value, np.inf)=4.56e-11. np.linalg.norm(z.value-(1,0), np.inf)=8.08e-13. Require every residual and the solution difference , rather than exact feasibility. Then derive the scalar soft-threshold map and work , , by hand: . From , take 30 NumPy float64 proximal steps with ; the infinity-norm error against this closed form is 1.40e-9, allowed . No random draws are needed.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Where does each assumption enter the KKT sufficiency proof?Answer

    Convex objective and inequality functions, affine equalities, and nonnegative multipliers make convex in . Differentiability and stationarity therefore minimize globally. Feasibility and complementary slackness make . The dual infimum is then , so weak duality certifies optimality. Slater is not needed for sufficiency.

  2. 2.Does this QP satisfy Slater's condition?Answer

    Yes. strictly satisfies and satisfies the affine equality. This supplies the constraint qualification; the strictly convex objective also makes the primal optimizer unique.

  3. 3.Why is the proximal minimizer zero when ?Answer

    At the stationarity inclusion is , exactly that inequality. The quadratic term is strictly convex, so this condition identifies the unique minimizer, including both threshold endpoints.

  4. 4.How can you check a lasso answer without knowing w*?Answer

    Let . Nonzero coordinates need ; zero coordinates need . Check these residuals with a stated numerical zero threshold, or use as a proximal-gradient residual.

You're done when

You can derive the QP certificate and threshold endpoints unaided, and your NumPy and solver checks pass their stated infinity-norm and feasibility tolerances.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 8 more in the section
  • Convex OptimizationBoyd & Vandenberghe · required

    Read Chapters 1-5 and 9 with the course; use Chapter 10 only for equality-constrained Newton steps.

  • CVXPY basic and DCP tutorialsCVXPY documentation · support

    Use as the solver oracle after deriving a constrained problem and its KKT conditions by hand.

  • Proximal AlgorithmsNeal Parikh and Stephen Boyd · reference

    Read Sections 1.1, 4.2 and the elementwise soft-thresholding formula in 6.5.2, then the lasso formulation on p. 196. Skip 7.1.1's penalty-scaling and Gram-rewrite errors on p. 197; derive the update from 4.2 and 6.5.2.

Also in this section

  • Stanford EE364a - Convex OptimizationStanford Engineering Everywhere · primary

    Follow lectures 1-9 and 15-16; use lecture 17 only for KKT systems. Leave full interior-point treatment for later.

  • D2L - Optimization AlgorithmsD2L authors · required

    Use the convexity, GD, SGD, minibatch, momentum, AdaGrad, RMSProp, Adam and scheduler sections for ML derivations and code.

  • Fundamentals of Numerical ComputationDriscoll & Braun · required

    Study §§1.1-1.4, 2.7-2.8, 3.2-3.4 and 4.2-4.3 for floating point, conditioning, stability, least squares and iteration error, in the Python edition.

  • PyTorch optimizer and gradient-clipping contractsPyTorch · reference

    Use AdamW's algorithm and clip_grad_norm_'s parameters to locate weight decay and clipping precisely. Inspect state_dict for optimizer restart; no network training is assigned.

  • SciPy minimize: BFGSSciPy · reference

    Read the BFGS method description and gtol, maxiter, c1 and c2 options. Supply an analytic gradient and compare residuals and evaluation counts, not just iterations.

  • PyTorch numerical type informationPyTorch · reference

    Read torch.finfo's eps, max and smallest_normal fields and its subnormal note; inspect float64, float32, float16 and bfloat16 on CPU.

  • The Accuracy of Floating Point SummationNicholas J. Higham · reference

    Read Section 2's recursive-sum error bound and Section 3's pairwise and compensated summation algorithms. Leave the statistical error models and historical machine details aside.

  • Accurately computing running varianceJohn D. Cook · support

    Read the Welford mean and centered-sum recurrences. Prove the centered-sum invariant and translate the recurrence to NumPy; skip the C++ class.