# How to solve this problem in CVX?

I want to solve a problem like this

Here is my cvx code

cvx_begin sdp
variable W_k(para.M,para.M*para.K) complex
variable Wk(para.M,para.M) complex
expression t
sum=cvx(zeros(para.M,para.M));
tr_sum=0;

``````       minimize(-t)
subject to
for i=1:para.K
Wk=W_k(:,para.M*(i-1)+1:para.M*i);
Wk_sum=sum+Wk;
tr_sum=tr_sum+trace(Wk);
Wk>=0;
end
[trace(A1'*A1*Wk_sum)-t   trace(A1'*A*Wk_sum);...
trace(A'*A1*Wk_sum)   trace(A'*A*Wk_sum)]==hermitian_semidefinite(2);
tr_sum<=para.Pt;
for k=1:(para.K)
h=H(:,k);
ttr=0;
for f=1:para.K
if f ~= k
Wk=W_k(:,para.M*(f-1)+1:para.M*f);
ttr=ttr+trace(Wk*h*h');
end
end
Wk=W_k(:,para.M*(k-1)+1:para.M*k);
trace(Wk*h*h')-gamma*ttr>=gamma*para.sigma_k;
end
cvx_end
``````

Here is error information.

try `real(tr_sum)<=para.Pt;`

You need to declare `W` as complex hermitian. in order for `W >= 0` to be treated as a smidefinite constraint. Or just declare `W` as hermitian semidefinite, and then you don’t even need `W >= 0`.

Perhaps that will make your already encountered error go away, even without the real(). Or maybe placing parentheses around `A1'*A` which couldn’t hurt., and might help. You can use the real() if you want to.

Thank you for your help.Then there is new problem.

As it is now, t is an expression, which by default, until overriden, has value zero. So you are minimizing -0, and the t in the constraint has value 0.

The warning is because Wk is declared as a variable, but you then assign it, and hence it becomes an expression rather than variable. I suggest you declare

``````variable t
variable W_k(para.M,para.M*para.K) hermitian semidefinite
``````

now you don’t need to any additional semidefinite constraints for W_k.

Then use expressions such as
`trace((A'*A)*sum(W_k,3))-t` which is the upper left block of the block semidefinite constraint. You can do that instead of the complicated indexing mess you now have.

@jackfsuia might have a clever vectorized way of writing the middle constraints. But you can always use a for loop, without your messy indexing.