Creating square matrix variable by using small square matrix variables

(Fred) #1

Hi All,

I have the following cvx setup for my optimization problem:

   cvx_begin sdp
      variable W1(6,6) hermitian
      variable W2(6,6) hermitian
      variable W3(6,6) hermitian
    expression W 
    W = [ W1(1,1)   W1(1,2)    oo        oo 
          W1(2,1)   W1(2,2)  W2(2,3)   W3(2,4) 
             oo     W2(3,2)  W2(3,3)     oo  
             oo     W3(4,2)     oo      W3(4,4)]
    minimize real(trace(W*Fobj))

However, I got an error for W which is following:

Error using cvx/cat (line 40)
All dimensions but the one being concatenated (2) must be equal.

Error in cvx/horzcat (line 2)
y = cat( 2, varargin{:} );

Error in  (line 203)
W = [ W1(1,1) W1(1,2) oo      oo 

Can someone help me out what is wrong with my code?


(Mark L. Stone) #2

W1(1,1), W(11,2), W1(2,1) etc. are scalars (i.e., 1 by 1). oo is 3 by 3. So you have not constructed W in a conformal manner. If W1, W2, W3 were 6 by 6 MATLAB variables instead of CVX variables, you would also encounter a horzcat error.

I can’t tell you how to fix it, because I don’t know what you want W to be.

(Fred) #3

Thanks Mark for the quick response.
I made a mistake in matrix W definition, now I redefined my cvx variables as 3x3 and rewrite my W.

      cvx_begin sdp
          variable W11(3,3) hermitian
          variable W12(3,3) hermitian
          variable W21(3,3) hermitian
          variable W22(3,3) hermitian
          variable W23(3,3) hermitian
          variable W24(3,3) hermitian 
          variable W32(3,3) hermitian
          variable W33(3,3) hermitian
          variable W42(3,3) hermitian
          variable W44(3,3) hermitian
       expression W 
         W = [ W11   W12   oo    oo 
               W21   W22   W23   W24 
                oo   W32   W33   oo  
                oo   W42   oo    W44]
     W1=[W11 W12; W21 W22];  W2=[W22 W23; W32 W33]; W3=[W22 W24; W42 W44];
   minimize real(trace(W*Fobj))
    W1 >= 0; W2 >=0; W3>=0

But this time I got the following error for my inequality constraints:

Warning: This linear matrix inequality appears to be unsymmetric. This is
very likely an error that will produce unexpected results. Please check
the LMI; and, if necessary, re-enter the model.

Is it the way I created the W1, W2 and W3 that creates the error?

(Mark L. Stone) #4

You need to construct W so that it is hermitian (or symmetric).

   W =   [ W11   W12   oo    oo 
           W12'  W22   W23   W24 
            oo   W23'  W33   oo  
            oo   W24'  oo    W44]

And W1, W2, W3 as well if you don’t extract them out of W.

(Fred) #5

All W1,W2, and W3 are 6x6 cvx variable, aren’t they hermitian since I built them by using hermitian matrices (W11, W12,… etc.)?

(Mark L. Stone) #6

The variables you declared as 3 by 3 are hernitian. But, for example, W12 might not equal W21’, so CVX issued a warning. If you build the matrices (for example, W1) as I showed, it will be symmetric (hermitian) and W1 >= 0 should be processed by CVX as you wanted to specify a linear matrix inequality.

(Fred) #7

Thanks Mark, I solved the problem now.