Problem
The general quadratic programming model – called QP – consists of m linear constraints, n variables and a quadratic convex objective function f(x). It can be compactly formulated as follows:
An more compact formulation using matrix notation for the model is as follows:
The objective function f the constraints g_{i}, and X (in the general format) are as follows:
Note that the matrix Q must be semidefinite positive (SDP), (that is: there exist a vector x such that xQx′≥ 0). In many applications the matrix Q is also symmetric (Q = Q^{T}).
If the matrix Q is not semidefinite positive then it cannot be solved as a convex problem and it must be considered as an nonlinear problem.
In the following, a concrete problem with random data for the two matrices A, Q and the two vectors b and c is specified (with n = 15 and m = 15):



Note that this matrix Q consisting of positive diagonal entries and zero otherwise is semidefinite positive.
The data given above specify the following explicit linear program:
Modeling Steps
The formulation of the model in LPL modeling language is straightforward and the notation is close to the mathematical notation using indices: First, the two sets i and j are defined. Then the data are declare and assigned as parameters A, c, b, and a semidefinite positive matrix Q. The variable vector x is declared, and finally the constraints R and the minimizing objective function obj are written.
Note that the data matrices A, b, c, and Q are generated using LPL’s own random generator. (To generate each time the same data, the code can also use the function SetRandomSeed(a) where a is an integer.)
model Qp15 "A Quadratic Convex Program";
set i := [1..15]; j,k := [1..15];
parameter A{i,j}:= Trunc(if(Rnd(0,1)<.25,Rnd(10,100)));
c{j} := Trunc(Rnd(10,100));
b{i} := Trunc(if(Rnd(0,1)<.15, Rnd(0,120)));
Q{j,k}:= Trunc(if(j=k, Rnd(5,20))); //SDP
variable x{j};
constraint R{i} : sum{j} A*x >= b;
minimize obj : sum{j} c*x + sum{j,k} x[j]*Q*x[k];
Writep(obj,x);
end
Solution
The small model defined above has the following optimal solution:

The optimal value of the objective function is:

Further Comments
There are interesting applications in Portfolio Theory for the quadratic convex problems. Especially, the Markowitz approach in portfolio models can be formulated as a QP model. For several implemented models see Casebook I. Other applications are robust optimization and chance constraint optimization, and much more.
Note that the constraints can also be quadratic, we then have a QPC model where the Q matrix must be semidefinite positive: