-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun_experiment.py
66 lines (49 loc) · 1.95 KB
/
run_experiment.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
# Python 3.6
#
import sys
import os
from IPython.core.debugger import set_trace
def initialize():
if not os.path.exists("./gsim"):
# If this behavior were changed, the output file storage functionality should be
# modified accordingly.
print(
"Error: `run_experiment` must be invoked from the folder where it is defined"
)
quit()
sys.path.insert(1, './gsim/')
initialize()
########################################################################
# Select experiment file:
from Experiments.spectrum_surveying_experiments import ExperimentSet
# from Experiments.route_planning_experiments import ExperimentSet
########################################################################
if (len(sys.argv) < 2):
print(
'Usage: python3 ', sys.argv[0],
'[option] <experiment_index> [cmdl_arg1 [cmdl_arg2 ... [cmdl_argN]]]')
print(""" <experiment_index>: identifier for the experiment
cmdl_argn: n-th argument to the experiment function (optional)
OPTIONS:
-p : plot only the stored results, do not run the simulations.
-pe : plot only the stored results, do not run the simulations. Export the figures as pdf.
""")
quit()
l_args = sys.argv
if l_args[1] == "-p":
# Plot only
ExperimentSet.plot_only(l_args[2])
elif l_args[1] == "-pe":
ExperimentSet.plot_only(l_args[2], save_pdf=True)
else:
if (len(l_args) < 3):
cmdl_args = ""
else:
cmdl_args = l_args[2:]
ExperimentSet.run_experiment(l_args[1], cmdl_args)
# if 0:
# logging.basicConfig(level=logging.INFO, filename ='LogFile_%s.txt' /
# % experiment_number)
# sys.stdout = open('LogFile_%s.txt' % experiment_number, 'a')
# sys.stderr = open('LogFile_%s.txt' % experiment_number, 'a')
# experiment_name = 'run_experiment_%s'%experiment_number