How to preallocate an 'lmi' (Yalmip class) array of known size
Mostrar comentarios más antiguos
Hello. I use YALMIP to solve linear matrix inequalities. Currenly, I create the constraint vector, F, that gets passed to the 'optimize' function like this:
P = sdpvar(n,n,'symmetric');
F = [P >= eye(n),...
A_comb(:,:,1)'*P*A_comb(:,:,1)-P <= 0,...
A_comb(:,:,2)'*P*A_comb(:,:,2)-P <= 0,...
A_comb(:,:,3)'*P*A_comb(:,:,3)-P <= 0,...
A_comb(:,:,4)'*P*A_comb(:,:,4)-P <= 0]
options = sdpsettings('solver', 'sedumi');
sol = optimize(F,0,options); % Objective function=0, only checking feasibility
P_opt = value(P);
Where A_comb(:,:,i) are vertices of the n-by-n array space invloved in the linear matrix inequalities and P is a positive definite matrix satisfying the discrete Lyapunov equation. I am interested in making this code more general for any dimension LMI. In this case, the dimension is 4. But if i had another problem with the same structure of constraints (just more of them), I would like to have a loop that constructs F. I noticed that F has the class of 'constraint' if it has only one constraint, and a class of 'lmi' if it has more than one constraint. Not sure why that is. Is there a way initialize F with the class of 'lmi'? I tried this so far:
P = sdpvar(n,n,'symmetric');
F = repmat([P >= eye(n)],n+1,1)
for i = 1:n
F(i+1) = A_comb(:,:,i)'*P*A_comb(:,:,i)-P <= 0
end
options = sdpsettings('solver', 'sedumi');
sol = optimize(F,0,options); % Objective function=0, only checking feasibility
P_opt = value(P);
The problem with this is if I try to call out an index of F other than 1, I get the error
Error using indexing
LMI #2 not available.
I looked throught the YALMIP-master directory I downloaded, but I could not find the code that created the 'lmi' class. Any help is appreciated.
Edit:
I also found that this works:
P = sdpvar(n,n,'symmetric');
F = [P >= eye(n)];
for i=1:4
F = [F, A_comb(:,:,i)'*P*A_comb(:,:,i)-P <= 0];
end
options = sdpsettings('solver', 'sedumi');
sol = optimize(F,0,options); % Objective function=0, only checking feasibility
P_opt = value(P);
But the problem is that the size of F is changing with every iteration. When the dimension of the LMI if large, this will make the code run slower.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!