Path: news.mathworks.com!not-for-mail
From: "Michael Zhang" <cy_xiaoxiao@126.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: LMI term dimensions incompatible
Date: Thu, 8 May 2008 11:15:07 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 258
Message-ID: <fvunbr$1tb$1@fred.mathworks.com>
References: <fvtuvp$aiv$1@fred.mathworks.com> <fvueq0$mf3$1@fred.mathworks.com>
Reply-To: "Michael Zhang" <cy_xiaoxiao@126.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210245307 1963 172.30.248.37 (8 May 2008 11:15:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 8 May 2008 11:15:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1379620
Xref: news.mathworks.com comp.soft-sys.matlab:467358



"Johan L?fberg" <loefberg@control.ee.ethz.ch> wrote in 
message <fvueq0$mf3$1@fred.mathworks.com>...
> Well, I won't directly answer your question, but when I 
see
> this, I can see that it must be annoying. My advice to you
> is to use more modern tools to setup and solve the SDP.
> 
> Using YALMIP and the solver SeDuMi
> http://control.ee.ethz.ch/~joloef/wiki/pmwiki.php
> http://control.ee.ethz.ch/~joloef/wiki/pmwiki.php?
n=Solvers.SEDUMI
> 
> you would code your problem as below. 
> 
> I think this approach would save you a lot of agony during
> the modelling.
> 
> /johan
> 
> 
> Q = sdpvar(n,n);
> S1 = sdpvar(n,n);
> S2 = sdpvar(n,n);
> 
> gammasquared = sdpvar(1,1);
> 
> A = randn(n,n);
> Ad = randn(n,n);
> Bd = randn(n,n);
> B1 = randn(n,n);
> B2 = randn(n,n);
> M = randn(n,n);
> Cd = randn(n,n);
> C = randn(n,n);
> D11 = randn(n,n);
> D12 = randn(n,n);
> Dd = randn(n,n);
> 
> 
> % We could do something like this, but then we would have 
to
> find out the
> % dimensions of the zero blocks, and we are too lazy to 
do that 
> %B = [ -Q+Bd*S2*Bd'+Ad*S1*Ad' A*Q+B2*M         
B1          
>        Bd*S2*Dd'+Ad*S1*Cd'  0       0;
> %  Q*A'+M'*B2'                -Q            
0              
>     Q*C'+M'*D12'         M'      Q;
> %  B1'                         0          -
gammasquared*I  
>          D11'                0       0;
> %  Dd*S2*Bd'+Cd*S1*Ad'    C*Q+D12*M         
D11            
>   -I+Cd*S1*Cd'+Dd*S2*Dd' 0       0;
> %  0                      M                 
0              
>      0                  -S2      0;
> %  0                      Q                 
0              
>      0                   0      -S1 ];
> 
> % Instead, we use the blkvar shortcut. It automatically
> fills in the blanks and symmetrizes for you
> B = blkvar;
> B(1,1) =  -Q+Bd*S2*Bd'+Ad*S1*Ad';
> B(1,2) =  A*Q+B2*M;
> B(1,3) = B1;
> B(1,4) = Bd*S2*Dd'+Ad*S1*Cd';
> B(2,2) = -Q;
> B(2,4) = Q*C'+M'*D12';
> B(2,5) = M';
> B(2,6) = Q;
> B(3,3) = -gammasquared*eye(size(B1,2));
> B(3,4) = D11';
> B(4,4) = -eye(size(Cd,1))+Cd*S1*Cd'+Dd*S2*Dd';
> B(5,5) = -S2;
> B(6,6) = -S1;
> 
> % set up all constraints
> Constraints = [B < 0, Q>0, S1>0, S2>0];
> Objective = gammasquared;
> % Minimize gamma^2
> solvesdp(Constraints,Objective)
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> "Michael Zhang" <cy_xiaoxiao@126.com> wrote in message
> <fvtuvp$aiv$1@fred.mathworks.com>...
> > Is anyone can help me? I can figure out what happened 
to my 
> > programm.
> > 
> > I need to solve a inequality:
> > 
> > | -Q+Bd*S2*Bd'+Ad*S1*Ad' A*Q+B2*M   B1
> > |      Q*A'+M'*B2'         -Q       0
> > |          B1'              0       -gammar^2*I
> > |   Dd*S2*Bd'+Cd*S1*Ad'  C*Q+D12*M  D11
> > |          0                M       0
> > |          0                Q       0
> > 
> >     Bd*S2*Dd'+Ad*S1*Cd'     0       0  |
> >          Q*C'+M'*D12'       M'      Q  |
> >              D11'           0       0  |  <0
> >   -I+Cd*S1*Cd'+Dd*S2*Dd'    0       0  |
> >              0             -S2      0  |
> >              0              0      -S1 | 
> >   
> > Matrices:Q, S1, S2 are positive-define.
> > 
> > Below is programm:
> > ===================================================
> > A = [2 1; 0 1];
> > Ad = [0.2 0.1; 0 0.1];
> > B1 = [0.1 0.1]';
> > B2 = [1 1]';
> > Bd = [0.1 0.1]';
> > 
> > C = [1, 1];
> > Cd = [0.1, 0.1];
> > 
> > D11 = 0.1;
> > D12 = 1;
> > Dd = 0.1;
> > 
> > gammar = 1;
> > 
> > % Initial a LMI system
> > setlmis([]);
> > 
> > % Define Variables
> > 
> > % Q is a symmetric matrix, has a block size of 2 and 
this 
> > block is symmetric 
> > Q = lmivar(1, [2 1]);
> > 
> > % S1 a symmeric matrix, size 2 by 2
> > S1 = lmivar(1, [2 1]);
> > 
> > 
> > % S2 is 1 by 1 matrix
> > S2 = lmivar(1, [1 0]);
> > 
> > 
> > % Type of 2, size 1 by 2 
> > M = lmivar(2, [1 2]);
> > 
> > 
> > %I use upper triangular to represent the LMI
> > 
> > % pos in (1, 1)
> > lmiterm([1 1 1 Q], -1, 1);
> > lmiterm([1 1 1 S2], Bd, Bd');
> > lmiterm([1 1 1 S1], Ad, Ad');
> > 
> > % pos (1, 2)
> > lmiterm([1 1 2 Q], A, 1);
> > lmiterm([1 1 2 M], B2, 1);
> > 
> > % pos(1, 3)
> > lmiterm([1 1 3 0], B1);
> > 
> > % pos(1, 4)
> > lmiterm([1 1 4 S2], Bd, Bd');
> > lmiterm([1 1 4 S1], Ad, Cd');
> > 
> > 
> > % pos(2, 2)
> > lmiterm([1 2 2 Q], -1, 1);
> > 
> > % pos(2, 4)
> > lmiterm([1 2 4 Q], 1, C');
> > 
> > lmiterm([1 2 4 -M], 1, D12');
> > 
> > % pos(2, 5)
> > lmiterm([1 2 5 -M], 1, 1);
> > 
> > % pos(2, 6)
> > lmiterm([1 2 6 Q], 1, 1);
> > 
> > % pos(3, 3)
> > lmiterm([1 3 3 0], -(gammar^2));
> > 
> > % pos(3, 4)
> > lmiterm([1 3 4 0], D11');
> > 
> > % pos(4, 4)
> > lmiterm([1 4 4 0], -1);
> > lmiterm([1 4 4 S1], Cd, Cd');
> > lmiterm([1 4 4 S2], Dd, Dd');
> > 
> > % pos(5, 5)
> > lmiterm([1 5 5 S2], -1, 1);
> > 
> > 
> > % pos(6, 6)
> > lmiterm([1 6 6 S1], -1, 1);
> > 
> > lmis = getlmis;
> > 
> > [tmin, feas] = feasp(lmis)
> > 
> > --------------------------------
> > When I run it, I get error message:
> > 
> > ??? Error using ==> lmiterm at 296
> > lhs of LMI #1, block (4,1): term dimensions 
incompatible 
> > with
> > other terms in same row
> > 
> > Error in ==> paperor at 56
> > lmiterm([1 1 4 S1], Ad, Cd');
> > 
> > I have checked many times and can't figure out why it 
is 
> > wrong, can anybody point it to me?
> > 
> 

Dear Johan:

Thank you very much. But I still have some doubts about 
this.

You recommend me to use YALMIP, but I think the program you 
write for me is not apply to me.

1.The original problem is for a discrete time linear delay 
system which I have't write it here, If there exists 
positive-define matrices Q, S1, S2 and a matrix M satisfied 
that LMI, then we call it H-inf quadratically stable with H-
inf norm bound gammar. So I mean gammar cannot be a random 
variable. So you write the program that object is to 
minimize gamma^2, I think it is not suitable.

2.In my problem, matrices like A, Ad, Dd, they are all 
specified, you use randn(n,n) to generate them. I replace 
them with specified ones.