-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidea_myo_sim.m
33 lines (28 loc) · 902 Bytes
/
idea_myo_sim.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
function [tdr_myo_sim] = idea_myo_sim(pi_myo)
% Simulate the myopic scheme (idealized)
% Declare global variables
% See main_without_retran.m
global N D lambda sigma NE
% Run independent numerical experiments
success = zeros(1, NE);
parfor ne = 1:NE
% Simulate the packet arrival
% status: 0 (inactive), 1 (active)
status = rand(1, N) < lambda;
% Consider an arbitrary node as the tagged node
tagged_node = randi([1 N]);
for t = 1:D
if status(tagged_node) > 0
% Simulate the random access
access = (rand(1, N) < pi_myo(sum(status))) .* (status > 0);
status = status - access;
if access(tagged_node) * sum(access) == 1 && rand < sigma
success(ne) = 1;
end
else
break
end
end
end
% Compute the TDR performance
tdr_myo_sim = sum(success) / NE / lambda;