-
Notifications
You must be signed in to change notification settings - Fork 15
/
analyze_feasibility.m
106 lines (82 loc) · 3.02 KB
/
analyze_feasibility.m
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
97
98
99
100
101
102
103
104
105
106
% Copyright (C) 2014-2016 Bho Matthiesen, Alessio Zappone
%
% This program is used in the article:
%
% Alessio Zappone, Bho Matthiesen, and Eduard Jorswieck, "Energy Efficiency in
% MIMO Underlay and Overlay Device-to-Device Communications and Cognitive Radio
% Systems," IEEE Transactions on Signal Processing, vol. 65, no. 4, pp.
% 1026-1041 Feb. 2017, https://doi.org/10.1109/TSP.2016.2626249
%
%
% License:
% This program is licensed under the GPLv2 license. If you in any way use this
% code for research that results in publications, please cite our original
% article listed above.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
P1dBWrange = [-30 -20];
R1fac = [1.25 1.5 2];
P2dBW = -60:2:40;
P2 = 10.^(P2dBW/10);
P1range = 10.^(P1dBWrange/10);
N0 = -174; % dBm/Hz (noise density)
B = 180e3; % Hz (bandwidth)
F = 3; % dB (noise figure)
Nvar = 10^(N0/10-3) * B * 10^(F/10);
alpha = 10;
load channels.mat
h11 = p.channels.h11;
h21 = p.channels.h21;
Ht = p.channels.Ht;
%% make fmax
fmax = zeros(p.drops, length(P1range), length(P2dBW));
assert(all(sort(P2dBW)==P2dBW)); % we're relying on P2dBW being ordered (for align)
parfor drop = 1:p.drops
tmp = zeros(length(P1range), length(P2dBW));
for P1idx = 1:length(P1range)
P1 = P1range(P1idx);
for snr = 1:length(P2dBW)
% bounds
R1_lb = log2(1 + P1/Nvar * norm(h11(:,:,drop))^2);
a = norm(h11(:,:,drop))^2 * P2(snr) / alpha / (Nvar*norm(h11(:,:,drop))^2 + P1 *norm(Ht(:,:,drop)*h11(:,:,drop))^2);
A = sqrt(a) * (h21(:,:,drop)/norm(h21(:,:,drop))) * ((Ht(:,:,drop)*h11(:,:,drop))'/norm(Ht(:,:,drop)*h11(:,:,drop)));
R1_ub = .5 * log2(1 + P1 *norm(h11(:,:,drop))^2 / Nvar + P1 /norm(h11(:,:,drop))^2 * (abs(h21(:,:,drop)'*A*Ht(:,:,drop)*h11(:,:,drop))^2)/(Nvar + h21(:,:,drop)'*(Nvar*A*A')*h21(:,:,drop)) );
tmp(P1idx, snr) = R1_ub / R1_lb;
end
end
fmax(drop, :, :) = tmp;
end
%% analyze
tmp = permute(fmax,[3 2 1]);
abscnt = sum(tmp >= max(R1fac), 3)
relcnt = abscnt/size(tmp,3)
fprintf('Maximum # of drops: %d\n', min(min(abscnt)))
%% plot N(P2; R1fac)
relcnt = cell(1, length(R1fac));
leg = cell(length(P1dBWrange), length(R1fac));
tmp = permute(fmax,[3 2 1]);
for R1idx = 1:length(R1fac)
relcnt{R1idx} = sum(tmp >= R1fac(R1idx), 3) / size(tmp,3);
for ii=1:length(P1dBWrange)
leg{ii,R1idx} = sprintf('%ddBW %g', P1dBWrange(ii), R1fac(R1idx));
end
end
% r = [];
% for ii=1:length(R1fac)
% r = [r ii:length(R1fac):numel(leg)];
% end
dat = horzcat(relcnt{:});
% dat = dat(:,r);
% leg = leg';
figure
plot(P2dBW, dat)
legend(reshape(leg, numel(leg), 1), 'Location', 'EastOutside')
%% save results
keys = horzcat('P2dBW', reshape(leg, 1, numel(leg)));
keys = regexprep(keys, '\s+', ' ');
cd mpi
sav('../tex/feasibility.dat', horzcat(P2dBW', dat), keys);
cd ..