Write Constraints for Problem-Based Cone Programming - MATLAB & Simulink (original) (raw)
To ensure that solve
or prob2struct
callsconeprog
for a second-order cone problem, specify the second-order cone constraints as one of two types:
norm(linear expression) + constant <= linear expression
sqrt(sum of squares) + constant <= linear expression
Here, linear expression
means a linear expression in the optimization variables. sum of squares
means a sum of explicit squares of optimization variables, such as sum(x.^2)
. The objective function for coneprog
must be linear in the optimization variables. For more information on the sum of squares form, see Write Objective Function for Problem-Based Least Squares.
solve
and prob2struct
also callconeprog
when the constraint type has an equivalent form to the two listed:
linear expression >= sqrt(sum of squares) + constant
linear expression >= norm(linear expression) + constant
const*norm(linear expression) + constant <= linear expression
providedconst > 0
(sum of squares)^0.5
instead ofsqrt(sum of squares)
For example, coneprog
is the default solver for each of the following two equivalent problem formulations when you callsolve
.
x = optimvar('x',3,... 'LowerBound',[-Inf,-Inf,0],... 'UpperBound',[Inf,Inf,2]); A = diag([1,1/2,0]); d = [0;0;1]; f = [-1,-2,0]; probnorm = optimproblem('Objective',fx); probsumsq = optimproblem('Objective',fx);
consnorm = norm(A*x) <= d'x; probnorm.Constraints.consnorm = consnorm; conssumsq = sqrt(sum((Ax).^2)) <= dot(d,x); probsumsq.Constraints.conssumsq = conssumsq;
optnorm = optimoptions(probnorm); class(optnorm)
ans =
'optim.options.ConeprogOptions
optsumsq = optimoptions(probsumsq); class(optsumsq)
ans =
'optim.options.ConeprogOptions
If you write the second-order constraints differently, such as the mathematically equivalent sqrt(x'*x)
, solve
calls a different solver, such as fmincon
. In this case, you need to supplysolve
with an initial point, and the solution process can be different (and often is less efficient), as in the following example.
x = optimvar('x',3,... 'LowerBound',[-Inf,-Inf,0],... 'UpperBound',[Inf,Inf,2]); A = diag([1,1/2,0]); d = [0;0;1]; f = [-1,-2,0]; prob = optimproblem('Objective',f*x); cons = sqrt(x'*A'Ax) <= d'*x; prob.Constraints.cons = cons; opt = optimoptions(prob); class(opt)
ans =
'optim.options.Fmincon'
See Also
coneprog | solve | prob2struct