-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAlg_1.asv
96 lines (86 loc) · 2.59 KB
/
Alg_1.asv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
function [pc,pk]=Alg_1(Nt,K,pc,pk,H_m,Pt,M,N0)
%%%
n=2;
A=[];
A(2)=-10;
A(1)=10;
e=0.01;
while abs((A(n)-A(n-1))/A(n))>=e
for m=1:M
for k=1:K
T_ck(k,m)=abs(H_m(:,k,m)'*pc)^2+sum(abs(H_m(:,k,m)'*pk).^2)+N0;
T_k(k,m)=sum(abs(H_m(:,k,m)'*pk).^2)+N0;
S_ck(k,m)=abs(H_m(:,k,m)'*pc)^2;
S_k(k,m)=abs(H_m(:,k,m)'*pk(:,k))^2;
I_ck(k,m)=T_k(k,m);
I_k(k,m)=I_ck(k,m)-S_k(k,m);
%%%
g_ck_m(k,m)=pc'*H_m(:,k,m)/T_ck(k,m);
g_k_m(k,m)=pk(:,k)'*H_m(:,k,m)/T_k(k,m);
u_ck_m(k,m)=T_ck(k,m)/I_ck(k,m);
u_k_m(k,m)=T_k(k,m)/I_k(k,m);
%%%
t_ck_m(k,m)=u_ck_m(k,m)*abs(g_ck_m(k,m))^2;
t_k_m(k,m)=u_k_m(k,m)*abs(g_k_m(k,m))^2;
psi_ck_m(:,:,k,m)=t_ck_m(k,m)*H_m(:,k,m)*H_m(:,k,m)';
psi_k_m(:,:,k,m)=t_k_m(k,m)*H_m(:,k,m)*H_m(:,k,m)';
f_ck_m(:,k,m)=u_ck_m(k,m)*H_m(:,k,m)*g_ck_m(k,m)';
f_k_m(:,k,m)=u_k_m(k,m)*H_m(:,k,m)*g_k_m(k,m)';
v_ck_m(k,m)=log2(u_ck_m(k,m));
v_k_m(k,m)=log2(u_k_m(k,m));
end
end
%averaging=bar{variable in paper}
for k=1:K
t_ck(k)=mean(t_ck_m(k,:));
t_k(k)=mean(t_k_m(k,:));
psi_ck(:,:,k)=(mean(psi_ck_m(:,:,k,:),4)+mean(psi_ck_m(:,:,k,:),4)')/2;
psi_k(:,:,k)=(mean(psi_k_m(:,:,k,:),4)+mean(psi_k_m(:,:,k,:),4)')/2;
f_ck(:,k)=mean(f_ck_m(:,k,:),3);
f_k(:,k)=mean(f_k_m(:,k,:),3);
v_ck(k)=mean(v_ck_m(k,:));
v_k(k)=mean(v_k_m(k,:));
%%%
u_ck(k)=mean(u_ck_m(k,:));
u_k(k)=mean(u_k_m(k,:));
end
clearvars a c ac
cvx_begin quiet
%cvx_begin
variable xi_c(1,1) nonnegative
variable P(Nt*(K+1),1) complex
% variable a(K,K) complex
% variable c(K)
% variable ac(K,K) complex
% variable cc(K)
% PP=reshape(P,Nt,K+1);
% PK=PP(:,2:K+1);
% Pc=PP(:,1);
for k=1:K
for i=1:K
a(k,i)=P((Nt*i+1):Nt*(i+1),1)'*psi_k(:,:,k)*P((Nt*i+1):Nt*(i+1),1);
end
c(k)=real(f_k(:,k)'*P((Nt*k+1):Nt*(k+1),1));
end
xx=xi_c+sum(sum(a))+sum(N0*t_k+u_k-v_k)+sum(-2.*c);
maximize(-xx)
subject to
for k=1:K
for i=1:k
ac(k,i)=P(Nt*i+1:Nt*(i+1),1)'*psi_ck(:,:,k)*P((Nt*i+1):Nt*(i+1),1);
end
P(1:Nt,1)'*psi_ck(:,:,k)*P(1:Nt,1)+N0*t_ck-2*real(f_ck(:,k)'*P(1:Nt,1))+u_ck-v_ck<=xi_c;
end
P'*P<=Pt;
cvx_end
%%%
PP=reshape(P,Nt,K+1);
pc=PP(:,1);
pk=PP(:,2:K+1);
n=n+1;
A(n)=xx;
P'*P
Pt
end
A
end