Maximum volume inscribed ellipsoid in a polyhedron with YALMIP

173 views
Skip to first unread message

Raffaele Romagnoli

unread,
Aug 10, 2018, 11:48:01 PM8/10/18
to YALMIP
Hi,
I'm computing the maximum volume inscribed ellipsoid in a polyhedron, following the theory developed in Boyd & Vandenberghe "Convex Optimization"
. After computing the polyhedron, using cvx I have no problems, instead using the same structure of the polyhedron with YALMIP I obtain an ellipsoid out of the polyhedron that in my case is a triangle:

%-----------Polyhedron-----------------------------
x1=0:0.1:5;
y1=0.2*x1; y2=x1; y3=-1*x1+4;
figure
plot(x1,y1,x1,y2,x1,y3)
%---------------------------------------------------------

I am wondering if I am wrong in the description of the polyhedron using YALMIP. Following the code I use


%-------------------------- Code ------------------------------------------------------
A=[-1 1;1 1;0.2 -1]; b=[0;4;0];   % it's a triangle

P = sdpvar(n,n);
x = sdpvar(2,1);

F = [P>=0, A(1,:)*P*A(1,:)'+A(1,:)*x<=b(1),...
       A(2,:)*P*A(2,:)'+A(2,:)*x <=b(2),...
       A(3,:)*P*A(3,:)'+A(3,:)*x<=b(3)];

optimize(F,-logdet(P),sdpsettings('solver','sdpt3'));


noangles = 500;
angles   = linspace( 0, 2 * pi, noangles );
ellipse_inner  = value(P) * [ cos(angles) ; sin(angles) ] + value(x) * ones( 1, noangles );
%------------------------------------------------------------------------------------------------------

Thanks for your attention

Raffaele

Johan Löfberg

unread,
Aug 11, 2018, 5:17:14 AM8/11/18
to YALMIP
You're not solving the same problem, so of course you get something weird. Correct code would be

F = [P>=0, 
    norm( P*A(1,:)', 2 ) + A(1,:)*x <= b(1),
    norm( P*A(2,:)', 2 ) + A(2,:)*x <= b(2),
    norm( P*A(3,:)', 2 ) + A(3,:)*x <= b(3)];
optimize(F,-logdet(P),sdpsettings('solver','sdpt3'));
z = sdpvar(2,1);
plot([A*z <= b]);hold on
plot((value(x) - z)'*value(P)^-2*(value(x)-z) <= 1)





Reply all
Reply to author
Forward
0 new messages