Optimization · Module 8 of 10

Quadratic Programming and Penalty Methods

A quadratic objective with linear constraints is solved by one linear system, its KKT equations. When constraints are awkward, penalty and barrier methods fold them into the objective and solve a sequence of easier problems.

01

Readiness check

This module solves quadratic problems and penalises constraints. Tick only what you can do closed-notes.

  • Write the KKT stationarity condition.
  • Solve a small linear system.
  • Minimise a one-variable quadratic.
  • Recall a Lagrange multiplier as a shadow price.
  • Take a limit as a parameter grows large.
0 or 1 weak itemsContinue with this module.
2 weak itemsRevisit the KKT conditions in Module 6.
3 or more weak itemsRevisit linear programming in Module 7.
02

The core idea

An equality-constrained quadratic program is solved by one linear KKT system. Penalty and barrier methods handle general constraints by adding a term to the objective and solving a sequence of unconstrained problems.

QP: minimise ½xTGx + cTx s.t. Ax = bKKT: ∇f + ATλ = 0, Ax = bpenalty: minimise f + ½μ·(constraint)2

A quadratic program (QP) minimises a quadratic objective ½xTGx + cTx subject to linear constraints, the model behind least squares with constraints, portfolio design, and the subproblems of sequential quadratic programming. With equality constraints, the KKT conditions, stationarity of the Lagrangian and feasibility, are themselves linear, so the QP is solved by one linear system in the variables and multipliers together. General constraints, especially inequalities, are harder, and one powerful family avoids them altogether. The quadratic penalty method replaces the constrained problem by an unconstrained one, minimising f(x) + ½μ·c(x)2, where the penalty parameter μ punishes constraint violation; as μ grows the solution is driven onto the constraint. Barrier (interior-point) methods instead add a term that blows up at the boundary, keeping iterates strictly feasible. Both solve a sequence of unconstrained problems, and the augmented Lagrangian improves them by adding a multiplier estimate so μ need not go to infinity.

The skill works when: you write the QP's KKT system and solve it, or drive a penalty solution onto the constraint.
The skill breaks down when: the penalty parameter is pushed so high the subproblem becomes ill-conditioned.
The concept. The penalty method solves a sequence of unconstrained problems; as the penalty parameter grows, the minimiser is pushed toward satisfying the constraint exactly.
03

The skills, taught in order

Five skills build the QP, its KKT system, and the penalty and barrier reformulations.

8.1 The quadratic program

A QP minimises ½xTGx + cTx subject to linear constraints. When G is positive definite the objective is convex and the QP has a unique minimum. QPs are the workhorse subproblem of larger nonlinear solvers.

8.2 The KKT linear system

For an equality-constrained QP the KKT conditions are linear: Gx + c + ATλ = 0 together with Ax = b. Stacking them gives one linear system in x and λ, solved directly, no iteration needed for the convex case.

MethodHandlesIdea
KKT systemequality-constrained QPsolve one linear system
Quadratic penaltygeneral constraintsadd ½μ·c2 to f
Barrierinequality constraintsadd a term that blows up at the boundary
Augmented Lagrangiangeneral constraintspenalty plus a multiplier estimate

From an exact linear solve for a QP to sequential unconstrained methods for harder constraints.

8.3 The quadratic penalty method

The quadratic penalty method minimises f(x) + ½μ·c(x)2 for increasing μ. Each subproblem is unconstrained; as μ grows, violating the constraint becomes too costly, so the minimiser approaches the constrained optimum. The penalty is exact only in the limit.

8.4 Barrier and interior-point methods

Barrier methods add a term, such as −Σ log(−gi), that grows without bound as an inequality boundary is approached, keeping iterates strictly inside the feasible region. Reducing the barrier parameter traces a path to the optimum, the basis of modern interior-point solvers.

8.5 The augmented Lagrangian

The augmented Lagrangian adds a Lagrange-multiplier term to the penalty, minimising f + λTc + ½μ·c2 and updating λ each round. This lets the constraint be satisfied without driving μ to infinity, curing the ill-conditioning of the pure penalty method.

Engineering connection: penalty and barrier methods are how a solver enforces stress or displacement limits when they cannot be handled directly, and QPs are the inner step of the design optimisers in the next module.

04

Worked example 1: an equality-constrained QP by KKT

Minimise f(x, y) = x2 + y2 − 2x − 4y subject to x + y = 1. Solve the KKT linear system for the optimum and the multiplier.

Figure 1. The KKT conditions of an equality-constrained QP are linear, so stacking stationarity and feasibility gives a small linear system solved directly for the point and the multiplier.
  1. ProblemSolve the equality-constrained QP in Figure 1 by its KKT system.
  2. Given / findf = x2 + y2 − 2x − 4y, constraint x + y = 1. Find x, y, and λ.
  3. AssumptionsConvex QP (G = 2I positive definite), so the KKT point is the unique minimum.
  4. ModelStationarity ∇f + λ∇h = 0 with h = x + y − 1: 2x − 2 + λ = 0, 2y − 4 + λ = 0, x + y = 1.
  5. Equations2x − 2 + λ = 0, 2y − 4 + λ = 0x + y = 1
  6. SolveSubtracting the first two: 2x − 2y + 2 = 0, so x − y = −1. With x + y = 1: x = 0, y = 1. Then 2(0) − 2 + λ = 0 gives λ = 2. f = 0 + 1 − 0 − 4 = −3.
  7. CheckThe unconstrained minimum is (1, 2); the constraint pulls the solution to (0, 1) on the line x + y = 1, and the positive multiplier λ = 2 measures how binding it is.
  8. ConclusionThe QP optimum is (0, 1), f = −3, with multiplier 2, all from one linear solve. Equality-constrained QPs need no iteration.
