Quadratic Programming (QP)

Decision Sciences
Introduced by
Marguerite Frank & Philip Wolfe
Year
1956
Type
Constrained mathematical optimization
Family
Mathematical programming

What does it do?

Quadratic Programming (QP) is constrained optimization in which the objective function is quadratic and the constraints are linear.

Frank and Wolfe (1956) proposed an algorithm for quadratic programming, and the feasible-direction iteration shown below is a generic illustration of that style of method rather than a transcription of their procedure. QP is used in finance, machine learning and engineering design wherever a quadratic cost must be minimized under linear feasibility conditions. When Q is positive semi-definite the problem is convex, and a point satisfying the optimality conditions is a global minimizer.

The intuition behind the method

Think of QP as finding the lowest point of a bowl-shaped surface while staying inside a polygon-shaped region defined by linear constraints. For convex QP with a non-empty feasible region, every local minimum is global; the minimizer is unique when the objective is strictly convex on the feasible set. The iterative method moves inside the feasible region, choosing a direction and a step length at each iteration. A small step does not prove that the solution has been reached: progress can also stall at a non-optimal boundary point, so optimality must be checked separately.

History

Frank and Wolfe (1956), 'An algorithm for quadratic programming', published in Naval Research Logistics Quarterly, is the reference for this entry. It is the origin of the feasible-direction approach now known as the Frank-Wolfe method. Quadratic programming later became a standard tool in portfolio selection, support vector machine training and control.

When to use it

Choose QP when the objective is genuinely quadratic, for example in variance minimization, least-squares fitting with constraints, or margin maximization in support vector machines, and the constraints are linear. If Q is positive semi-definite, the problem is convex and a global optimum is attainable; if Q is indefinite, the problem is non-convex and global solution generally requires specialized methods such as branch-and-bound. Do not use QP when the objective is linear, where linear programming is the simpler model, or when the constraints are themselves quadratic or matrix-valued, where second-order cone or semidefinite programming is more suitable. Problem size, the sparsity of Q, and the solver available (OSQP, Gurobi, CPLEX, quadprog) should guide the implementation choice.

Limitations and considerations

  • Non-convex QP, where Q has negative eigenvalues, is NP-hard in the general case, so typical local methods cannot guarantee a global minimum.
  • A dense Q matrix requires storage that grows with the square of the number of variables, so large problems depend on sparse structure to remain tractable.
  • Nearly singular Q or nearly redundant constraints can cause numerical instability in the linear algebra inside the solver.
  • The basic feasible-direction iteration can converge slowly near the optimum, where successive directions tend to zigzag; this is one reason interior-point and active-set solvers are common in practice.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • When Q is positive semi-definite, every local minimum is global, so the output of a convex QP solve does not require a multistart search to be interpreted as a global optimum.
  • When d_k'Q d_k > 0, the one-dimensional step-size problem along a fixed direction has a closed-form solution, which keeps each line search cheap.
  • Linear equality and inequality constraints are handled directly, and their associated KKT multipliers are available from the solution.
  • Convex QP can be solved in polynomial time, and it models curvature, such as the variance in portfolio problems, that linear programming cannot represent.

Applications

  • Mean-variance portfolio optimization: minimize return variance subject to target return and budget constraints.
  • Support vector machine training: maximize the margin hyperplane formulated as a QP over Lagrange multipliers.
  • Model predictive control: compute actuator inputs that minimize a quadratic cost over a receding planning horizon.
  • Structural engineering: minimize elastic strain energy subject to stress and displacement constraints.
  • Least-squares regression with constraints: minimize residual sum of squares subject to bounds on coefficients.

How it works

How it works

1

The problem is written as minimizing (1/2)x'Qx + c'x subject to Ax ≤ b and x ≥ 0, where Q is the Hessian matrix of the quadratic objective. If Q is positive semi-definite, the problem is convex, and any local minimum is also a global minimum.

