In the standard QP model we have an objective of the form min x'Qx,or in GAMS syntax:

sum((i,j), x(i)*Q(i,j)*x(j))

Now is such a quadratic form rather expensive for GAMS to generate and for an NLP solver under GAMS to solve. MINOS for instance, spends most of its time in the interpreter, which evaluates the non-linear functions and derivatives. (See the table below).

The idea we will try exploit here is to save on generation and interpretation time by observing that the expression x(1)*Q(1,2)*x(2) has the same valua as x(2)*Q(2,1)*x(1). I.e. the cross products corresponding to the non-diagonal elements of Q should rather be evaluated once as 2.0*x(i)*Q(i,j)*x(j), i>j.

Notice that the symmetry of Q is not even a requirement as we always can enforce this by setting:

Q'(i,j) = 0.5*(Q(i,j)+Q(j,i))

In the model we implemented this by carefully filling the Q' matrix:

Q'(i,j) = Q(i,j)+Q(j,i) for j>i
Q'(i,i) = Q(i,i)
Q'(i,j) = 0 for j<i

As in our case Q is symmetric we use for j>i:

Q'(i,j) = 2.0*Q(i,j) for j>i

If we compare the results between this model and model qp1.gms then we observe first that the size of the model in terms of rows, columns and non-zero elements has not changed. However the the generation time and the solution time have decreased significantly (approximately by a factor of two which can be explained as we only use now about half of the variance-covariance matrix).