Main Content

Convert Quadratic Programming Problem to Second-Order Cone Program

This example show how to convert a positive semidefinite quadratic programming problem to the second-order cone form used by the coneprog solver. A quadratic programming problem has the form

minx12xTHx+fTx,

possibly subject to bounds and linear constraints. coneprog solves problems in the form

minxfscTx

such that

Ascx-bscdscTx-γ,

possibly subject to bounds and linear constraints.

To convert a quadratic program to coneprog form, first calculate the matrix square root of the matrix H. Assuming that H is a symmetric positive semidefinite matrix, the command

A = sqrtm(H);

returns a positive semidefinite matrix A such that A'*A = A*A = H. Therefore,

xTHx=xTATAx=(Ax)TAx=Ax2.

Modify the form of the quadratic program as follows:

minx12xTHx+fTx=-12+minx,t[(t+1/2)+fTx]

where t satisfies the constraint

t+1/212xTHx.

Extend the control variable x to u, which includes t as its last element:

u=[xt].

Extend the second-order cone constraint matrices and vectors as follows:

Asc=[A001]

bsc=[00]

dsc=[001]

γ=-1.

Extend the coefficient vector f as well:

fsc=[f1].

In terms of the new variables, the quadratic programming problem becomes

minu12uTAsc2u+fscTu=-1/2+minu[1/2+fscTu]

where

u(end)+1/212uTAscu.

This quadratic constraint becomes a cone constraint through the following calculation, which uses the earlier definitions of Asc, dsc, and γ:

12Hx2=12uTAsc2ut+12

Hx22t+1

Hx2+t2t2+2t+1=(t+1)2

Hx2+t2|t+1|=±(t+1)

But Hx2+t2=Ascu2. So, recalling that γ=-1 and the definition of dsc, the inequality becomes

Ascu±(t-γ)

Ascu±(dscTu-γ).

The quadratic program has the same solution as the corresponding cone program. The only difference is the added term -1/2 in the cone program.

Numerical Example

The quadprog documentation gives this example.

H = [1,-1,1
    -1,2,-2
    1,-2,4];
f = [-7;-12;-15];
lb = zeros(3,1);
ub = ones(size(lb));
Aineq = [1,1,1];
bineq = 3;
[xqp fqp] = quadprog(H,f,Aineq,bineq,[],[],lb,ub)
Minimum found that satisfies the constraints.

Optimization completed because the objective function is non-decreasing in 
feasible directions, to within the value of the optimality tolerance,
and constraints are satisfied to within the value of the constraint tolerance.
xqp = 3×1

    1.0000
    1.0000
    1.0000

fqp = -32.5000

Referring to the description at the beginning of this example, specify the second-order cone constraint variables, and then call the coneprog function.

Asc = sqrtm(H);
Asc((end+1),(end+1)) = 1;
d = [zeros(size(f(:)));1];
gamma = -1;
b = zeros(size(d));
qp = secondordercone(Asc,b,d,gamma);
Aq = Aineq;
Aq(:,(end+1)) = 0;
lb(end+1) = -Inf;
ub(end+1) = Inf;
[u,fval,eflag] = coneprog([f(:);1],qp,Aq,bineq,[],[],lb,ub)
Optimal solution found.
u = 4×1

    1.0000
    1.0000
    1.0000
    1.0000

fval = -33.0000
eflag = 1

The first three elements of the cone solution u are equal to the elements of the quadratic programming solution xqp, to display precision:

disp([xqp,u(1:(end-1))])
    1.0000    1.0000
    1.0000    1.0000
    1.0000    1.0000

The returned quadratic function value fqp is the returned cone value minus 1/2 when 2t+1 is positive, or plus 1/2 when 2t+1 is negative.

disp([fqp-sign(2*u(end)+1)*1/2 fval])
  -33.0000  -33.0000

See Also

| |

Related Topics