-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulate.m
More file actions
74 lines (69 loc) · 3.28 KB
/
Copy pathsimulate.m
File metadata and controls
74 lines (69 loc) · 3.28 KB
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
clearvars;
% input parameters for the simulation:
numberOfLoadPoints = 40;
logSpacing = false;
% rafLengths = [500];
rafLengths = [35];
% inputPar.numberOfSources = 20000;
inputPar.numberOfSources = 100;
inputPar.queueLength = 1000000; % same queue length for every source
% inputPar.queueLength = randi([1800 2200],numberOfSources,1); % variable queue length
% inputPar.activeModes = {'sul'}; % a cell array with any of the following: 'tul', terrestrial uplink, 'sul', satellite UL, 'sdl', satellite downlink, 'tdl', terrestrial DL
inputPar.activeModes = {'tul'}; % a cell array with any of the following: 'tul', terrestrial uplink, 'sul', satellite UL, 'sdl', satellite downlink, 'tdl', terrestrial DL
inputPar.timeConstraint = 100000;
inputPar.retryLimit = 1;
inputPar.sicMinIter = 1;
% inputPar.sicMaxIter = inf(1);
inputPar.sicMaxIter = 2;
% inputPar.tulAccMeth = 'csa-nc';
inputPar.tulAccMeth = 'csa';
% inputPar.sulAccMeth = 'crdsa-nc';
% Goff = logspace(-2,0,numberOfLoadPoints)
Goff = linspace(0.01,1.5,numberOfLoadPoints)
% Goff = [0.01:0.05:0.4 0.4:0.02:0.6 0.6:0.05:1]
% numberOfLoadPoints = numel(Goff);
if logSpacing == 1
proba = logspace(-3,-0.7,numberOfLoadPoints);
elseif logSpacing == 0
proba = linspace(0.01,0.017,numberOfLoadPoints); %csa
proba = linspace(0.001,0.025,numberOfLoadPoints); % crdsa
proba = Goff * rafLengths / inputPar.numberOfSources
proba(proba>1) = 1;
end
fprintf('Started at \n')
fprintf('%u ',fix(clock))
fprintf('\n')
t1 = tic;
ii = 0;
for modeIndex = inputPar.activeModes
for rafIndex = rafLengths
ii = ii + 1;
inputPar.rafLength = rafIndex;
for lpIndex = 1:numberOfLoadPoints
t2=tic;
inputPar.poissonThreshold = proba(lpIndex);
[~,~,~,~,~,~,output] = randomAccess(inputPar.numberOfSources,inputPar.queueLength,char(modeIndex),inputPar);
% if numel(queueLength) == 1
% results(ii).load(lpIndex) = queueLength * numberOfSources ./ (output.rafLength * output.duration);
% elseif iscolumn(queueLength)
results(ii).load(lpIndex) = sum(sum(output.firstTx > 0,2)) ./ (output.rafLength * output.duration);
% end
results(ii).throughput(lpIndex) = sum(sum(output.queues,2)) ./ (output.rafLength * output.duration);
results(ii).meanDelay(lpIndex) = mean(nonzeros( ((output.retries -1) .* output.rafLength + output.delaySlot) .* output.queues ));
assert(results(ii).load(lpIndex) >= results(ii).throughput(lpIndex));
validateResults(inputPar.queueLength,output);
fprintf('Mode %s - Load %f Throughput %f. \n %.0f seconds for Simulation %u of %u. Elapsed time %u m %.0f s. \n',char(modeIndex),results(ii).load(lpIndex),results(ii).throughput(lpIndex),toc(t2),(lpIndex + (ii-1)*numel(proba)),numel(inputPar.activeModes)*numel(rafLengths)*numberOfLoadPoints,floor(toc(t1)/60),toc(t1)-floor(toc(t1)/60)*60);
end
results(ii).mode = char(modeIndex);
results(ii).rafLength = rafIndex;
end
end
[path,~,~] = fileparts(mfilename('fullpath'));
datetime = datestr(now,30);
name = strcat('jsac-sim-',datetime);
save(fullfile(path,name));
totalTime = toc(t1);
fprintf('Total time elapsed: %u hours %2.0f minutes (%.0f seconds).\n',fix(totalTime/3600),(fix(totalTime/60)-fix(totalTime/3600)*60),totalTime);
fprintf('Ended at \n')
fprintf('%u ',fix(clock))
fprintf('\n')