Where is the mistake of this Convex optimization problem?


(eliiiiiiiiiiiiiiiii) #1

Hi,
I want to simulate the LMI problem which exist in the article.
but it takes this error:
Error using reshape
To RESHAPE the number of elements must not change.

Error in cvx/cat (line 102)
yb = reshape( yb, nz, psz );

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


clc
clear all
close all
A = [-0.45 0.45 0;0.09 0.225 -0.45;0.135 0.135 -0.54];
B = [1 0;0.2 1;0 .3];
C = [0.1 0.8 0.7;-0.6 0.9 0.6];
Ad = [-0.04 0.02 0;0.02 -0.16 0.04;0.2 -0.06 -0.2];
D1 =[0.1;0;0.2]
D2 =[1;0]
D3 =[0.1;0;0.1]
E =[0.1 0 0;0.2 0 0.2;0 0.1 0.2]
F =[1 0 0.1;0.1 0 1;0.1 0.1 0]

n = size(A,1);
[n,m] = size(B);
[q,n] = size©;

d1=-0.1;d2=0.1;
T1=-0.2;T2=0.2;
alpha=0.95
beta=.85
alpha0 =sqrt(alpha*(1-alpha))
beta0 = sqrt(beta*(1-beta))

[U,S,V] = svd(B)
U1 =U(:,1:2)
U2 =U(:,3)

cvx_begin sdp

variable gama

variable omega11(m,m)
variable omega12(n-m,n-m)
variable omega21(m,m)
variable omega22(n-m,n-m)

variable W2(n,m)
variable Y(q,n)
variable W1(n,n)

omega1 = U1omega11U1’+U2omega12U2’
omega2 = U1omega21U1’+U2omega22U2’
omegaT1= inv(V)pinv(S)omega1SV
omegaT2 = inv(V)pinv(S)omega2SV

%decision variable
variable P1(n,n)
variable P2(n,n)
variable Q1(n,n)
variable Q2(n,n)
variable Q3(n,n)

variable R1(n,n)
variable R2(n,n)
variable R3(n,n)

Q = [Q1 Q2;Q2’ Q3]
R = [R1 R2;R2’ R3]
P =blkdiag(P1,P2)

Phat = blkdiag((d2-d1+1)*Q+(T2-T1+1)R-P,-Q,-R,-gama^2eye(6))
PTel = blkdiag(P1-omega1-omega1’,P2-omega2-omega2’)

Etel =[E zeros(n) F zeros(n) zeros(n) zeros(n) D3 zeros(n,5)]
Atel = [omega1A zeros(n) omega1Ad zeros(n,7) zeros(n) betaBY omega1D1 zeros(n,1);zeros(n) W1 zeros(n) zeros(n,7) alphaW2C zeros(n) zeros(n,1) alphaW2D2]
Btel = [zeros(n,5) zeros(n) zeros(n) zeros(n) zeros(n) alpha0
BY zeros(n) zeros(n,1);zeros(n,5) zeros(n) zeros(n) zeros(n) alpha0W2C zeros(n) zeros(n) alpha0W2*D2]
minimize gama
subject to
[Phat Atel’ Btel’ Etel’;
Atel PTel zeros(6) zeros(6,3);
Btel zeros(6) PTel zeros(6,3);
Etel zeros(3,6) zeros(3,6) -eye(n)]<=0
cvx_end

G = inv(omegaT1)(Y)
Bc = inv(omega2)
(W1)
Ac = inv(omega2)*(W2)


(Mark L. Stone) #2

The difficulty is in the LMI constraint, and in particular with PTel in the 2nd and 3rd block rows.

>> PTel
PTel =
    cvx real affine expression (6x6 matrix, 18 nonzeros)

So I believe it should be correct, but somehow PTel is not being processed as a 6 by 6 matrix.
Ptel-zeros(6) even produces an error message, but shouldn’t. I don’t know why this is happening.

This seems to me like a bug in CVX. However, using
PTel = [P1-omega1-omega1' zeros(3);zeros(3) P2-omega2-omega2']
seems to work; so that is a workaround to the apparent bug.

However, there is another difficulty with your program. gama^2 is used in Phat, which is in the “LMI”: constraint, which is not allowed. Perhaps you can instead declare
variable gamasq nonnegative
and use gamasq instead of gama^2 in Phat. I will leave you to determine whether you can use gamasq instead of gama in the object5ive function.

Doing all that, there is still another problem, your LMI is not symmetric per CVX. I think you need to declare P1, P2, Q1, Q3, R1, R3 to be symmetric.

If all these changes are made, the program executes without warning or error message, and with sdpt3, produces cvx_optval = +1.50199 .

Here is the program I successfully ran:

cvx_begin sdp

variable gamasq nonnegative

variable omega11(m,m)
variable omega12(n-m,n-m)
variable omega21(m,m)
variable omega22(n-m,n-m)

variable W2(n,m)
variable Y(q,n)
variable W1(n,n)

omega1 = U1*omega11*U1'+U2*omega12*U2'
omega2 = U1*omega21*U1'+U2*omega22*U2'
omegaT1= inv(V)*pinv(S)*omega1*S*V
omegaT2 = inv(V)*pinv(S)*omega2*S*V

%decision variable
variable P1(n,n) symmetric
variable P2(n,n) symmetric
variable Q1(n,n) symmetric
variable Q2(n,n)
variable Q3(n,n) symmetric

variable R1(n,n) symmetric
variable R2(n,n)
variable R3(n,n) symmetric

