not forming output matrix

12 views
Skip to first unread message

ykiran reddy

unread,
Mar 8, 2015, 11:03:16 PM3/8/15
to yal...@googlegroups.com
the below program is showing the answer of the final output... it is not showing all the outputs in matrix form ...so i was not able to plot it ...please reply as soon as possible

clc
sdpvar p1 p2
opj=6 * p2 + 0.04 * p2^2 +12 + 8 * p1 + 0.024 * p1^2 + 80;
for h= [75:100]
C=[p1+p2==h ;20<=p1<=100;20<=p2<=100];
ops=sdpsettings('solver','quadprog');
optimize(C,opj,ops)
end
waste.m

Johan Löfberg

unread,
Mar 9, 2015, 2:35:40 AM3/9/15
to yal...@googlegroups.com
What do you want to have in matrix format? The solution after you run optimize is given by value([p1;p2])

http://users.isy.liu.se/johanl/yalmip/pmwiki.php?n=Tutorials.Basics

Johan Löfberg

unread,
Mar 9, 2015, 2:40:26 AM3/9/15
to yal...@googlegroups.com
I guess you want to study the optimal solution as a function of h

P = [];

ops=sdpsettings('solver','quadprog');
for h= [75:100]
    C
=[p1+p2==h ;20<=p1<=100;20<=p2<=100];

    optimize
(C,opj,ops)
    P
= [P;value([p1;p2])];
end
plot
(P')

Or conveniently and more efficiently to reduce overhead
sdpvar h
Solver = optimizer([p1+p2==h ;20<=p1<=100;20<=p2<=100],opj,[],h,[p1;p2]);
P
= Solver{75:100};
plot
(P')

BTW, install a better QP solver than quadprog. It is pretty slow and unstable.
Reply all
Reply to author
Forward
0 new messages