compilesos with optimizer

37 views
Skip to first unread message

Matanya Horowitz

unread,
Dec 3, 2014, 9:26:08 PM12/3/14
to yal...@googlegroups.com
Hello there,
I'm stuck on a problem when using compilesos with the optimizer for a particular problem of mine. The purpose of the optimization itself won't make much sense, it's stripped down from a much larger problem.

I would like to solve the following trivial problem. When using solvesos, everything works properly and as expected. However, when I do "OPTION 2", which would compile it (with a dummy argument called foo), the solver says the problem is dual infeasible, and the polynomial I extract is full of NaN.

x = sdpvar(1,1);
y
= sdpvar(1,1);
gam
= sdpvar(1,1);

[p,cp] = polynomial([x y],6);

cons
= [sos( p )];
cons
= [cons, sos(gam-p)];

ops
= sdpsettings('solver','sdpt3','verbose',2, 'sdpt3.maxit', 100);


%OPTION 1

% solvesos(cons, gam, ops, [cp; gam]);

%OPTION 2

foo
= sdpvar(1,1);
[FC, objC, monoms, etc] = compilesos(cons,gam+foo, ops, [cp; gam; foo]);
opti
= optimizer(FC, objC, ops, foo, cp);

opti
{0}

I must be making a mistake in my calls to compilesos and optimizer. Any help would be much appreciated, this is a fantastic feature for my application.

Johan Löfberg

unread,
Dec 4, 2014, 2:10:29 AM12/4/14
to
You must use an image model (parametrization in dual) when you use compilesos (model 1, kernel model, requires reconstruction of solution from the primal, which isn't done when you use optimizer)

...'sos.model',2...


Johan Löfberg

unread,
Dec 4, 2014, 2:20:21 AM12/4/14
to yal...@googlegroups.com
BTW, the following works too

opti = optimizer(cons, gam+foo, ops, foo, cp);

YALMIP will automatically force the option sos.model to the required value. YALMIP will also define gam,foo and cp as parameters in the sos problem when calling compilesos (as they appear in non-sos constraints and/or the objective and/or as input parameters or output variables)

Matanya Horowitz

unread,
Dec 4, 2014, 2:47:56 PM12/4/14
to yal...@googlegroups.com
Very helpful, thank you
Reply all
Reply to author
Forward
0 new messages