-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabm.py
More file actions
33 lines (27 loc) · 781 Bytes
/
abm.py
File metadata and controls
33 lines (27 loc) · 781 Bytes
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
import numpy as np
import json
import os
import src
import multiprocessing as mp
def do(args,R0):
DIR = "Results\\ABM_{}".format(R0)
args["R0"] = R0
os.makedirs(DIR,exist_ok=True)
src.simulate(args,DIR,SAVE=False,LOAD=False)
def do_normal(args):
DIR = "Results\\ABM_{}".format(args["Name"])
os.makedirs(DIR,exist_ok=True)
src.simulate(args,DIR,SAVE=True,LOAD=False)
if __name__ == '__main__':
with open("ABM_parameters.json") as f:
args = json.load(f)
if args["Name"] == "MULTI":
Nos = 9
R0 = np.linspace(1,4,Nos)
pool = mp.Pool(processes=8)
for i in range(Nos):
pool.apply_async(do, args = (args,R0[i]))
pool.close()
pool.join()
else:
do_normal(args)