yalmip / YALMIP

MATLAB toolbox for optimization modeling
https://yalmip.github.io/
Other
464 stars 134 forks source link

Warning: Solver not applicable (mosek does not support polynomial constraints) #1199

Closed JianqiangDing closed 1 year ago

JianqiangDing commented 1 year ago

Hi, I am new to yalmip, I am trying to use yalmip to solve a problem with sos constraints using mosek backend, but it failed. Am I wrong somewhere in modeling the problem? Here is the code,

yalmip('clear');

sdpvar u v d;

g0 = 1 - d^2;
g1 = 1 - u^2;

[s0, c0] = polynomial(d, 2);
[s1, c1] = polynomial(v, 2);

u0 = 1;

% minmize |u-u0|^2 - v (try to find optimal u and minimal v)
% s.t.
% constraint 0: 0+0*u+0*d-1*v >=0 on the set g0 >=0 (this constraint should hold for all d in [-1,1])
% constraint 1: g1 >= 0 (optimal u should in [-1,1])

F = [sos(0 + 0 * u + 0 * d -1 * v -s0 * g0), sos(s1 * g1), sos(s0), sos(s1)];
% F = [sos(0 + 0 * u + 0 * d -1 * v -s0 * g0), -1<=u<=1, sos(s0), sos(s1)];
ops = sdpsettings('solver', 'mosek', 'sos.newton', 1, 'sos.congruence', 1);
diag = optimize(F, (u - u0)' * (u - u0) - v, ops, [c0; c1; v; u]);

% check optimized result
if diag.problem == 0
    disp('Solver thinks it is feasible');
elseif diag.problem == 1
    disp('Solver thinks it is infeasible');
else
    disp('Something else happened');
end

Any suggestion would be helpful. :)

JianqiangDing commented 1 year ago

Another question, actually, I don't understand the meaning of this warning. can you explain a little bit to me what is the best way to construct sos constraints in general? and what condition triggers this warning?

johanlofberg commented 1 year ago

I think you completely misunderstood the point/use of sum-of-squares programming as this code makes no sense at all, to the point that I can hardly point at the specific errors as it is so messed up

Saying v<=0 when g(d)>=0 makes no sense when v is a parameter and d independent. It is either positive or negative, and since it has to be negative sometimes, it is thus known to be negative.

since u is a parameter, it makes no sense to model its constraints via sos constructs

I think you simply should not use sos, you are on the wrong track.

JianqiangDing commented 1 year ago

thank you for your kind response, I re-check yalmip docs relate to sos, you are right, I misunderstood what is parametric variables in a sos problem such that I provide a toy example makes no sense at all.

thank you for your time, sincerely.