Problem with writing CVX with SDP solution

hi. i don’t know my code is true or not. please help me its very crucial

W_1 = w_1w_1’ and w_1 is a M1 vector and should be complex and W_2 is like W_1.
H_01 = h_01h_01, that h_01 is a complex gaussian channel vector M1 with zero mean and variance one.
H_cu_1 = h_cu_1h_cu_1’ and H_cu_2 = h_cu_2h_cu_2’ like i said about H_01.

cvx_begin
variable W_1(M,M) hermitian complex;
variable W_2(M,M) hermitian complex;
maximize etareal((trace(H_01W_1)+trace(H_01*W_2)));

subject to
    W_1==semidefinite(M);
    W_2==semidefinite(M);
    real((trace(W_1)) + (trace(W_2))) <= P_w_max;
    real(trace(H_cu_1*W_2)) + sigma2_w <= real(trace(H_cu_1*W_1))/(saai_w);
    real(trace(H_cu_2*W_1)) + sigma2_w <= real(trace(H_cu_2*W_2))/(saai_w);

cvx_end

w_1=eig(W_1);
w_2=eig(W_2);

Use of hermitian_semidefinite instead of semidefinite would be correct, but I don’t know whether use of semidefinite is incorrect.

Other than that, nothing is obviously wrong, but as with your previous question, it is up to you to determine what problem you are solving, and in particular, your decision to declare variables as complex and to apply real in your formulation.

i don’t wanna use real function. i have to. because there is a error in cvx that ‘objective function must be real’.
the final w_1 and w_2 is not seem to be true i think.

w_1 =

0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.4997

w_2 =

0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.5001

and i think this is wrong

The objective function must evaluate to a real scalar. Both sides of inequality constraints must be real. That;s just the way it is.

Your listing of the values of W_1 and W_2 (presuming they are not for some different variables w_1, w_2) and presuming they are for all elements, don’t make any sense because they each show only 7 elements, but those variables must be square matrices.

after cvx evaluates W_1 and W_2 that is a square matrix as the article says i have to extract the principal eigenvector of W_1 and W_2. as you can see i use eig() function for this purpose that is wrong i think . because eig() function gives me the eigenvalues not eigenvectors. but i don’t know how to evaluate principal eigenvector.

Sorry, I missed the

w_1=eig(W_1);
w_2=eig(W_2);

To the number of digits you have shown, W_1 and W_2 are both rank one matrices, i.e., psd or hsd with only one positive eigenvalue. Are they supposed to be rank one matrices?

Eigenvectors are returned in the optional 2nd output argument of eig.

The principal eigenvector is the column of the 2nd output argument corresponding to the largest eigenvalue.

help eig

eig Eigenvalues and eigenvectors.
E = eig(A) produces a column vector E containing the eigenvalues of
a square matrix A.

[V,D] = eig(A) produces a diagonal matrix D of eigenvalues and 
a full matrix V whose columns are the corresponding eigenvectors  
so that A*V = V*D.

[V,D,W] = eig(A) also produces a full matrix W whose columns are the
corresponding left eigenvectors so that W'*A = D*W'.

[...] = eig(A,'nobalance') performs the computation with balancing
disabled, which sometimes gives more accurate results for certain
problems with unusual scaling. If A is symmetric, eig(A,'nobalance')
is ignored since A is already balanced.

[...] = eig(A,'balance') is the same as eig(A).

E = eig(A,B) produces a column vector E containing the generalized 
eigenvalues of square matrices A and B.

[V,D] = eig(A,B) produces a diagonal matrix D of generalized
eigenvalues and a full matrix V whose columns are the corresponding
eigenvectors so that A*V = B*V*D.

[V,D,W] = eig(A,B) also produces a full matrix W whose columns are the
corresponding left eigenvectors so that W'*A = D*W'*B.

[...] = eig(A,B,'chol') is the same as eig(A,B) for symmetric A and
symmetric positive definite B.  It computes the generalized eigenvalues
of A and B using the Cholesky factorization of B.

[...] = eig(A,B,'qz') ignores the symmetry of A and B and uses the QZ
algorithm. In general, the two algorithms return the same result,
however using the QZ algorithm may be more stable for certain problems.
The flag is ignored when A or B are not symmetric.

[...] = eig(...,'vector') returns eigenvalues in a column vector 
instead of a diagonal matrix.

[...] = eig(...,'matrix') returns eigenvalues in a diagonal matrix
instead of a column vector.

yes they have to be rank one. this is the relaxation of the article.
so when i have only one eigenvalue, you mean my principal eigenvector is the last column of the eigenvector matrix.
for example:
D =

0.0000         0         0         0         0         0         0
     0    0.0000         0         0         0         0         0
     0         0    0.0000         0         0         0         0
     0         0         0    0.0000         0         0         0
     0         0         0         0    0.0000         0         0
     0         0         0         0         0    0.0000         0
     0         0         0         0         0         0    0.5004

this is my diagonal eigenvalue matrix. the last column of eigenvector is principal. this is true??

Yes, the principal eigenvector is the jth column of the eigenvector matrix if the largest eigenvalue is in the jth column of the eigenvalue matrix. .

1 Like

Thank you so much Mr. Stone. you really helped me with this problem. thank you very much