Talk:Beginning with CVX

From Wikimization

(Difference between revisions)
Jump to: navigation, search
Current revision (02:00, 10 February 2009) (edit) (undo)
 
(13 intermediate revisions not shown.)
Line 3: Line 3:
</pre>
</pre>
--------------------------------------------------------------------
--------------------------------------------------------------------
-
Thanks for the idea<pre>full(W)</pre> it's great, it works!!! Thank you very much :D.
 
-
I have an answer, how to calculate the normalized eigenvector.
+
Thanks a lot for all the ideas, they all are greats.
-
Maybe? <pre>v_W=eig(full(W))/max(eig(full(W)))</pre>
+
The code still not working. I think I’m making thinks wrong (sure). I have a dude.
-
And... how does i have to undersand the result?
+
The new code could be:
-
 
+
-
In the tutorial don't explain anything, or, with type K in Matlab(is the variable I want to know) thats all?
+
-
 
+
-
Thanks a lot again.
+
-
 
+
-
Here is the new code:
+
<pre>
<pre>
 +
%0)Initialization
 +
clear all;
-
clear all;
+
%cvx_setup
n=2; m=1;
n=2; m=1;
A_a=3*eye(2*n,2*n)
A_a=3*eye(2*n,2*n)
B_a=4*eye(2*n,2*m)
B_a=4*eye(2*n,2*m)
 +
 +
%1)1
W=eye(4)
W=eye(4)
R=(zeros(2,4))
R=(zeros(2,4))
-
cvx_begin
+
%2)2
 +
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'
+
Epsilon1=1e-6;
 +
Epsilon2=1e-6;
 +
%3)3
 +
[v_W,D] = eig( full ( W ) )
 +
[v_H,D] = eig( full ( H ) )
-
variables p1 p2 Epsilon1 Epsilon2 W(4,4) R(2,4)
+
cvx_begin
-
+
variables p1 p2 W(4,4) R(2,4)
-
minimize (p1+p2)
+
if ( Epsilon1 - lamda_W )>(lamda_H+Epsilon2) CK=v_W'*W*v_W - Epsilon1*eye(2*n) ;
-
+
else CK=-Epsilon2*eye(2*n) - v_H'*H*v_H ;
-
subject to
+
end
-
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
+
-
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)
+
-
end
+
-
end
+
-
W>=Epsilon1*eye(2*n,2*n)
+
-
H<=-Epsilon2*eye(2*n,2*n)
+
-
cvx_end
+
minimize (p1+p2)
-
 
+
-
lamda_W=eig(full(W))
+
-
lamda_H=eig(H)
+
-
v_W=eig(full(W))/max(eig(full(W)))%%normalized eigenvector :|
+
-
v_H=eig(H)/max(eig(H))
+
-
 
+
-
para=0 %STOP
+
-
 
+
-
while para==0
+
-
if ( Epsilon1 - lamda_W )>(lamda_H+Epsilon2)
+
subject to
-
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)
 
-
 
-
minimize (p1+p2)
 
-
 
-
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)
-
for q=1
+
R(1,1)>=-p2
-
R(1,1)>=-p2
+
R(1,1)<=p2
-
R(1,1)<=p2
+
R(2,3)==R(1,1)
-
R(2,3)==R(1,1)
+
R(1,2)>=-p2
-
+
R(1,2)<=p2
-
R(1,2)>=-p2
+
R(2,4)==R(1,2)
-
R(1,2)<=p2
+
-
R(2,4)==R(1,2)
+
CK == 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
+
cvx_end
cvx_end
-
else
+
lamda_W = min ( eig ( full ( W ) ) )
-
 
+
lamda_H = max ( eig ( full ( H ) ) )
-
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)
+
-
+
-
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
+
-
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)
+
-
end
+
-
end
+
-
W>=Epsilon1*eye(2*n,2*n)
+
-
H<=-Epsilon2*eye(2*n,2*n)
+
-
+
-
v_H'*W*v_H<=-Epsilon2
+
-
 
+
-
cvx_end
+
-
end
+
-
 
+
-
lamda_W=eig(full(W))
+
-
lamda_H=eig(H)
+
-
v_W=eig(full(W))/min(eig(full(W)))%%Cálculo del normalized eigenvector
+
-
v_H=eig(H)/min(eig(H))
+
-
 
+
-
%STOP
+
-
if(lamda_W>=Epsilon1)
+
-
if(lamda_H<=-Epsilon2) para=1
+
-
else para = 0
+
-
end
+
-
else para =0
+
-
end
+
-
+
-
end
+
R
R
-
W
+
W=full(W)
K=R/W
K=R/W
 +
</pre>
</pre>

Current revision

lamda_W=eig(full(W))

Thanks a lot for all the ideas, they all are greats.

The code still not working. I think I’m making thinks wrong (sure). I have a dude.

The new code could be:

%0)Initialization
clear all;

%cvx_setup
n=2; m=1;

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

%1)1
W=eye(4)
R=(zeros(2,4))

%2)2
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=1e-6;
Epsilon2=1e-6;
%3)3
[v_W,D] = eig( full ( W ) )
[v_H,D] = eig( full ( H ) )
    
    cvx_begin
    variables p1 p2 W(4,4) R(2,4)
    if ( Epsilon1 - lamda_W )>(lamda_H+Epsilon2)    CK=v_W'*W*v_W - Epsilon1*eye(2*n) ;
    else CK=-Epsilon2*eye(2*n) - v_H'*H*v_H ;
    end
        
        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)
     
            CK  == semidefinite(2*n);                  

cvx_end

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

R
W=full(W)
K=R/W

Personal tools