Skip to first unread message

Sandeep Parameshwara

unread,
Dec 28, 2019, 9:49:44 AM12/28/19
to YALMIP
Hello members,

I am facing problems with optimization with an objective function. I have shared Matlab files. Please unzip and add  'LPVTools' to the path before running the programs. 
I need to evaluate my matrices, constraints at each point in grid 'rho'. 
My question here is all about how to use Optimize command. I am using 'optimize' in files 'ctrb_gram' and 'obsv_gram'. My 'objective' is obtained from the functions 'cost_ctrb' and 'cost_obsv' respectively. I want to 'minimize the sum of the trace of the product of two matrices over grid points'. 
When I tried to directly call 'cost_ctrb' or 'cost_obsv' inside optimize command, I got the error message that 'solver is not applicable(sdpt 3-4)', problem -4. 
If I call the cost functions before using optimize command and pass that value to optimize, it runs successfully but I don't see any meaning in doing that since it's not optimizing anything at all! How can minimize my objective dynamically in my program? 
I hope I have put forth my doubt clearly, please feel free to ask me for any clarification. I also suspect that I might be doing this whole thing wrong. I look forward to your responses.

Q0=sdpvar(2*n, 2*n,'symmetric');
Q1
=sdpvar(2*n, 2*n,'symmetric');
Q2
=sdpvar(2*n, 2*n,'symmetric');
Q
=@(rho) Q0 + Q1*sin(rho) + Q2*cos(rho);
dQ
=@(rho) 0 + Q1*cos(rho) - Q2*sin(rho);


P0=sdpvar(2*n, 2*n,'symmetric');
P1
=sdpvar(2*n, 2*n,'symmetric');
P2
=sdpvar(2*n, 2*n,'symmetric');
P
=@(rho) P0 + P1*sin(rho) + P2*cos(rho);
dP
=@(rho) 0 + P1*cos(rho) - P2*sin(rho);


