clear;
cvx_setup
%=================================
%SystemSetup
%=================================
%numbers of antennas
N=4;
%numbers of users
K=2;
sigma = 1.0;% set noise 1.
dr=1;%源到中继的距离
d1=1;%用户1的距离
d2=0.2;%用户2的距离(近)
coe_dr=sqrt(dr^(-2));% 系数
coe_d1=sqrt(d1^(-2));
coe_d2=sqrt(d2^(-2));
r_2 = [];
% for Pr_dB=10:5:30
% Pr=10^(0.1Pr_dB);
Ps=100;%w不是dB
Pr=100;%w不是dB
%Pr=20;%according to fig to set power of relay.(dB)
% P1=0.8Ps; %when 0 interation the value of p1.(dB)
% P1=0.6*Ps;
% P2=Ps-P1; %when 0 interation the value of p2.(dB)
CH_iter_max=10;%信道的数目
bug_iter=0;%解不出来的迭代次数(个数)
r2_sum=0;%r2速率的总和
% for CH_iter=1:CH_iter_max %换信道
n=16;% the dimension of f
% h=coe_dr*(randn(N,1)+1irandn(N,1));
% g1=coe_d1(randn(N,1)+1irandn(N,1));
% g2=coe_d2(randn(N,1)+1i*randn(N,1));
h=coe_dr*(rand(N,1)+1irand(N,1));
g1=coe_d1(rand(N,1)+1irand(N,1));
g2=coe_d2(rand(N,1)+1i*rand(N,1));
F=randn(N,N);
I1=eye(N);%setup unit matrix N dimension.
I2=eye(N^2);
f=vec(F);
W=f*f’;
G_pre=0.1;
a=60;
b=90;
P1=SelectP( a,b,1 );
P2=Ps-P1;
B_1_1=P1kron((conj(h)h.’),g1g1’);%(13)k=1,j=1
B_2_1=P1kron((conj(h)h.’),g2g2’);%(13)k=1,j=2
B_2_2=P2*kron((conj(h)h.’),g2g2’);%(13)k=2,j=2
b_1=kron((conj(h)h.’),g1g1’);%mu_1没有P1,后面需要
b_2=kron((conj(h)h.’),g2g2’);%mu_2
C_1_1=P2kron(conj(h)h.’,g1g1’)+kron(sigmasigmaI1,g1g1’);%(14)k=1,j=1
C_2_1=P2kron(conj(h)h.’,g2g2’)+kron(sigmasigmaI1,g2g2’);%(14)k=1,j=2
C_2_2=kron(sigmasigmaI1,g2g2’);%(14)k=2,j=2
c_1=kron(sigmasigmaI1,g1g1’);%C_1_1后面的一部分
c_2=kron(sigmasigmaI1,g2*g2’);
D=Pskron(conj(h)h.’,I1)+sigmasigmaI2;%(16)
Q_1_1=C_1_1+sigmasigmaD/Pr;%(21)k=1,j=1
Q_2_1=C_2_1+sigmasigmaD/Pr;%(21)k=1,j=2
Q_2_2=C_2_2+sigmasigmaD/Pr;%(21)k=2,j=2
r1=0.6;
t1=2^(2*r1)-1;%(7)
R1=B_1_1-t1Q_1_1;
R2=B_2_1-t1Q_2_1;
%=================================
%Initialize
%=================================
%=================================
%Repeat
%=================================
%==================================
%obtain f(m) by solving (34)iteratively with {Pk(m-1)}
% %==================================
% G_pre=0.1;
% a=60;
% b=90;
% P1=SelectP( a,b,1 );
while(1)
cvx_begin sdp quiet
variables W(NN,NN)
maximize P2trace(b_2W)/(trace((c_2+DPr^(-1))W))
subject to
real(P1trace(b_1W))-real(P2trace(b_1W))t1-real(trace(c_1+DPr^(-1)))t1>=0;
real(P1trace(b_2W))-real(P2trace(b_2*W))t1-real(trace(c_2+DPr^(-1)))*t1>=0
P2==Ps-P1;
cvx_end
cvx_optval
if cvx_optval>G_pre
a=P1;
P1=SelectP(a,b,1);
G_pre=cvx_optval;
else
b=P1;
P1=SelectP(a,b,2);
G_pre=cvx_optval;
end
if abs(b-a)<0.1
break;
end
the problem is:
错误使用 ./ (line 42)
Disciplined convex programming error:
Invalid operation: {complex affine} / {complex affine}
出错 / (line 17)
出错 maximize (line 8)
出错 SDP (line 95)
maximize P2trace(b_2W)/(trace((c_2+D*Pr^(-1))*W))