Generate multiple sdpvar m x m matrices in a for loop

275 views
Skip to first unread message

drw5ff

unread,
Jun 9, 2015, 3:42:18 PM6/9/15
to yal...@googlegroups.com
Johan,

I'm trying to generalize some LMI code I've been working on and have a question: Is there a way to generate a predetermined number of m x m sdpvar matrices inside of a for loop such that each variable is unique? I tried originally tried using cells similar to 

for i = 1:num_lmi_cond

P{i} = sdpvar(m,m)

end

but I got an error along the lines that YALMIP does not accept cell references for its inequalities. Is there a proper way to do this? 

Johan Löfberg

unread,
Jun 10, 2015, 1:36:08 AM6/10/15
to yal...@googlegroups.com
Like you do, or using the built-in cell format explained here

and then you simply reference the cells
P{2}<=0

(i.e., you cannot write P <= 0 etc)

drw5ff

unread,
Jun 10, 2015, 9:22:08 AM6/10/15
to yal...@googlegroups.com
Thanks Johan, 

Now I'd like to sum these matrices and multiply them by a single scale constant. For cells, I believe you can sum them using

P = P0 + delta_lambda*sum(cat(3,P1{:}),3);


For some cell of m x m matrices P1 and a fixed matrix P0. However, when the scalar constant delta_lambda is set to zero, I get the following warning

Warning: One of the constraints evaluates to a DOUBLE variable 
> In constraint/horzcat (line 6)
  In matrix_test_general (line 85) 

For the following constraint

F = [F, 100*eye(m+n) >= P >= eye(m+n)];

F = [F, 100*eye(m+n) >= P0 >= eye(m+n)];


MOSEK is still correctly solving this problem. Is this something I should be worried about? Here's an excerpt of my code

for i = 1:num_lmi_cond_2

    

    P1{i} = sdpvar(m+n,m+n);

    

    Delta_A_bar_12 = zeros(n,m);

    Delta_A_bar_12(:,i) = B(:,i)*delta_lambda;

    Delta_A_bar_22 = zeros(m);

    Delta_A_bar_22(i,i) = delta_lambda;

 

    Delta_A_bar = [zeros(n,n), -Delta_A_bar_12;

                   zeros(m,n), Delta_A_bar_22];

 

    % Delta_A_bar constraint           

    F = [F, Delta_A_bar'*P1{i} + P1{i}*Delta_A_bar >= 0];

 

end


%Calc P

if num_lmi_cond_2 == 1

 

    P = P0 + delta_lambda*P1{1};

       

elseif num_lmi_cond_2 >= 2

    

    P = P0 + delta_lambda*sum(cat(3,P1{:}),3);

    

elseif delta_lambda == 0

    

    P = P0;

    

end

 

% Enforce negativity of P, P0

F = [F, 100*eye(m+n) >= P >= eye(m+n)];

F = [F, 100*eye(m+n) >= P0 >= eye(m+n)];





Johan Löfberg

unread,
Jun 10, 2015, 1:41:47 PM6/10/15
to yal...@googlegroups.com
It imply means that somewhere in your constraints, something evaluates to 0>=0, which YALMIP thinks is weird that you want to redundantly impose.
Reply all
Reply to author
Forward
0 new messages