Hello, I am having difficulty understanding how to formulate and implement these LMIs correctly in YALMIP. Could you please help me with how to write this formulation properly? I would really appreciate your guidance.
I used ChatGPT and got errors. Is it correct?
S = cell(r,r);
Tol = 1e-10;
Constraints = [];
Constraints = [Constraints, P >= Tol*eye(n)];
for i = 1:r
for j = 1:r
S{i,j} = [A{i}'*P + P*A{i} E{j};
M*C{j} zeros(p,q)];
end
end
for i = 1:r
for j = 1:r
if i == j
Constraints = [Constraints, ...
S{i,i} <= -Tol*eye(size(S{i,i},1))];
else
Constraints = [Constraints, ...
(2/(r-1))*S{i,i} + S{i,j} + X{j,i} ...
<= -Tol*eye(size(S{i,i},1))];
end
end
end
Sorry, I didn’t explain my idea clearly, this is just an example. Are the constraints written correctly?
S = cell(r,r);
Tol = 1e-10;
Constraints = [];
Constraints = [Constraints, P >= Tol*eye(n)];
for i = 1:rfor j = 1:rS{i,j} = [A{i}'*P + P*A{i} E{j};
E{j}' zeros(p,q)];
The matrix is written incorrectly because this is just an example and I didn’t pay attention. What I want to verify, regardless of the matrix itself, is whether the constraints are written correctly ??
I have already defined the matrices C0, E0 and A_{TS}. This is a part of my code. Are there any issues in it? I am still obtaining incorrect results, and these are the eigenvalues of the matrix P
0.0000
0.0002
0.9644
yalmip('clear');
n = size(C0,2);
p = size(C0,1);
r = length(A_TS);
P = sdpvar(n,n,'symmetric');
gamma = sdpvar(1);
% Li bar (Lbar)
Lbar = cell(r,1);
for i=1:r
Lbar{i} = sdpvar(n,p,'full');
end
%C
C = cell(1,r);
for j = 1:r
C{j} = C0;
end
%E
E = cell(1,r);
for i = 1:r
E{i} = E0;
end
% M
M = sdpvar(p,p,'full');
q = size(E0,2);
X = cell(r,r);
Tol = 1e-10;
Constraints = [];
Constraints = [Constraints, P >= Tol*eye(n)];
Constraints = [Constraints, gamma >= Tol];
for i = 1:r
for j = 1:r
X{i,j} = [ ...
A_TS{i}'*P + P*A_TS{i} ...
- Lbar{i}*C{j} - C{j}'*Lbar{i}', ...
P*E{i}, ...
-Lbar{i}, ...
C{j}'*M';
E{i}'*P, ...
-gamma*eye(q), ...
zeros(q,p), ...
zeros(q,p);
-Lbar{i}', ...
zeros(p,q), ...
-gamma*eye(p), ...
M' - eye(p);
M*C{j}, ...
zeros(p,q), ...
M - eye(p), ...
-gamma*eye(p)
];
end
end
for i = 1:r
for j = 1:r
if i == j
Constraints = [Constraints, ...
X{i,i} <= -Tol*eye(size(X{i,i},1))];
else
Constraints = [Constraints, ...
(2/(r-1))*X{i,i} + X{i,j} + X{j,i} ...
<= -Tol*eye(size(X{i,i},1))];
end
end
end
Objective = gamma;
options = sdpsettings('solver','mosek');
sol = optimize(Constraints, Objective, options);
if sol.problem == 0
disp('Feasible');
else
disp('Infeasible or numerical issue');
end
P= value(P)
gamma= value(gamma)
L = cell(r,1);
for i=1:r
L{i} = value(P) \ value(Lbar{i});
end
M= value(M)
L1 = L{1}
L2 = L{2}