Q = [Q1 Q2;Q2' Q3]
R = [R1 R2;R2' R3]
P =blkdiag(P1,P2)

Phat = blkdiag((d2-d1+1)*Q+(T2-T1+1)*R-P,-Q,-R,-gamasq*eye(6))
PTel = [P1-omega1-omega1' zeros(3);zeros(3) P2-omega2-omega2']

Etel =[E zeros(n) F zeros(n) zeros(n) zeros(n) D3 zeros(n,5)]
Atel = [omega1*A zeros(n) omega1*Ad zeros(n,7) zeros(n) beta*B*Y omega1*D1 zeros(n,1);zeros(n) W1 zeros(n) zeros(n,7) alpha*W2*C zeros(n) zeros(n,1) alpha*W2*D2]
Btel = [zeros(n,5) zeros(n) zeros(n) zeros(n) zeros(n) alpha0*B*Y zeros(n) zeros(n,1);zeros(n,5) zeros(n) zeros(n) zeros(n) alpha0*W2*C zeros(n) zeros(n) alpha0*W2*D2]
minimize gamasq
subject to 
[Phat Atel' Btel' Etel';
Atel PTel zeros(6) zeros(6,3);
Btel zeros(6) PTel zeros(6,3);
Etel zeros(3,6) zeros(3,6) -eye(n)]<=0
cvx_end

(eliiiiiiiiiiiiiiiii) #3

Thanks alot …but there is another problem that i face with it …when i ran the simulation the matrices
Ac , G ,Bc are very small .there are 1e-8 factor…also gamma and P1 and P2 which obtained from solving optimization problem is very big …

it’s 2 days that i work on it but i couldn’t find how can i solve this .’'can you guide me that why the matrices which obtained from LMI is very big ?

it’s the code :
clear all
close all
clc
%% First: sensor-to-controller
A = [-0.45 0.45 0;0.09 0.225 -0.45;0.135 0.135 -0.54];
B = [1 0;0.2 1;0 .3];
C = [0.1 0.8 0.7;-0.6 0.9 0.6];
Ad = [-0.04 0.02 0;0.02 -0.16 0.04;0.2 -0.06 -0.2];
D1 =[0.1;0;0.2]
D2 =[1;0]
D3 =[0.1;0;0.1]
E =[0.1 0 0;0.2 0 0.2;0 0.1 0.2]
F =[1 0 0.1;0.1 0 1;0.1 0.1 0]

n = size(A,1);
[n,m] = size(B);
[q,n] = size©;

d1=-0.1;d2=0.1;
T1=-0.2;T2=0.2;
alpha=0.95
beta=.85

[U,S,V] = svd(B)
U1 =U(:,1:2)
U2 =U(:,3)

cvx_begin sdp
variable gamasq nonnegative

variable omega11(m,m)

variable omega12(n-m,n-m)

variable omega21(m,m)

variable omega22(n-m,n-m)

variable W2(n,m)

variable Y(q,n)

variable W1(n,n)

omega1 = U1omega11U1’+U2omega12U2’

omega2 = U1omega21U1’+U2omega22U2’

omegaT1= inv(V)pinv(S)omega1SV

omegaT2 = inv(V)pinv(S)omega2SV

%decision variable

variable P1(n,n) symmetric

variable P2(n,n) symmetric

variable Q1(n,n) symmetric

variable Q2(n,n)

variable Q3(n,n) symmetric

variable R1(n,n) symmetric

variable R2(n,n)

variable R3(n,n) symmetric

Q = [Q1 Q2;Q2’ Q3]

R = [R1 R2;R2’ R3]

P =blkdiag(P1,P2)

Phat = blkdiag((d2-d1+1)*Q+(T2-T1+1)R-P,-Q,-R,-gamasqeye(6))

PTel = [P1-omega1-omega1’ zeros(3);zeros(3) P2-omega2-omega2’]

Etel =[E zeros(n) F zeros(n) zeros(n) zeros(n) D3 zeros(n,5)]

Atel = [omega1A zeros(n) omega1Ad zeros(n,7) zeros(n) betaBY omega1D1 zeros(n,1);zeros(n) W1 zeros(n) zeros(n,7) alphaW2C zeros(n) zeros(n,1) alphaW2*D2]

Btel = [zeros(n,5) zeros(n) zeros(n) zeros(n) zeros(n) alpha0BY zeros(n) zeros(n,1);zeros(n,5) zeros(n) zeros(n) zeros(n) alpha0W2C zeros(n) zeros(n) alpha0W2D2]
lmi =[Phat Atel’ Btel’ Etel’;

Atel PTel zeros(6) zeros(6,3);

Btel zeros(6) PTel zeros(6,3);

Etel zeros(3,6) zeros(3,6) -eye(n)]
minimize lambda_max(lmi)

cvx_end
G = inv(omegaT1)(Y)
Bc = inv(omega2)
(W2)
Ac = inv(omega2)*(W1)






(Mark L. Stone) #4

Apparently, the code lines

alpha0 =sqrt(alpha*(1-alpha))
beta0 = sqrt(beta*(1-beta))

from your first post must be added to your latest post code to make the problem executable.

In any event, neither control theory in general, nor the specific paper in question, are in my areas of expertise. Therefore I have no insight as to what should be happening with your problem and with your specific input data/problem instance. Therefore I defer to others for any comments on expected results, or what should be done if the results are not what you expect or want.


(eliiiiiiiiiiiiiiiii) #5

Thank you for your response


About"blkdiag". Dimensions with subscripts do not match