forked from mburq/dynamic_optimization_benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
38 lines (34 loc) · 1.14 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
from src.sim import simulation
from generate_sim_plan import parameter_set, generate_sim_plan
import multiprocessing as mp
import time
import sys
def run_sim(p):
sim = simulation(p)
sim.run()
def run_multiple_sim(sim_plan):
for p in sim_plan:
run_sim(p)
def run_paralell_sim(sim_plan):
with mp.Pool(processes=mp.cpu_count() - 1) as pool:
pool.map(run_sim, sim_plan, chunksize=1)
if __name__ == '__main__':
if len(sys.argv) == 4:
T = int(sys.argv[1])
alg = sys.argv[2]
arr = sys.argv[3]
p = parameter_set(T, alg, arr,
save=False,
batch=25,
patience=15,
alpha=1,
dep_rate=50,
r_seed = 2)
run_multiple_sim([p])
elif len(sys.argv) == 1:
sys.setrecursionlimit(1500) # Needed to run nx.max_weight_matching on large graphs
timer = time.time()
sim_plan = generate_sim_plan(save=True)
run_paralell_sim(sim_plan)
# run_sim(sim_plan[0])
print("Total time = {}".format(time.time() - timer))