|
楼主 |
发表于 2008-5-9 09:19
|
显示全部楼层
该问题已经解决
我找了好久也没有发现问题在哪里,就加入了Matlab的Newsgroup,结果碰见一高人把我程序又写了一遍,并推荐我用现代一点的工具箱。
The following new items match a watch list that you have set up on the MATLAB� Community pages. You can see a complete list of your watch lists, modify them, or unsubscribe on your MATLAB Community profile page. This email was sent to you because you specified �email� as your notification method for new watch list items.
Subject: Re: LMI term dimensions incompatible
From: "Michael Zhang"
Date: Fri May 09 01:07:06 -0400 2008
"Johan L?fberg"
message > "Michael Zhang"
> > > "Johan L?fberg"
> > message > > > "Johan L?fberg"
> > > message > > > > "Johan L?fberg"
in
> > > > message > > > > > "Michael Zhang"
message
> > > > > > > > > > > "Johan L?fberg"
wrote
> > in
> > > > > > message > > > > > > > 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"
in
> > message
> > > > > > > > > > > > > > > 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.
> > > > > >
> > > > >
> > > > >
> > > > > I though gammar was a decision variable that you
> > wanted to
> > > > > optimize. If it is given, well then you just use
that
> > > > > instead and remove the objective from the call to
> > solvesdp
> > > > > and solve the feasibility problem instead
> > > > >
> > > > > You can of course use your own data, I only
defined
> > random
> > > > > matrices to get an example that was working.
> > > > >
> > > > > The problem can be solved with YALMIP and SeDuMi
> > without a
> > > > > doubt, it is a trivial SDP problem.
> > > >
> > > >
> > > > ..and I noticed you optimized over M too, so you
should
> > use
> > > >
> > > > M = sdpvar(somesize,someothersize,'full')
> > > >
> > > >
> > >
> > > To summarize
> > >
> > > 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;
> > >
> > > Q = sdpvar(2,2);
> > > S1 = sdpvar(2,2);
> > > S2 = sdpvar(1);
> > > % Full by definition, but just to rmember it if
> > > % we change dimensions later
> > > M = sdpvar(1,2,'full');
> > >
> > > 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) = -gammar^2*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];
> > > solvesdp(Constraints)
> > > yalmiptime: 0.3430
> > > solvertime: 1.3440
> > > info: 'No problems detected (SeDuMi-1.1)'
> > > problem: 0
> > > dimacs: [1.4589e-015 0 0 0 7.3848e-016
3.9007e-
> > 015]
> > >
> > >
> > > >> double(Q)
> > >
> > > ans =
> > >
> > > 0.2425 -0.2091
> > > -0.2091 1.0081
> > >
> > > >> double(S1)
> > >
> > > ans =
> > >
> > > 1.3613 -0.4978
> > > -0.4978 2.3019
> > >
> > > >> double(S2)
> > >
> > > ans =
> > >
> > > 2.0517
> > >
> > > >> double(M)
> > >
> > > ans =
> > >
> > > -0.1367 -0.6933
> > >
> > >
> > >
> > This LMI example is what I read from a paper, but the
> > author's result is different form yours. And he gave
> > proofs, I think the author only use matlab and we use
other
> > toolboxes. I doubt if there really exists result
difference
> > because of toolboxes?
> >
> > The paper's address is
http://www.sciencedirect.com/science?
> > _ob=ArticleURL&_udi=B6V21-3WWV8W6-
B&_user=10&_coverDate=08%
> > 2F31%
> >
2F1999&_alid=736573613&_rdoc=1&_fmt=high&_orig=search&_cdi=5
> >
689&_sort=d&_docanchor=&view=c&_ct=1&_acct=C000050221&_versi
> >
on=1&_urlVersion=0&_userid=10&md5=8ecef13fb66b50ddc4a3990637
> > 4c61b7
>
>
> The solution is not unique since you only solve a
> feasibility problem
>
>
Thank you very much. According to this, I have a lot to
learn.
View thread: http://www.mathworks.com/matlabcentral/newsreader/view_thread/168901#431171 |
|