Thank you for this information. I did not want to post code before making sure that the problem statement as well as the implementation make sense.
(My code determines the maximum volume ellipsoid {x'Px<=alpha} inside a polyhedron defined by the inequality constraint matrices Vae and Vbe.)
This is a MWE:
- I define a positive definite matrix Pi.
- I define constraint matrices VAe and Vbe.
- I want to minimize det(inv(B)), where B=sqrt(alpha)*Pi^(-1/2) with alpha as decision variable. Because it is not possible to calculate inv(B) when B contains an sdpvar, I explicitly construct the help variable Binv. Then I define the cost function
cost=det(Binv).
The constraints are defined as
norm(B*VAe(i,:)',2)<=Vbe(i); %i=1,...,length(Vbe).
(Btw: we know that det(inv(B)) has to be positive as Pi is PD and alpha>=0.)
%Define matrix Pi
Pi=[3.4309 1.4534; 1.4534 3.3298];
%Define matrices VAe, Vbe
VAe=[-0.1046 -0.2476
0 -0.1961
0.1961 0.0000
0.1046 0.2476
0 0.1961
-0.1961 -0.0000]
Vbe=[0.9632
0.9806
0.9806
0.9632
0.9806
0.9806]
%Optimization
sdpvar alpha
B=sqrt(alpha)*Pi^(-1/2);
a=B(1,1);
b=B(1,2);
c=B(2,1);
d=B(2,2);
Binv=1/(a*d-b*c)*[d -b; -c a];
cost=det(Binv)%log(det(Binv)), we know det(Binv)>=0
cond=[];
for i=1:length(Vbe)
cond=[cond norm(B*VAe(i,:)',2)<=Vbe(i)]
end
%cond=[cond alpha>=0]
optimize(cond,cost)
This gives 'Model creation failed (Model not available in objective at level 2)'.