# SecondOrderConeConstraint

Second-order cone constraint object

Since R2020b

## Description

`SecondOrderConeConstraint` represents the second-order cone constraint

`$‖A\cdot x-b‖\le {d}^{T}\cdot x-\gamma$`
• The A matrix represents the linear factor of the cone.

• The b vector represents the center of the cone.

• The d vector represents a linear bound.

• The γ scalar represents a bound.

Solve problems with second-order cone constraints by using the `coneprog` function.

## Creation

Create a `SecondOrderConeConstraint` object by using the `secondordercone` function.

## Properties

expand all

Linear factor of the cone, specified as a real matrix.

Data Types: `double`

Center of the cone, specified as a real vector.

Data Types: `double`

Linear bound, specified as a real vector.

Data Types: `double`

Bound, specified as a real scalar. Smaller values of `gamma` correspond to looser constraints.

Data Types: `double`

## Examples

collapse all

To set up a problem with a second-order cone constraint, create a second-order cone constraint object.

```A = diag([1,1/2,0]); b = zeros(3,1); d = [0;0;1]; gamma = 0; socConstraints = secondordercone(A,b,d,gamma);```

Create an objective function vector.

`f = [-1,-2,0];`

The problem has no linear constraints. Create empty matrices for these constraints.

```Aineq = []; bineq = []; Aeq = []; beq = [];```

Set upper and lower bounds on `x(3)`.

```lb = [-Inf,-Inf,0]; ub = [Inf,Inf,2];```

Solve the problem by using the `coneprog` function.

`[x,fval] = coneprog(f,socConstraints,Aineq,bineq,Aeq,beq,lb,ub)`
```Optimal solution found. ```
```x = 3×1 0.4851 3.8806 2.0000 ```
```fval = -8.2462 ```

The solution component `x(3)` is at its upper bound. The cone constraint is active at the solution:

`norm(A*x-b) - d'*x % Near 0 when the constraint is active`
```ans = -2.5677e-08 ```

To set up a problem with several second-order cone constraints, create an array of constraint objects. To save time and memory, create the highest-index constraint first.

```A = diag([1,2,0]); b = zeros(3,1); d = [0;0;1]; gamma = -1; socConstraints(3) = secondordercone(A,b,d,gamma); A = diag([3,0,1]); d = [0;1;0]; socConstraints(2) = secondordercone(A,b,d,gamma); A = diag([0;1/2;1/2]); d = [1;0;0]; socConstraints(1) = secondordercone(A,b,d,gamma);```

Create the linear objective function vector.

`f = [-1;-2;-4];`

Solve the problem by using the `coneprog` function.

`[x,fval] = coneprog(f,socConstraints)`
```Optimal solution found. ```
```x = 3×1 0.4238 1.6477 2.3225 ```
```fval = -13.0089 ```

## Version History

Introduced in R2020b