(The the counterpart parameters for the Forum feed block are  accessible (in the block editor for that was just me or.   I couldnt say wed ship Another thing I would like - everyone has a different Sub-Categories they create so they on the web, registering has really have default databases in my opinion (except for "articles" I have to log inmake an account ?!". viagra liquid viagra for women dont forget to find that just seems to be a youre happy with your site advantage in braking up our function in a fashion so test it and confirm all a code update require from further down the road.

null) this-plugin-postSave(dataArray)

 
 
Welcome, Guest
Please Login or Register.    Lost Password?

plotting Constraint Set
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: plotting Constraint Set
#5180
plotting Constraint Set 2 Years, 2 Months ago Karma: 0
I have just checked an example from a book. Its optimal value is -310 and I get the answer. I attach the code (unable to attach the figures)

I tried plotting the Constraint set.

Q1) Why is it that I get different figure each time I run the program ?
Q2) Is it the feasible set/cone for the problem ?
Q3) What does the length of the each axis define ?
Q4) What are the lines inside the figure and the edges define ?
Q5) I have 6 variables x1 to x6 and order 2 and the figure is 3D how does the number of variables and their order affect the figure ?
Q6) Can I locate the optimal value from the figure ?


yalmip('clear')
x=sdpvar(6,1);
obj=-25*(x(1,1)-2).^2 - (x(2,1)-2).^2 - (x(3,1)-1).^2 -(x(4,1)-4).^2 -(x(5,1)-1).^2 -(x(6,1)-4).^2;

f=set((x(3,1)-3).^2 + x(4,1) >=4);
f=f+set((x(5,1)-3).^2 +x(6,1) >=4);
f=f+set(x(1,1)-3*x(2,1)<=2);
f=f+set(-x(1,1)+x(2,1)<=2);
f=f+set(x(1,1)+x(2,1)>=2);
f=f+set(x(1,1)+x(2,1)<=6);
f=f+set(1<=x(3,1)<=5);
f=f+set(0<=x(4,1)<=6);
f=f+set(1<=x(5,1)<=5);
f=f+set(0<=x(6,1)<=10);
f=f+set(x(1,1)>=0);
f=f+set(x(2,1)>=0);
solvesdp(f,obj,sdpsettings('solver','bmibnb'))
checkset(f)
plot(f)
acekris
Junior Boarder
Posts: 36
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#5181
Re: plotting Constraint Set 2 Years, 2 Months ago Karma: 32
Q1: YALMIP uses a randomized ray-shooting algorithm to draw the set (see below).

Q2: No. The plot command assumes the feasible set is convex. If not, if you are lucky and the solver used finds the optimal point in every ray it shoots, it will plot the convex hull of the nonconvex set. If the solver happens to find local minimizers, you simply get a garbage set.

Q3-Q4: ??

Q5: YALMIP projects (by shooting rays in these dimensions) on the first three variables defined (i.e. the ones with lowest internal indicies). You can select in which dimension the projection is performed by using more arguments to plot

Q6: No.

Code:


sdpvar x y
p1 = 1-((x-1)^2+y^2);
p2 = 1-((x+1)^2+y^2);
% Plot first ball
plot(p1>0);
hold on
% Plot second ball
plot(p2>0);
% Plot the union of them, i.e. a nonconvex set
% However, this will only work if the solver used actually finds global
% optimizers along each ray. On my machine, with fmincon, I was apparantly
% lucky
plot(p1*p2<0)
% We can guarantee the generation of the convex hull by using a global
% solver. This will be slow though...
plot([p1*p2<0,-100<[x y]<100],[],[],[],sdpsettings('solver','bmibnb'))

% Manually generate a plot of a ball
points = [];
for i = 1:100
    direction = randn(2,1);
    solvesdp(p1>0,direction'*[x;y]);
    points = [points double([x;y])];
end
K = convhulln(points');   
p = patch('Vertices', points', 'Faces', K);

lofberg
Platinum Boarder
Posts: 2280
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#5182
Re: plotting Constraint Set 2 Years, 2 Months ago Karma: 32
Hence, the code to plot the convex hull in x3,x4,x5

plot(f,x(3:5),[],[],sdpsettings('solver','bmibnb'))

PS, the operator SET is obsolete.
lofberg
Platinum Boarder
Posts: 2280
graphgraph
User Offline Click here to see the profile of this user
Last Edit: 2011/03/04 11:12 By lofberg.
The administrator has disabled public write access.
 
#5184
Re: plotting Constraint Set 2 Years, 2 Months ago Karma: 32
Some more plotting fun!

Plot the feasible set for the SDP relaxation of the union. It's tight as you can see
Code:


v = monolist([x y],2);
M = v*v';
plot([p1*p2<0,M>0],[],[],100,sdpsettings('relax',1,'verbose',0));
hold on
% Plot first ball
plot(p1>0,[],'g',100);
hold on
% Plot second ball
plot(p2>0,[],'b',100);



The convex hull of conic-representable sets can be created directly by using the hull operator
Code:


plot(hull(p1>0,p2>0))

lofberg
Platinum Boarder
Posts: 2280
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1
Moderators: jcg207