A question about writing the constraints in "decayrate.m"

22 views
Skip to first unread message

叶超天

unread,
Sep 24, 2014, 3:11:10 AM9/24/14
to yal...@googlegroups.com
I have to use the bisection method, and I found something useful in yalmip example "decayrate.m"
I find  that every time you are about to use solvesdp, you have to rewrite F, if you'v changed the  value of certain parameters in the constraint.
For example, in 'decayrate.m', 

t_upper = t_lower*2;
F = [P>=eye(2), A'*P+P*A <= -2*t_upper*P];
ops = sdpsettings('verbose',0,'warning',0);
sol = solvesdp(F,[],ops);
while ~(sol.problem==1)
    t_upper = t_upper*2;
    F = [P>=eye(2), A'*P+P*A <= -2*t_upper*P];
    sol = solvesdp(F,[],ops);
end 

If I comment the red part, the program will not work. 
There's no problem when F is short, but when F is very long, Repeating  F is boring and 
make the program hard to read. 
 
Is there any way to solve the problem?

Johan Löfberg

unread,
Sep 24, 2014, 4:10:28 AM9/24/14
to yal...@googlegroups.com
I don't understand how you can say that explicitly writing down the constraint in every iteration makes the code hard to read. In my opinion, it makes the code impossible to misunderstand.

However, if you want to avoid defining the model in every iteration, and just update some parameter in the model (t_upper here), you should use the optimizer framework, which is explained in the decay-rate example. Alternatively, create a function which defines all the constraints, for a particular value of some parameter.

叶超天

unread,
Sep 24, 2014, 4:28:36 AM9/24/14
to yal...@googlegroups.com
Thank you very much.
You present two ways to solve the problem.
But the optimizer framework you mentioned in the decay-rate example seems to repeat defining F every time before solving.

I prefer the second method. But I am not sure about writing this function correctly, because the special structure and meaning of F.
Would please provide me with an example based on 'decayrate.m'?

Johan Löfberg

unread,
Sep 24, 2014, 4:47:25 AM9/24/14
to yal...@googlegroups.com
Have you really read the Section "Faster code through optimizer"?
http://users.isy.liu.se/johanl/yalmip/pmwiki.php?n=Examples.DecayRate

叶超天

unread,
Sep 24, 2014, 5:02:45 AM9/24/14
to yal...@googlegroups.com
I printed the old version of all yalmip examples and collect them as a book. So I missed this updated material. I'll study this part. Thank you!
Message has been deleted
Message has been deleted

叶超天

unread,
Sep 24, 2014, 6:07:10 AM9/24/14
to yal...@googlegroups.com
phi=sdpvar(N,1);
psi=sdpvar(N,1);
sdpvar vm1 vm2 vm3 vm4 vm5 vm6 vs vt vn1 vn2 vn3 vn4 vn5 vn6
my wantedvariables are phi and psi

should I write: P = optimizer(Constraints,[],[],Parameters,phi,psi) ?

Johan Löfberg

unread,
Sep 24, 2014, 6:13:43 AM9/24/14
to yal...@googlegroups.com
Multiple parameters and output are either stacked in single vectors, or placed in cells, so either

 P = optimizer(Constraints,[],[],Parameters,[phi(:);psi(:)])

or

 P = optimizer(Constraints,[],[],Parameters,{phi,psi})

叶超天

unread,
Sep 24, 2014, 6:20:44 AM9/24/14
to yal...@googlegroups.com
Thank you very much!
Reply all
Reply to author
Forward
0 new messages