Problem
The general 01quadratic (convex) programming model – called 01QP – contains n linear constraints and m binary variables and a quadratic convex objective function. It can be compactly formulated as follows (see [11]):
An even more compact formulation using matrix notation for the model is :
Solve this problem – x are unknowns, A, b, and c are given – with n = 15 and m = 15 with the following data:



The data given above specify the following explicit linear program:
Modeling Steps
A 01quadratic program (01QP) is a mathematical model that consists of a number (n ≥ 0) of linear inequalities in a number (m ≥ 0) of binary variables. Furthermore, it defines an quadratic convex objective function that is to be minimized or maximized. The 01QP model has many applications in quantitative decision making. The formulation of the model in LPL modeling language is straightforward and the notation is close to the mathematical notation using indices: First we define the two sets i and j. Then we declare and assign the data as parameters A, c, b, and a semidefinite positive (SDP) matrix Q. The variable vector x is declared, and finally the constraints R and the minimizing objective function obj.
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.) Note that the unique difference within this model and the QP model (see exampqp) consists of the word binary in declaration of the variables.
model Qp15_01 "A 01Quadratic 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
binary 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 model has the following solution:

The optimal value of the objective function is:

Further Comments
Interesting applications for the iQP model come from portfolio theory. Especially, if we want to limit the number of assets in a portfolio we must use 01 variables. An applications come from clustering problems. An example is bill035.