-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrunScenario.py
More file actions
132 lines (108 loc) · 4.52 KB
/
runScenario.py
File metadata and controls
132 lines (108 loc) · 4.52 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import numpy as np
import pandas as pd
from simulate import simulate
import multiprocessing as mp
import time
shuffled_pollution_activate = False
centralized_infectious = False
if __name__ == '__main__':
# jobs = np.zeros((3), dtype=[('N', int), ('N_ill', int), ('Lx', int), ('Ly',int), ('step size',float), ('infection rate',float), ('pollution rate',float)\
# , ('tile infection rate',float), ('flow rate',float), ('time',int)\
# ,('shuffled_pollution',bool), ('animation',bool), ('infectious_center', bool),\
# ('state_after_infection',int), ('opening_duration',int), ('sigma_1', float),\
# ('sigma_2', float),('n_sigma_2',int)
# ] )
jobs = []
N = 100
N_ill = 1
Lx = Ly = 30
stepSize = 0.5
infection_rate = 0.1
tile_infection_rate = pollution_rate = 0.02
flow_rate = 0
shuffled_pollution_activate = False
animatable_output = False
centralized_infectious = False
state_after_infection = 1 #1 for SEI, 2 for SI
opening_duration = 0 #flash_forward every ...
sigma_1 = 4.0
sigma_2 = 0
n_sigma_2 = 0
realisations = 5
tMax = 20
args1 = N, N_ill, Lx, Ly, stepSize, infection_rate, pollution_rate\
, tile_infection_rate, flow_rate, tMax,\
shuffled_pollution_activate, animatable_output,\
centralized_infectious, state_after_infection,\
opening_duration, sigma_1, sigma_2, n_sigma_2
N = 100
N_ill = 1
Lx = Ly = 30
stepSize = 0.5
infection_rate = 0.1
tile_infection_rate = pollution_rate = 0.02
flow_rate = 0
shuffled_pollution_activate = False
animatable_output = False
centralized_infectious = False
state_after_infection = 1 #1 for SEI, 2 for SI
opening_duration = 0 #flash_forward every ...
sigma_1 = 0.001
sigma_2 = 0
n_sigma_2 = 0
args2 = N, N_ill, Lx, Ly, stepSize, infection_rate, pollution_rate\
, tile_infection_rate, flow_rate, tMax,\
shuffled_pollution_activate, animatable_output,\
centralized_infectious, state_after_infection,\
opening_duration, sigma_1, sigma_2, n_sigma_2
#---------------N---N_ill--Lx--Ly----step---inf rate--poll rate--tile inf rate--flow rate--time --
N = 100
N_ill = 1
Lx = Ly = 30
stepSize = 0.5
infection_rate = 0.1
tile_infection_rate = pollution_rate = 0.02
flow_rate = 0
shuffled_pollution_activate = False
animatable_output = False
centralized_infectious = False
state_after_infection = 1 #1 for SEI, 2 for SI
opening_duration = 0 #flash_forward every ...
sigma_1 = 0.001
sigma_2 = 4.0
n_sigma_2 = 50
args3 = N, N_ill, Lx, Ly, stepSize, infection_rate, pollution_rate\
, tile_infection_rate, flow_rate, tMax,\
shuffled_pollution_activate, animatable_output,\
centralized_infectious, state_after_infection,\
opening_duration, sigma_1, sigma_2, n_sigma_2
jobs.append(args1)
jobs.append(args2)
jobs.append(args3)
np.random.seed(int(time.time()))
for job in jobs:
with mp.Pool(mp.cpu_count()) as pool:
p_r = pool.map_async(simulate, [(np.random.randint(10000000),)+job for i in range(realisations)])
results = p_r.get()
for j in range(len(results)):
results[j] = (results[j]['from_per'].cumsum(), results[j]['from_env'].cumsum())
ts = np.mean(results, axis=0)
errors = np.std(results, axis=0)
rand_string = str(np.random.randint(100000000))
id_string = rand_string
np.save(id_string, results)
#with open("info "+rand_string, "w") as f:
#f.write( str(job)[1:-1] )
with open("info "+rand_string, "w") as f:
f.write( 'scenario:\n\n' )
#if shuffled_pollution_activate:
#f.write('shuffled\n')
#else:
#f.write('not shuffled\n')
# f.write( 'shuffled_pollution_activate=' + str( shuffled_pollution_activate ) + '\n' )
# f.write( 'centralized_infectious=' + str( centralized_infectious ) + '\n' )
# f.write( 'infection_rate=' + str( infection_rate ) + '\n' )
# f.write( 'tile_rate=' + str( tile_rate ) + '\n' )
f.write( str(job)[1:-1] )
#np.save( id_string , ts)
#np.save(str(int(job['infection rate']*100)) + "-" + str(int(job['tile infection rate']*100))+"-err", errors)