Main Content

To ensure that `solve`

or `prob2struct`

calls
`coneprog`

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 call
`coneprog`

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`

provided`const > 0`

`(sum of squares)^0.5`

instead of`sqrt(sum of squares)`

For example, `coneprog`

is the default solver for each of the
following two equivalent problem formulations when you call
`solve`

.

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',f*x); probsumsq = optimproblem('Objective',f*x); consnorm = norm(A*x) <= d'*x; probnorm.Constraints.consnorm = consnorm; conssumsq = sqrt(sum((A*x).^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 supply
`solve`

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'*A*x) <= d'*x; prob.Constraints.cons = cons; opt = optimoptions(prob); class(opt)

ans = 'optim.options.Fmincon'

`coneprog`

| `prob2struct`

| `solve`