A class of optimisation problems with a quadratic objective and linear (in)equality constraints. Convex QPs have unique global optima and efficient off-the-shelf solvers, which is why many ML problems work hard to be expressible in QP form — most notably the SVM primal.

Definition

A quadratic program has the form:

subject to:

where is symmetric, , , , and similarly for .

The QP is convex iff is positive semi-definite. Convex QPs are the well-behaved case: unique global optimum (assuming the feasible set is non-empty), no local minima to worry about, and a rich library of polynomial-time solvers.

Why QPs Matter

Three properties make convex QPs especially useful in ML:

  1. Global optima. Convexity guarantees that any local min is a global min. There is no “did we get stuck somewhere bad?” concern.
  2. Efficient solvers. Interior-point methods, active-set methods, and other algorithms solve QPs reliably in polynomial time. Implementations in CVXPY, CVXOPT, MOSEK, Gurobi, etc. accept the problem in standard form and return the optimum.
  3. Sparse active sets. At the optimum, only some of the inequality constraints are active (binding with equality). For SVMs, the active constraints are exactly the support vectors — a small fraction of the training set.

The SVM Primal Is a QP

The hard-margin SVM formulation is:

To match the standard QP form, let the unknown be . Then:

  • Objective: where is the identity in the block and zero in the entry.
  • Constraints: rewrites as for each — a linear inequality in .

is positive semi-definite (the block is identity, the entry is zero), the constraints are linear, so the SVM primal is a convex QP.

Convexity at a Glance

For :

ObjectiveOptimisation difficulty
Positive definiteStrictly convexEasy — unique global min
Positive semi-definiteConvex (possibly with flat directions)Easy — global min, may not be unique
Indefinite (mixed eigenvalues)Saddle-shapedNP-hard in general
Negative definiteStrictly concaveEasy — unique global max (so flip signs to use a min solver)

The SVM primal lives squarely in the “easy” zone. By contrast, generic non-convex quadratic programs (e.g., with indefinite) are NP-hard, and ML problems that can be expressed as them — such as discrete combinatorial relaxations — usually need approximation algorithms.

Active Constraints and Support Vectors

At the optimum of a constrained problem, each inequality constraint is either:

  • Active (binding): . The constraint is “pulling” on the solution.
  • Inactive (slack): . The constraint isn’t a barrier; the solution would be the same without it.

For SVMs, the constraint is active when — i.e., when is a support vector. The number of active constraints equals the number of support vectors, which is typically much smaller than . This sparsity is what makes the SVM solution structurally informative.

The Karush-Kuhn-Tucker (KKT) conditions characterise optimality of constrained QPs and are the formal vehicle for stating “support vectors are exactly the points with active constraints.” Treated in week 4 alongside the SVM dual.

Other QPs in ML

QPs appear in several other places besides SVMs:

  • Lasso (linear regression with regularisation) is a QP after introducing auxiliary variables.
  • Portfolio optimisation in quantitative finance.
  • Constrained least-squares problems with bounds or equality constraints.
  • Trust-region subproblems inside many nonlinear optimisers.
  • Quadratic discriminant analysis (some variants).

The pattern is general: any time you have a smooth quadratic objective and constraints describable by half-spaces, you have a QP.

Active Recall