The âloopâ is the while-loop of main-function.

No, I donât solve a series of different problem.

Yes, I only show you the constraint and expression about `A2_p`

.

```
$ main():
count = 0;
R = 1000*ones(1,30);
while(1){
count += 1;
t = optimize_q (para);
R(count) = R_cal(para);
if( abs(R(count) - R(count)) <1e-4 && count != 1)
{ break; }
}
$ function optimize_q (para), Solver is MOSEK
CVX_begin
variable q(2,N)
variable t nonnegative
variable ze(Uk,N)
variable se(1,N)
variable A2(1,N)
variable A3(1,N)
expression A2_p(1,N)
expression R4(1,N)
expression Re(Uk,N)
for n=1:N
A2_p(n) = pow_p(A2(n),alpha);
R4(n) =pow_pos( A2_p(n)+inv_pos(A3(n)), 2 ) ;
end
for n=1:N
for k=1:Uk
Re(k,n) = rel_entr( ze(k,n)/P(k,n),1+(ze(k,n)/P(k,n)) ) +rel_entr( 1+(ze(k,n)/P(k,n)),ze(k,n)/P(k,n) );
end
end
maximize t
subject to
for k=1:Uk
-sum(Re(k,:)) >= t;
end
for n=1:N
for k=1:Uk
ze(k,n) <= 2/se_f(n) - se(n)/(se_f(n)^2) ;
end
end
for n=1:N
se(n)>= pow_p(A2(n),-alpha) + pow_p(A3(n),-2) + 2* R4(n) ;
pow_pos(A3(n),2) <= power(norm(q_f(:,n)-q1(:)),2) + 2*(q_f(:,n)-q1(:))'*(q(:,n)-q_f(:,n)) + H3^2 ;
pow_pos(A2(n),2) <= power(norm(q_f(:,n)-q2(:)),2) + 2*(q_f(:,n)-q2(:))'*(q(:,n)-q_f(:,n)) + H2^2;
end
CVX_end
```