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