-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
67 lines (52 loc) · 1.98 KB
/
main.py
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
"""
Massive MIMO Network slicing on MAC layer simulation
"""
import json
import time
import sys
import os
import numpy as np
from utilities.trace import Trace
from simulation import Simulation
import argparse
sys.path.append(os.path.abspath('../'))
with open('default_config.json') as config_file:
config = json.load(config_file)
def isprime(N):
if N<=1 or N==4:
return False
else:
for i in range(2, N//2):
if N%i == 0:
return False
return True
if __name__ == '__main__':
# Load simulation parameters
parser = argparse.ArgumentParser()
parser.add_argument('--variance', action="store", type=float, default=None)
parser.add_argument('--period', action="store", type=float, default=None)
parser.add_argument('--d_on', action="store", type=float, default=None)
parser.add_argument('--d_off', action="store", type=float, default=None)
parser.add_argument('--no_periodic', action="store", type=int, default=None)
parser.add_argument('--no_file', action="store", type=int, default=None)
parser.add_argument('--seed', action="store", type=int, default=None)
parser.add_argument('--distribution', action="store", default="constant")
args = parser.parse_args()
# print(args.scheduler)
seed = args.seed
inner_periods = args.period
inner_variance = args.variance
t_on = args.d_on
t_off = args.d_off
np.random.seed(seed)
distribution = args.distribution
no_file = args.no_file
no_periodic = args.no_periodic
trace_file_path = 'trace/' + 'Trace_' + str(inner_periods) + '_' + str(inner_variance) + '-' + str(no_file) + '_' + str(no_periodic) + '_' + str(round(time.time())) + '_event_trace.csv'
trace = Trace(trace_file_path, log=True)
simulation = Simulation(config, no_file, no_periodic, inner_periods, inner_variance, t_on, t_off, distribution, trace, seed)
simulation.run()
# Close files
trace.close()
trace.plot_arrivals()
trace.show_plot()