My constraints are:
P(rho)>0
Q
(rho)>0
rate
*dQ(rho)+(A_rho'*Q(rho))+(Q(rho)*A_rho)+C_rho'*C_rho)<0;
-rate*dP(rho))+(A_rho*P(rho))+(P(rho)*A_rho')+(B_rho*B_rho<0;

I need to solve for P and Q while minimizing
trace(P(rho)*Q(rho))


my solver settings are
sdpoptions=sdpsettings('solver','sdpt3','debug',1);

When I run 
 sum_obsv=cost_obsv(P,Q,rho_grid,k,no);
  J
(k)=sum_obsv;   % J is an array
  diagnostic_obsv
= optimize(LMIConstraints_obsv,J(k),sdpoptions);

it returns that 'successfully solved (SDPT3-4)'. However when I run
diagnostic_ctrb = optimize(LMIConstraints_ctrb,cost_ctrb(P,Q,rho_grid),sdpoptions)   %or
diagnostic_obsv
= optimize(LMIConstraints_obsv,cost_obsv(P,Q,rho_grid),sdpoptions)
it tells me that 'solver not applicable 'sdpt 3-4'. How can I minimize my objective dynamically in my program?
Thank you
Sandeep

LPVTools.zip
cost_ctrb.m
cost_obsv.m
ctrb_gram.m
mass_spring_damper_main.m
obsv_gram.m
sys_eqns.m

Johan Löfberg

unread,
Dec 28, 2019, 10:02:30 AM12/28/19
to YALMIP
>> mass_spring_damper_main
Undefined function or variable 'pgrid'.
Error in mass_spring_damper_main (line 5)
rho=pgrid('rho',-1:0.2:1,rho_dot); 


however, you talk about a product of two matrices. if those both contain decision variables you will get a nonconvex objective and you have no solver

Sandeep Parameshwara

unread,
Dec 28, 2019, 10:06:13 AM12/28/19
to YALMIP
Hello professor,
'pgrid' is function from 'LPVtools', I have attached a zip file for LPV tools. It should run fine when you add unzipped LPVTools to the path. Also, I am keeping either P or Q fixed and optimizing only one matrix hence I hope my objective function is convex.

Johan Löfberg

unread,
Dec 28, 2019, 10:08:51 AM12/28/19
to YALMIP
copied the wrong error message, it is

>> mass_spring_damper_main
Undefined function or variable 'csize'.
Error in rgrid/size (line 490)
            varargout = csize(out,arg2,nargin,nargout);
Error in pmat/isvalid (line 91)
                szDomain = size(obj.DomainPrivate);
Error in pmat (line 72)
                [pflag,errstr] = isvalid(obj);
Error in pmat (line 56)
                obj = pmat(DataPrivate,Domain);
Error in switchyard (line 18)
    A = pmat(A);
Error in pmat/binop (line 23)
   [A,B]=switchyard(A,B);
Error in  *  (line 11)
out = binop(A,B,'mtimes');
Error in mass_spring_damper_main (line 9)
    k(i)=k0+rho*krho; 

Sandeep Parameshwara

unread,
Dec 28, 2019, 10:09:48 AM12/28/19
to YALMIP
Slight change, please change the path to the unzipped folder and run "addlpv.m". This will add required paths to your Matlab installation

Johan Löfberg

unread,
Dec 28, 2019, 10:15:16 AM12/28/19
to YALMIP
It's in my path as you can see from my run

You should check where csize is located in case it uses a non-standard toolbox, since that is the missing file

Sandeep Parameshwara

unread,
Dec 28, 2019, 10:36:45 AM12/28/19
to YALMIP
professor, do you still see the problem after running addlpv.m? I am using just LPVTools, SDPT3 and YALMIP for my project and nothing else. 
LPVInstallatiom.PNG

Sandeep Parameshwara

unread,
Dec 28, 2019, 10:38:36 AM12/28/19
to YALMIP
Also, System Requirements: MATLAB R2014b or later plus Control System Toolbox and Robust Control Toolbox.

Johan Löfberg

unread,
Dec 28, 2019, 11:05:08 AM12/28/19
to YALMIP
missed robust toolbox

ran your file mass_spring_damper_main and it runs without problems

Sandeep Parameshwara

unread,
Dec 28, 2019, 11:13:34 AM12/28/19
to YALMIP
My bad, I had forgotten to comment and uncomment some lines. could you please replace these two files and run them again? The files I had shared earlier were not optimizing anything at all even though running successfully. Sorry for the trouble, I request you to run with these two replaced files. This will print the error
ctrb_gram.m
obsv_gram.m

Johan Löfberg

unread,
Dec 28, 2019, 12:17:40 PM12/28/19
to YALMIP
You call ctrb_gram(sys,rho_grid,rho_dot,P,dP,Q,dQ,k,J) in which you create objective by cost_ctrb(P,Q,rho_grid), and in that, both P and Q functions of decision variables

>> P(1.1)
Linear matrix variable 6x6 (symmetric, real, 63 variables)
Eigenvalues between [2.7199,22.3001]
Coeffiecient range: 0.4536 to 1

K>> Q(.3)
Linear matrix variable 6x6 (symmetric, real, 63 variables)
Eigenvalues between [2.5978,22.7681]
Coeffiecient range: 0.29552 to 1

hence, the sum of P(rho)*Q(rho) will be bilinear, and thus you have a nonconvex SDP

Sandeep Parameshwara

unread,
Dec 28, 2019, 12:41:52 PM12/28/19
to YALMIP
Thank you, Professor. I now understand the problem and will rewrite the code. So by your comment, I understand that if I manage to keep either P or Q fixed and allow another one to be varied, I will get a convex objective which will solve my problem.

Johan Löfberg

unread,
Dec 28, 2019, 12:44:44 PM12/28/19
to YALMIP
if one of them is fixed, the products is clearly linear
Reply all
Reply to author
Forward
Message has been deleted
0 new messages