yalmip detecting linear SDP problem as bilinear SDP Problem

51 views
Skip to first unread message

Muhammad Ali Murtaza

unread,
Jan 20, 2019, 3:43:02 PM1/20/19
to YALMIP
Hi Professor Johan,

The problem I am working on involves system dynamics of the following form:

x1 = x2;
x2 = x4;
x3 = ( 1/f1(x) ) * g1(x);
x4 = ( 1/f2(x) ) * g2(x);

f1,g1, f2 and g2 problem do involves sin and cosine. I also have a symmetric positive definite matrix P, whose value is given.

I do have a candidate Lyapunov function V(x) = x'Px, which is supposed as fixed for the problem

I have to solve the following optimization problem:

objective []
subject to

-V_dot + constant_c1 + L(x)(V(x) - constant_c1) is sos

The decision variable are coefficients of L(x) and u, which appears in V_dot.

Because of the the structure of my problem and sine and cosine function, I have to introduce an additional constraint.


clear
close all;

%all constants
m = 2;
M = 0.5*2;
l = 0.8;
g =9.8;
Cd = 0.5;

I = 26;
Iw = 0.005*2;
R = 0.25;

P =[395.648029781184,8003.90030531997,899.596510954508,10591.1321212639;8003.90030531998,479751.385515800,52850.9555041087,630641.794725162;899.596510954509,52850.9555041088,5953.04187871333,69562.0418672153;10591.1321212639,630641.794725162,69562.0418672153,830293.159311394];

x = [0;0;0;0];
const = 0;

sdpvar x1 x2 x3 x4 c1 s1 u t1;
 
tau_fric = -2*(Cd/R)*(x3/R - x4);

detM = ((M+m)*R + Iw/R)*(m*l^2+I) - R*m^2*l^2*c1^2;
 
f3 = (1/t1)*( (m*l^2+I)*(u - tau_fric + m*R*l*x4^2*s1) + ...
   (-m*R*l*c1)*(-u + tau_fric + m*g*l*s1));

f4 = (1/t1)*( (-m*l*c1)*(u - tau_fric + m*R*l*x4^2*s1) + ...
    ((M+m)*R+Iw/R)*(-u + tau_fric + m*g*l*s1 ) );

f = [x3; x4; f3; f4];
 
veqconstraint = monolist([x1 x2 x3 x4 c1 s1],2);
%Generating monomial to satify Li(x)
vL_x =monolist([x1 x2 x3 x4 c1 s1],2);

%Generating monomial to satify cosine and sine constraint
c_eq = sdpvar(length(veqconstraint),1);
s1 = c_eq'*veqconstraint;
g1 = c1^2 + s1^2 - 1;   %Equality constraint for sine and cosine
   
%Generating monomial to satify cosine and sine constraint
c_L = sdpvar(length(vL_x),1);
L_x = c_L'*vL_x;
   
%Generating constraint model
    x_var = [x1;x2;x3;x4];
    V_x = [x1 x2 x3 x4]*P*[x1;x2;x3;x4];
    q = -jacobian(V_x,x_var)*f*t1;
    detM_val = replace(detM,c1,cos(x(2)));
    q = replace(q,t1,detM_val);
    q = replace(q,[x1;x2;x3;x4],[x(1);x(2);x(3);x(4)]);
 
    V_val = x'*P*x;
    Model = [sos(q + const + L_x*(V_val - const) +  s1*g1)];
    options = sdpsettings('solver', 'mosek');
    [sol,v,Q] = solvesos(Model,[],options,[c_eq;c_L;u])



It can be seen that the solve sos model has three constraints L(x), s1 and u which are all linear. But Yalmip discovers it as bilinear SDP.
I do have penlab installed and it tries to solve it through it. I am not sure what I am doing wrong.

Thanks

Muhammad Ali Murtaza

unread,
Jan 20, 2019, 5:13:47 PM1/20/19
to YALMIP
I also tried to replace following command in code above (5th last line)

q = replace(q,[x1;x2;x3;x4],[x(1);x(2);x(3);x(4)]);

with
q = replace(q,[x1;x2;x3;x4;c1;s1],[x(1);x(2);x(3);x(4);cos(x(2); sin(x(2))]);

and It give me the following error
Second arguments must be linear

Its only gone if I remove s1 and sin(x(2)) from it. However even if I remove it, it still treats the problem as bilinear SDP.

Johan Löfberg

unread,
Jan 21, 2019, 7:06:52 AM1/21/19
to YALMIP
you cannot use cos(x) etc. The whole idea is that you replace cos(x) with c and sin(x) with s, and explain that these are cos/sin terms by performing the SOS decompisition over c^2 + s^2 = 1 (which is an outer approximation of the true model)

Muhammad Ali Murtaza

unread,
Jan 21, 2019, 10:06:43 AM1/21/19
to YALMIP
Hi Professor Johan,

Thank you for response. That is what I am doing. I introduce constraint g1 = c1^2 + s1^2 - 1; and c_eq are coefficient of polynomial for equality constraint. c_L are coefficient of L(x) and u is also variable which appears in v_dot.

I did substitute values of cos(x) in v_dot using replace command to make it fix.

So optimization should take place on the following form

(constant_term1 * u + constant2 + L_x * ( constant_term3 - constrant4 ) + s1*g1);

It was supposed to be linear SDP problem but yalmip is detecting it as a bilinear SDP problem.

When my program is showing all constant to be having the form double but yalmip thinks it as bilinear SDP.

If you remove options with [], you will see that yalmip is detecting it as a bilinear SDP problem.

Johan Löfberg

unread,
Jan 21, 2019, 11:35:55 AM1/21/19
to YALMIP
detM_val = replace(detM,c1,cos(x(2))); term,. As far as I can tell, you will have a cos(x(2)) term in the final expression, and YALMIP does not support trigonometric functions of the variable which the sos is performed on. It has to be purely polynomial. cos(x) will confuse YALMIP and it will think it is a parameter, thus leading to nonlinear parameterzation. You seem to have misunderstood the idea of outer approimating trigonometric functions in SOS

For instance, if you want to find a lower bound on x^2+x*cos(x)+sin(x), you would solve
sdpvar x c s t
p = x^2 + x*c + s;
[m,coeff] = polynomial([x;s;c],2);
solvesos(sos(p - m*(c^2+s^2-1)-t),-t,[],[t;coeff])


Muhammad Ali Murtaza

unread,
Jan 21, 2019, 1:12:54 PM1/21/19
to YALMIP
Thank you Professor Johan. I did help me address the problem.
Reply all
Reply to author
Forward
0 new messages