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
,
possibly subject to bounds and linear constraints. coneprog
solves problems in the form
such that
,
possibly subject to bounds and linear constraints.
To convert a quadratic program to coneprog
form, first calculate the matrix square root of the matrix . Assuming that 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,
.
Modify the form of the quadratic program as follows:
where satisfies the constraint
.
Extend the control variable to , which includes as its last element:
.
Extend the second-order cone constraint matrices and vectors as follows:
.
Extend the coefficient vector as well:
.
In terms of the new variables, the quadratic programming problem becomes
where
.
This quadratic constraint becomes a cone constraint through the following calculation, which uses the earlier definitions of , , and :
But . So, recalling that and the definition of , the inequality becomes
.
The quadratic program has the same solution as the corresponding cone program. The only difference is the added term 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 is positive, or plus 1/2 when is negative.
disp([fqp-sign(2*u(end)+1)*1/2 fval])
-33.0000 -33.0000
See Also
quadprog
| coneprog
| secondordercone