Result. Optimum (0, 1), f = −3, multiplier λ = 2.
05

Worked example 2: the quadratic penalty method

Solve the constrained problem minimise f(x) = x2 subject to x = 1 by the quadratic penalty method. Minimise P(x, μ) = x2 + ½μ(x − 1)2 and show the solution approaches x = 1 as μ grows, at μ = 8 and μ = 98.

Figure 2. Each penalty subproblem has a closed-form minimiser x = μ/(2 + μ). As the penalty parameter rises, the solution climbs toward the constraint value x = 1.
  1. ProblemSolve the constrained problem in Figure 2 by the quadratic penalty method.
  2. Given / findMinimise x2 subject to x = 1. Find the penalty minimiser at μ = 8 and μ = 98.
  3. AssumptionsThe penalty subproblem is minimised exactly for each fixed μ.
  4. ModelP(x, μ) = x2 + ½μ(x − 1)2; set dP/dx = 0.
  5. EquationsdP/dx = 2x + μ(x − 1) = 0x(μ) = μ/(2 + μ)
  6. Solvex(μ) = μ/(2 + μ). At μ = 8: x = 8/10 = 0.8. At μ = 98: x = 98/100 = 0.98. As μ → ∞, x → 1, the constrained answer.
  7. CheckEach subproblem is unconstrained yet the sequence approaches x = 1, so the constraint is satisfied only in the limit. The pure penalty needs a large μ, which eventually ill-conditions the subproblem, the reason for the augmented Lagrangian.
  8. ConclusionThe penalty method converts a constrained problem into a sequence of unconstrained ones, whose solutions march onto the constraint as μ increases.
Result. x(8) = 0.8, x(98) = 0.98, approaching x = 1 as μ → ∞.
06

Misconceptions and diagnostics

MistakeSymptomDiagnostic questionCorrection
Iterating an equality QPSlow solve of a linear system"Are the KKT conditions linear?"Solve the KKT system directly.
Penalty exact at finite μConstraint slightly violated"Is the constraint met only in the limit?"The quadratic penalty is exact only as μ → ∞.
Pushing μ too highSubproblem ill-conditioned"Is the Hessian blowing up?"Use an augmented Lagrangian to bound μ.
Barrier iterate on the boundaryLog term undefined"Am I strictly feasible?"Barrier methods must stay inside the region.
07

Practice ladder

Level 1 · Direct skill

For the penalty P(x, μ) = x2 + ½μ(x − 1)2, find x at μ = 2.

Show answer

x = μ/(2 + μ) = 2/4 = 0.5.

Level 2 · Mixed concept

What μ gives x = 0.9 for that penalty?

Show answer

0.9 = μ/(2 + μ) ⇒ 0.9(2 + μ) = μ ⇒ 1.8 = 0.1μ ⇒ μ = 18.

Level 3 · Independent problem

Minimise x2 + y2 subject to x + y = 2 by the KKT system.

Show answer

2x + λ = 0, 2y + λ = 0, x + y = 2 ⇒ x = y = 1, λ = −2, f = 2.

Transfer task | Real engineering

A solver enforces a stress limit by penalising violation. Explain why the answer is slightly infeasible and how an augmented Lagrangian fixes it.

What good work looks like

A quadratic penalty satisfies the constraint only as μ → ∞, so at finite μ the stress limit is slightly exceeded. The augmented Lagrangian adds a multiplier estimate, letting the constraint be met exactly at a moderate μ without ill-conditioning.

08

Working with AI, and proving it yourself

Use AI as an examiner, not a solver

"Check that my KKT system for this QP is set up correctly."
"Give me three penalty problems; I will find the minimiser for each μ."
"Solve the QP for me." Building and solving the KKT system is the skill.
"Why is the constraint violated?" Reasoning about the penalty limit is the point.

Portfolio task

Solve a small constrained problem two ways, by the KKT system and by a penalty sequence, and show both give the same optimum as the penalty grows.

Must include: a KKT solve, a penalty sequence, and a comparison of the two.
09

Retrieval and spaced review

Closed notes. Answer out loud, then reveal.

1. What is a quadratic program?

Minimising a quadratic objective subject to linear constraints.

2. How is an equality-constrained QP solved?

By solving its linear KKT system for the variables and multipliers.

3. What does the quadratic penalty method minimise?

f(x) + ½μ·c(x)2, for increasing μ.

4. How do barrier methods keep feasibility?

They add a term that grows without bound at the constraint boundary.

5. What does the augmented Lagrangian add?

A multiplier estimate, so the constraint is met without μ → ∞.

TodayFinish this quiz and Levels 1 and 2 of the ladder.
+1 dayRe-solve the QP and penalty examples from a blank page.
+3 daysSolve three new constrained problems by penalty.
+7 daysOptimise without gradients, Module 9.
+30 daysReuse penalty and barrier ideas when a solver enforces limits.
10

Textbook mapping

This module follows Nocedal and Wright, Numerical Optimization, 2nd edition. Use these references to read further.

Topic in this moduleWhere to read more
Quadratic programming and the KKT systemNocedal & Wright, Chapter 16
Penalty and barrier methodsNocedal & Wright, Chapter 17
The augmented LagrangianNocedal & Wright, Chapter 17

Chapter numbers refer to the 2nd edition. The QP and penalty methods are standard, so any recent edition will align closely.