```
Ps = 30;
Pr = 20;
Ns = 3;
Nr = 3;
Nd = 3;
N = [Ns,Nr,Nd];
NN = max(N);
% % % % % % % % % % % channel noise
nr = eye(NN);
nd = eye(NN);
% % % % % % % % % % % scaling matrices
CS = [eye(Ns) zeros(Ns,Nr)];
CR = [zeros(Nr,Ns) eye(Nr)];
% % % % % % % % % % %
itermax = 50 ; %%%%% maximum number of itterations.
% % % % % % % % % % % % channel gains
Hsr = (1/sqrt(2)).*(randn(Nr,Ns) + 1i*randn(Nr,Ns));% Channel coefficients for Soure-Relay Link
Hsd = (1/sqrt(2)).*(randn(Nd,Ns) + 1i*randn(Nd,Ns));% Channel coefficients for Soure-Destination Link
Hrd = (1/sqrt(2)).*(randn(Nd,Nr) + 1i*randn(Nd,Nr));% Channel coefficients for Relay-Destination Link
Hsrd = (1/sqrt(2)).*(randn(Nd,Ns+Nr) + 1i*randn(Nd,Ns+Nr));% Channel coefficients for {Soure,Relay}-Destination Link
QQhat = zeros (Ns,Ns);
QVhat = zeros (Ns,Ns);
% QQhat=1/2*(QQhat+QQhat')
Qnothat = zeros (Nr+Ns,Nr+Nd);
Throu=zeros(itermax,1);
for k = 1:itermax
cvx_begin SDP
variable QQ(Ns,Ns) hermitian semidefinite
variable QV(Ns,Ns) hermitian semidefinite
variable Qnot(Ns+Nr,Nr+Nd) hermitian semidefinite
a1 = log_det(nr + Hsr*(QQ+QV)*Hsr');
a2 = log_det(nd + Hsd*QV*Hsd');
a3 = log_det((nr+nd) + Hsd*QV*Hsd' + Hsrd*Qnot*Hsrd');
a4 = log_det(nr + Hsr*QVhat*Hsr');
a5 = (trace(Hsr'*inv(nr + Hsr*QVhat*Hsr')*Hsr*(QVhat-QV)));
% a6 = -trace(Hsr'*inv(nr + Hsr*QVhat*Hsr')*Hsr*QV);
Throuput = a1 ;
Throuput = Throuput + a2;
Throuput = Throuput + a3;
Throuput = Throuput + a4;
Throuput = Throuput + a5;
% Throuput = Throuput + a6;
maximize Throuput
subject to
trace(QV+CS*Qnot*CS') <= Ps;
trace(CR*Qnot*CR') <= Pr;
Qnot-CS'*QQ*CS == semidefinite(Ns+Nr,Nr+Nd);
QQ == semidefinite(Ns,Ns);
QV == semidefinite(Ns,Ns);
cvx_end
QQhat = QQ;
QVhat = QV;
Qnothat = Qnot;
Throu(k) = cvx_optval;
end
```