# sosmodel

sosmodel derives the semidefinite program used to compute a sum-of-squares decomposition, without solving it.

### Syntax

```
[F,obj,m] = sosmodel(Constraints,Objective,options,decisionvariables)
```

### Examples

The following example sets up the SDP required to find a lower bound of a polynomial, using sum-of-squares. The last output contains the monomials YALMIP uses in the decomposition. To make it easier to see the connection between the polynomial and the derived decomposition, we turn off a scaling feature. YALMIP has introduced 1 new variable, i.e., there is a degree-of-freedom in a sum-of-squares representation of a quartic.

```
sdpvar x t
p = 8*x^4+x+5;
Model = [sos(p-t)];
[F,objective,monomials] = sosmodel(Model,-t,sdpsettings('sos.scale',0),t);
sdisplay(sdpvar(F(1)))
ans =
'5-t' '0.5' '-0.4472*internal(1)'
'0.5' '0.8944*internal(1)' '0'
'-0.4472*internal(1)' '0' '8'
sdisplay(monomials{1})
ans =
'1'
'x'
'x^2'
```

The optimization problem can be solved or manipulated as any other model.

```
optimize(F,objective)
```

Note that YALMIP by default derives an image model (dual form) for sum-of-squares programs when sosmodel is used, in contrast to a kernel model (primal form) used by default in solvesos. With this, we can be assured that the resulting model is expressed in terms of the original variables and possibly new additional variables, in contrast to a primal form where all original variables are lost. If you want to have a primal form (which typically has better computational properties), you have to set **sos.model** to 1 in an options structure.

## Leave a Comment