Here is my sample code to find the maximum inscribed ellipsoid: {x : (x-c)'*P^(-1)*(x-c)<=1}
contained in a polytope: {x : A*x <= b}, using YALMIP.
A = [ eye(3); -eye(3) ];
b = ones(6,1);
yref = zeros(3,1);
y = sdpvar(3, 1);
[P, ~] = maxInscribedEllipsoid(A, b, yref);
ellipsoid_constr = (y-c)*P*(y-c) == 1;
figure();
constr_poly = A*y - b <= 0;
confg = sdpsettings('verbose', 0);
confg.plot.linewidth = 2;
confg.plot.shade = 0.2;
plot(constr_poly, [], 'g-', [], confg);
hold on;
confg.plot.shade = 0.1;
plot(ellipsoid_constr, [], 'b-');
hold off;
%% function
[P_opt] = maxInscribedEllipsoid (A, b, c)
[m, n] = size(A);
% variables
P = sdpvar(n, n, 'symmetric');
% Constraints: P ≻ 0
Constraints = [P >= eps*eye(n)];
% Containment: for each i, ||P^(1/2)*a_i|| + a_i'*c <= b_i
for i = 1:m
ai = A(i, :)';
Constraints = [Constraints, norm(sqrtm(P)*ai, 2) + ai'*c <= b(i)];
end
% Objective: maximize geometric mean of eigenvalues of P
Objective = -geomean(P);
% Objective: minimize log det of P
% Objective = logdet(P);
% Solver settings: use SeDuMi or mosek
% options = sdpsettings('solver', 'sedumi', 'verbose', 1);
options = sdpsettings( 'solver', 'mosek', 'verbose', 1);
% Solve the SDP
sol = optimize(Constraints, Objective, options)
% Extract optimal values
P_opt = value(P);
end
Result:
% solvertime: 0
% info: 'No suitable solver'
% problem: -2
% yalmiptime: 0.2500
Can you help me find the problem, please?