# Talk:Beginning with CVX

(Difference between revisions)
 Revision as of 23:32, 3 February 2009 (edit)← Previous diff Revision as of 09:46, 4 February 2009 (edit) (undo)Next diff → Line 3: Line 3: -------------------------------------------------------------------- -------------------------------------------------------------------- - Thanks for the idea
full(W)
it's great, it works!!! Thank you very much :D. + Thanks for the ideas it's great. Thank you very much :D. I have an answer, how to calculate the normalized eigenvector. I have an answer, how to calculate the normalized eigenvector. - Maybe?
v_W=eig(full(W))/max(eig(full(W)))
+ Maybe?
[v_W]=eig(full(W))/norm ....
- And... how does i have to undersand the result? + I've changed Epsilon1, Epsilon2, they aren't a variable, I think they are constants. - In the tutorial don't explain anything, or, with type K in Matlab(is the variable I want to know) thats all? + I'm going to see how to initialice (I'm going to research in the references of my article (Cross fingers) Thanks a lot again. Thanks a lot again. Line 27: Line 27: R=(zeros(2,4)) R=(zeros(2,4)) - cvx_begin + H=W*A_a'+A_a*W-B_a*R-R'*B_a' - expression K(2*m,2*n) + lamda_W=min(eig(full(W))) - + lamda_H=max(eig(H)) - H=W*A_a'+A_a*W-B_a*R-R'*B_a' + - + - variables p1 p2 Epsilon1 Epsilon2 W(4,4) R(2,4) + - + - minimize (p1+p2) + - + - subject to + - for p=1:2 + - W(1,1)<=p1 + - W(2,2)<=p1 + - W(3,3)==W(1,1) + - W(4,4)==W(2,2) + - for q=1 + Epsilon1=1; - R(1,1)>=-p2 + Epsilon2=1; - R(1,1)<=p2 + - R(2,3)==R(1,1) + - + - R(1,2)>=-p2 + - R(1,2)<=p2 + - R(2,4)==R(1,2) + - end + - end + - W>=Epsilon1*eye(2*n,2*n) + - H<=-Epsilon2*eye(2*n,2*n) + - + - cvx_end + - lamda_W=eig(full(W)) + if(lamda_W>=Epsilon1) - lamda_H=eig(H) + if(lamda_H<=-Epsilon2) para=1 - v_W=eig(full(W))/max(eig(full(W)))%%normalized eigenvector :| + else para = 0 - v_H=eig(H)/max(eig(H)) + end + else para =0 + end + + + %v_W=eig(W)/(abs(eig(W))) + %v_W=eig(full(W))/abs(full(W))%%normalized eigenvector :| + %v_H=eig(H)/max(eig(H)) - para=0 %STOP while para==0 while para==0 + + [v_W,D] = eig(W) + [v_H,D] = eig(H) if ( Epsilon1 - lamda_W )>(lamda_H+Epsilon2) if ( Epsilon1 - lamda_W )>(lamda_H+Epsilon2) cvx_begin cvx_begin - + - H=W*A_a'+A_a*W-B_a*R-R'*B_a' + variables p1 p2 W(4,4) R(2,4) - + - variables p1 p2 Epsilon1 Epsilon2 W(4,4) R(2,4) + minimize (p1+p2) minimize (p1+p2) subject to subject to - for p=1:2 + W(1,1)<=p1 W(1,1)<=p1 W(2,2)<=p1 W(2,2)<=p1 + W(1,1)>=Epsilon1 + W(2,2)>=Epsilon1 W(3,3)==W(1,1) W(3,3)==W(1,1) W(4,4)==W(2,2) W(4,4)==W(2,2) + + R(1,1)>=-p2 + R(1,1)<=p2 + R(2,3)==R(1,1) - for q=1 + R(1,2)>=-p2 - R(1,1)>=-p2 + R(1,2)<=p2 - R(1,1)<=p2 + R(2,4)==R(1,2) - R(2,3)==R(1,1) + - + H=W*A_a'+A_a*W-B_a*R-R'*B_a' - R(1,2)>=-p2 + - R(1,2)<=p2 + W - Epsilon1*eye(2*n) == semidefinite(2*n); - R(2,4)==R(1,2) + Epsilon2*eye(2*n) + H == -semidefinite(2*n); - end + - end + - W>=Epsilon1*eye(2*n,2*n) + - H<=-Epsilon2*eye(2*n,2*n) + - v_W'*W*v_w>=Epsilon1 + v_W'*W*v_W>=Epsilon1*eye(4) cvx_end cvx_end Line 105: Line 90: cvx_begin cvx_begin - - H=W*A_a'+A_a*W-B_a*R-R'*B_a' - variables p1 p2 Epsilon1 Epsilon2 W(4,4) R(2,4) + variables p1 p2 W(4,4) R(2,4) minimize (p1+p2) minimize (p1+p2) subject to subject to - for p=1:2 + + W(1,1)>=Epsilon1 + W(2,2)>=Epsilon1 + W(1,1)<=p1 W(1,1)<=p1 W(2,2)<=p1 W(2,2)<=p1 Line 119: Line 105: W(4,4)==W(2,2) W(4,4)==W(2,2) - for q=1 + R(1,1)>=-p2 R(1,1)>=-p2 R(1,1)<=p2 R(1,1)<=p2 Line 127: Line 113: R(1,2)<=p2 R(1,2)<=p2 R(2,4)==R(1,2) R(2,4)==R(1,2) - end + - end + H=W*A_a'+A_a*W-B_a*R-R'*B_a' - W>=Epsilon1*eye(2*n,2*n) + - H<=-Epsilon2*eye(2*n,2*n) + - v_H'*W*v_H<=-Epsilon2 + W - Epsilon1*eye(2*n) == semidefinite(2*n); + Epsilon2*eye(2*n) + H == -semidefinite(2*n); + + v_H'*H*v_H<=-Epsilon2*eye(4) cvx_end cvx_end end end - lamda_W=eig(full(W)) + lamda_W=min(eig(full(W))) - lamda_H=eig(H) + lamda_H=max(eig(H)) - v_W=eig(full(W))/min(eig(full(W)))%%Cálculo del normalized eigenvector + - v_H=eig(H)/min(eig(H)) + % v_W=eig(full(W))/max(eig(full(W)))%%Cálculo del normalized eigenvector + % v_H=eig(H)/max(eig(H)) %STOP %STOP Line 154: Line 142: R R W W - K=R/W + K=R/W - +

## Revision as of 09:46, 4 February 2009

```lamda_W=eig(full(W))
```

Thanks for the ideas it's great. Thank you very much :D.

I have an answer, how to calculate the normalized eigenvector.

Maybe?
`[v_W]=eig(full(W))/norm ....`

I've changed Epsilon1, Epsilon2, they aren't a variable, I think they are constants.

I'm going to see how to initialice (I'm going to research in the references of my article (Cross fingers)

Thanks a lot again.

Here is the new code:

```
clear all;
n=2; m=1;

A_a=3*eye(2*n,2*n)
B_a=4*eye(2*n,2*m)
W=eye(4)
R=(zeros(2,4))

H=W*A_a'+A_a*W-B_a*R-R'*B_a'

lamda_W=min(eig(full(W)))
lamda_H=max(eig(H))

Epsilon1=1;
Epsilon2=1;

if(lamda_W>=Epsilon1)
if(lamda_H<=-Epsilon2)     para=1
else para = 0
end
else para =0
end

%v_W=eig(W)/(abs(eig(W)))
%v_W=eig(full(W))/abs(full(W))%%normalized eigenvector :|
%v_H=eig(H)/max(eig(H))

while para==0

[v_W,D] = eig(W)
[v_H,D] = eig(H)

if ( Epsilon1 - lamda_W )>(lamda_H+Epsilon2)

cvx_begin

variables p1 p2 W(4,4) R(2,4)

minimize (p1+p2)

subject to

W(1,1)<=p1
W(2,2)<=p1
W(1,1)>=Epsilon1
W(2,2)>=Epsilon1
W(3,3)==W(1,1)
W(4,4)==W(2,2)

R(1,1)>=-p2
R(1,1)<=p2
R(2,3)==R(1,1)

R(1,2)>=-p2
R(1,2)<=p2
R(2,4)==R(1,2)

H=W*A_a'+A_a*W-B_a*R-R'*B_a'

W - Epsilon1*eye(2*n) == semidefinite(2*n);
Epsilon2*eye(2*n) + H == -semidefinite(2*n);

v_W'*W*v_W>=Epsilon1*eye(4)

cvx_end

else

cvx_begin

variables p1 p2 W(4,4) R(2,4)

minimize (p1+p2)

subject to

W(1,1)>=Epsilon1
W(2,2)>=Epsilon1

W(1,1)<=p1
W(2,2)<=p1
W(3,3)==W(1,1)
W(4,4)==W(2,2)

R(1,1)>=-p2
R(1,1)<=p2
R(2,3)==R(1,1)

R(1,2)>=-p2
R(1,2)<=p2
R(2,4)==R(1,2)

H=W*A_a'+A_a*W-B_a*R-R'*B_a'

W - Epsilon1*eye(2*n) == semidefinite(2*n);
Epsilon2*eye(2*n) + H == -semidefinite(2*n);

v_H'*H*v_H<=-Epsilon2*eye(4)

cvx_end
end

lamda_W=min(eig(full(W)))
lamda_H=max(eig(H))

% v_W=eig(full(W))/max(eig(full(W)))%%Cálculo del normalized eigenvector
% v_H=eig(H)/max(eig(H))

%STOP
if(lamda_W>=Epsilon1)
if(lamda_H<=-Epsilon2)     para=1
else para = 0
end
else para =0
end

end

R
W
K=R/W```