Formula
\min_{x} \frac{1}{2} x^\top Q x + c^\top x \quad \text{s.t.} \quad Ax \leq b,\; x \geq 0
2

At the current iterate x_k, a feasible-direction method chooses a direction d_k that decreases the objective while keeping the iterate feasible. In the classical Frank-Wolfe scheme, the linearized objective ∇f(x_k)'d is minimized over the feasible polytope, and the direction is the vector from x_k to that minimizer. The cone form shown in the formula (Ad ≤ 0 with ||d|| ≤ 1) is a simplified illustration, not the exact Frank-Wolfe subproblem, and it is only meaningful for the constraints active at x_k.

Formula
d_k = \arg\min_{d} \nabla f(x_k)^\top d \quad \text{s.t.} \quad A d \leq 0,\; \|d\| \leq 1
3

With d_k fixed, the step α_k in [0,1] is chosen to minimize f(x_k + α d_k). Along a fixed direction the objective is a one-variable quadratic in α, so when d_k'Q d_k > 0 this minimization can be carried out in closed form, with the result restricted to [0,1] when necessary.

Formula
\alpha_k = \arg\min_{\alpha \in [0,1]} f(x_k + \alpha\, d_k)
4

The iterate is updated to x_{k+1} = x_k + α_k d_k, which keeps it feasible provided the starting point x_0 is feasible and α_k lies in [0,1]. The loop stops when the step length ||x_{k+1} − x_k|| falls below the tolerance ε. This test measures the size of the last step and does not by itself certify optimality: a small step can occur at a non-optimal boundary point. A KKT or duality-gap check is needed before the result is accepted.

Formula
x_{k+1} = x_k + \alpha_k\, d_k; \quad \text{stop if } \|x_{k+1} - x_k\| < \varepsilon

Common pitfalls

  • Assuming convexity without checking that Q is positive semi-definite can lead to a local minimum being reported as if it were the global one.
  • With positive semi-definite but singular Q, the set of minimizers may be non-unique, so the reported solution can depend on the solver and starting point.
  • For linearly constrained QP the constraints satisfy a constraint qualification automatically, so the KKT conditions are necessary at a local minimizer; for convex QP they are also sufficient, but for non-convex Q they are not sufficient for global optimality.
  • Poor variable scaling produces an ill-conditioned Q and unreliable solver output, so data should be normalized before the QP is formulated.
  • The stopping rule based on ||x_{k+1} − x_k|| < ε can trigger on a small step far from the optimum, so optimality should be checked separately rather than inferred from step size.

Frequently asked questions

How does QP differ from linear programming?

In linear programming both the objective and the constraints are linear, so an optimum, if one exists, is attained at a vertex of the feasible polytope. In QP the objective is quadratic, so the optimum can lie in the interior of the feasible region. This allows QP to model variance, energy and margin problems that LP cannot, but it requires more specialized algorithms.

When does a QP problem have a unique global minimum?

If Q is strictly positive definite and the feasible region is non-empty, the minimum is unique. If Q is only positive semi-definite, every local minimum is still global, but the set of minimizers may contain many points, so the solution a solver reports may depend on the solver. If Q is indefinite, there may be several local minima, and finding the global one is generally NP-hard.

Which solver should I use for practical QP problems?

For small to medium dense problems, quadprog (available in MATLAB and R) is an accessible option. For large sparse convex problems, OSQP (open-source), Gurobi and CPLEX (commercial) are commonly used. General-purpose local solvers such as SLSQP in scipy.optimize.minimize handle nonlinear programs and return only a local minimum if Q is not positive semi-definite, so convexity should be verified before trusting the result. The choice depends on problem size, sparsity, real-time requirements and licensing.

Related methods

Sources

  1. Frank, M., & Wolfe, P. (1956). An algorithm for quadratic programming. Naval Research Logistics Quarterly, 3(1–2), 95–110.

    Open DOI reference