Quadratic programming


Quadratic programming is the process of solving a special type of mathematical optimization problem—specifically, a quadratic optimization problem, that is, the problem of optimizing a quadratic function of several variables subject to linear constraints on these variables. Quadratic programming is a particular type of nonlinear programming.

Problem formulation

The quadratic programming problem with variables and constraints can be formulated as follows.
Given:
the objective of quadratic programming is to find an -dimensional vector, that will
where denotes the vector transpose of. The notation means that every entry of the vector is less than or equal to the corresponding entry of the vector .
A related programming problem, quadratically constrained quadratic programming, can be posed by adding quadratic constraints on the variables.

Solution methods

For general problems a variety of methods are commonly used, including
In the case in which Q is positive definite, the problem is a special case of the more general field of convex optimization.

Equality constraints

Quadratic programming is particularly simple when Q is positive definite and there are only equality constraints; specifically, the solution process is linear. By using Lagrange multipliers and seeking the extremum of the Lagrangian, it may be readily shown that the solution to the equality constrained problem
is given by the linear system
where is a set of Lagrange multipliers which come out of the solution alongside.
The easiest means of approaching this system is direct solution, which for small problems is very practical. For large problems, the system poses some unusual difficulties, most notably that the problem is never positive definite, making it potentially very difficult to find a good numeric approach, and there are many approaches to choose from dependent on the problem.
If the constraints don't couple the variables too tightly, a relatively simple attack is to change the variables so that constraints are unconditionally satisfied. For example, suppose . Looking at the constraint equations:
introduce a new variable defined by
where has dimension of minus the number of constraints. Then
and if is chosen so that the constraint equation will be always satisfied. Finding such entails finding the null space of, which is more or less simple depending on the structure of. Substituting into the quadratic form gives an unconstrained minimization problem:
the solution of which is given by:
Under certain conditions on, the reduced matrix will be positive definite. It is possible to write a variation on the conjugate gradient method which avoids the explicit calculation of.

Lagrangian duality

The Lagrangian dual of a QP is also a QP. To see that let us focus on the case where and Q is positive definite. We write the Lagrangian function as
Defining the dual function as, we find an infimum of, using and positive-definiteness of Q:
Hence the dual function is
and so the Lagrangian dual of the QP is
Besides the Lagrangian duality theory, there are other duality pairings.

Complexity

For positive definite Q, the ellipsoid method solves the problem in polynomial time. If, on the other hand, Q is indefinite, then the problem is NP-hard. In fact, even if Q has only one negative eigenvalue, the problem is NP-hard.

Integer constraints

There are some situations where one or more elements of the vector will need to take on integer values. This leads to the formulation of a mixed-integer quadratic programming problem. Applications of MIQP include water resources and the construction of index funds.

Solvers and scripting (programming) languages

NameBrief info
AIMMSA software system for modeling and solving optimization and scheduling-type problems
ALGLIBDual licensed numerical library.
AMPLA popular modeling language for large-scale mathematical optimization.
APMonitorModeling and optimization suite for LP, QP, NLP, MILP, MINLP, and DAE systems in MATLAB and Python.
CGALAn open source computational geometry package which includes a quadratic programming solver.
CPLEXPopular solver with an API. Free for academics.
Excel Solver FunctionA nonlinear solver adjusted to spreadsheets in which function evaluations are based on the recalculating cells. Basic version available as a standard add-on for Excel.
GAMSA high-level modeling system for mathematical optimization
GurobiSolver with parallel algorithms for large-scale linear programs, quadratic programs and mixed-integer programs. Free for academic use.
IMSLA set of mathematical and statistical functions that programmers can embed into their software applications.
IPOPTIpopt is a software package for large-scale nonlinear optimization
Artelys KnitroAn Integrated Package for Nonlinear Optimization
MapleGeneral-purpose programming language for mathematics. Solving a quadratic problem in Maple is accomplished via its command.
MATLABA general-purpose and matrix-oriented programming-language for numerical computing. Quadratic programming in MATLAB requires the Optimization Toolbox in addition to the base MATLAB product
MathematicaA general-purpose programming-language for mathematics, including symbolic and numerical capabilities.
MOSEKA solver for large scale optimization with API for several languages
NAG Numerical LibraryA collection of mathematical and statistical routines developed by the Numerical Algorithms Group for multiple programming languages and packages. The Optimization chapter of the NAG Library includes routines for quadratic programming problems with both sparse and non-sparse linear constraint matrices, together with routines for the optimization of linear, nonlinear, sums of squares of linear or nonlinear functions with nonlinear, bounded or no constraints. The NAG Library has routines for both local and global optimization, and for continuous or integer problems.
GNU OctaveA free general-purpose and matrix-oriented programming-language for numerical computing, similar to MATLAB. Quadratic programming in GNU Octave is available via its command
R GPL licensed universal cross-platform statistical computation framework.
SAS/ORA suite of solvers for Linear, Integer, Nonlinear, Derivative-Free, Network, Combinatorial and Constraint Optimization; the Algebraic modeling language OPTMODEL; and a variety of vertical solutions aimed at specific problems/markets, all of which are fully integrated with the SAS System.
TK SolverMathematical modeling and problem solving software system based on a declarative, rule-based language, commercialized by Universal Technical Systems, Inc..
TOMLABSupports global optimization, integer programming, all types of least squares, linear, quadratic and unconstrained programming for MATLAB. TOMLAB supports solvers like Gurobi, CPLEX, SNOPT and KNITRO.
XPRESSSolver for large-scale linear programs, quadratic programs, general nonlinear and mixed-integer programs. Has API for several programming languages, also has a modelling language Mosel and works with AMPL, GAMS. Free for academic use.