-
Notifications
You must be signed in to change notification settings - Fork 0
/
football.py
171 lines (154 loc) · 5.48 KB
/
football.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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import os
import stochpy
import numpy as numpy
workingdir = os.getcwd()
# Simulation parameters
start_time = 0.0
end_time = 109
n_runs = 1000
scenarios = 10
# Model output storage arrays
results = numpy.empty([n_runs*scenarios,3], dtype = object)
def LowControl(iteration, scen):
model = stochpy.SSA()
model.Model(model_file='no_football.psc', dir=workingdir)
model.Endtime(end_time)
model.ChangeParameter('beta',0.25)
model.DoStochSim()
model.GetRegularGrid(n_samples=end_time)
outcomes = model.data_stochsim_grid.species
cases = outcomes[2][0][-1]
symptom = outcomes[4][0][-1]
results[iteration+(n_runs*scen),0] = 0
results[iteration+(n_runs*scen),1] = cases
results[iteration+(n_runs*scen),2] = symptom
def HighControl(iteration, scen):
model = stochpy.SSA()
model.Model(model_file='no_football.psc', dir=workingdir)
model.Endtime(end_time)
model.ChangeParameter('beta',0.30)
model.DoStochSim()
model.GetRegularGrid(n_samples=end_time)
outcomes = model.data_stochsim_grid.species
cases = outcomes[2][0][-1]
symptom = outcomes[4][0][-1]
results[iteration+(n_runs*scen),0] = 1
results[iteration+(n_runs*scen),1] = cases
results[iteration+(n_runs*scen),2] = symptom
def LowBetaLowPrevLowMix(iteration,scen):
model = stochpy.SSA()
model.Model(model_file='football_lowmix_lowprev.psc', dir=workingdir)
model.Endtime(end_time)
model.ChangeParameter('beta',0.25)
model.DoStochSim()
model.GetRegularGrid(n_samples=end_time)
outcomes = model.data_stochsim_grid.species
cases = outcomes[2][0][-1]
symptom = outcomes[4][0][-1]
results[iteration+(n_runs*scen),0] = 2
results[iteration+(n_runs*scen),1] = cases
results[iteration+(n_runs*scen),2] = symptom
def LowBetaLowPrevHighMix(iteration,scen):
model = stochpy.SSA()
model.Model(model_file='football_highmix_lowprev.psc', dir=workingdir)
model.Endtime(end_time)
model.ChangeParameter('beta',0.25)
model.DoStochSim()
model.GetRegularGrid(n_samples=end_time)
outcomes = model.data_stochsim_grid.species
cases = outcomes[2][0][-1]
symptom = outcomes[4][0][-1]
results[iteration+(n_runs*scen),0] = 3
results[iteration+(n_runs*scen),1] = cases
results[iteration+(n_runs*scen),2] = symptom
def LowBetaHighPrevLowMix(iteration,scen):
model = stochpy.SSA()
model.Model(model_file='football_lowmix_highprev.psc', dir=workingdir)
model.Endtime(end_time)
model.ChangeParameter('beta',0.25)
model.DoStochSim()
model.GetRegularGrid(n_samples=end_time)
outcomes = model.data_stochsim_grid.species
cases = outcomes[2][0][-1]
symptom = outcomes[4][0][-1]
results[iteration+(n_runs*scen),0] = 4
results[iteration+(n_runs*scen),1] = cases
results[iteration+(n_runs*scen),2] = symptom
def LowBetaHighPrevHighMix(iteration,scen):
model = stochpy.SSA()
model.Model(model_file='football_highmix_highprev.psc', dir=workingdir)
model.Endtime(end_time)
model.ChangeParameter('beta',0.25)
model.DoStochSim()
model.GetRegularGrid(n_samples=end_time)
outcomes = model.data_stochsim_grid.species
cases = outcomes[2][0][-1]
symptom = outcomes[4][0][-1]
results[iteration+(n_runs*scen),0] = 5
results[iteration+(n_runs*scen),1] = cases
results[iteration+(n_runs*scen),2] = symptom
def HighBetaHighPrevLowMix(iteration,scen):
model = stochpy.SSA()
model.Model(model_file='football_lowmix_highprev.psc', dir=workingdir)
model.Endtime(end_time)
model.ChangeParameter('beta',0.30)
model.DoStochSim()
model.GetRegularGrid(n_samples=end_time)
outcomes = model.data_stochsim_grid.species
cases = outcomes[2][0][-1]
symptom = outcomes[4][0][-1]
results[iteration+(n_runs*scen),0] = 6
results[iteration+(n_runs*scen),1] = cases
results[iteration+(n_runs*scen),2] = symptom
def HighBetaHighPrevHighMix(iteration,scen):
model = stochpy.SSA()
model.Model(model_file='football_highmix_highprev.psc', dir=workingdir)
model.Endtime(end_time)
model.ChangeParameter('beta',0.30)
model.DoStochSim()
model.GetRegularGrid(n_samples=end_time)
outcomes = model.data_stochsim_grid.species
cases = outcomes[2][0][-1]
symptom = outcomes[4][0][-1]
results[iteration+(n_runs*scen),0] = 7
results[iteration+(n_runs*scen),1] = cases
results[iteration+(n_runs*scen),2] = symptom
def HighBetaLowPrevLowMix(iteration,scen):
model = stochpy.SSA()
model.Model(model_file='football_lowmix_lowprev.psc', dir=workingdir)
model.Endtime(end_time)
model.ChangeParameter('beta',0.30)
model.DoStochSim()
model.GetRegularGrid(n_samples=end_time)
outcomes = model.data_stochsim_grid.species
cases = outcomes[2][0][-1]
symptom = outcomes[4][0][-1]
results[iteration+(n_runs*scen),0] = 8
results[iteration+(n_runs*scen),1] = cases
results[iteration+(n_runs*scen),2] = symptom
def HighBetaLowPrevHighMix(iteration,scen):
model = stochpy.SSA()
model.Model(model_file='football_highmix_lowprev.psc', dir=workingdir)
model.Endtime(end_time)
model.ChangeParameter('beta',0.30)
model.DoStochSim()
model.GetRegularGrid(n_samples=end_time)
outcomes = model.data_stochsim_grid.species
cases = outcomes[2][0][-1]
symptom = outcomes[4][0][-1]
results[iteration+(n_runs*scen),0] = 9
results[iteration+(n_runs*scen),1] = cases
results[iteration+(n_runs*scen),2] = symptom
for i in range(0,n_runs):
print("*** Iteration %i of %i ***" % (i+1,n_runs))
LowControl(i,0)
HighControl(i,1)
LowBetaLowPrevLowMix(i,2)
LowBetaLowPrevHighMix(i,3)
LowBetaHighPrevLowMix(i,4)
LowBetaHighPrevHighMix(i,5)
HighBetaHighPrevLowMix(i,6)
HighBetaHighPrevHighMix(i,7)
HighBetaLowPrevLowMix(i,8)
HighBetaLowPrevHighMix(i,9)
numpy.savetxt('wsu_football.csv',results,delimiter=',',header="Scenario,Cases,Symptomatic",comments='')