-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel_comparison.py
More file actions
67 lines (56 loc) · 1.89 KB
/
Copy pathmodel_comparison.py
File metadata and controls
67 lines (56 loc) · 1.89 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
######################################################################
# Model Outcome Comparisons #
# MRSA Colonization Acquisitions among various Population Structures #
######################################################################
# Module Imports
import os
import stochpy
import numpy as numpy
import random
workingdir = os.getcwd()
# General simulation parameters
random.seed(80209)
start_time = 0.0
end_time = 8760
n_runs = 1000
# Model output storage arrays
acquisitions = numpy.empty([n_runs,3])
# Single Staff Type (SST) Model Run
def SST(iteration):
model = stochpy.SSA()
model.Model(model_file='SST.psc', dir=workingdir)
model.Endtime(end_time)
model.DoStochSim()
model.GetRegularGrid(n_samples=end_time)
outcomes = model.data_stochsim_grid.species
Incident = outcomes[4][0][-1]
acquisitions[iteration,0] = Incident
# Nurse_MD Model Run
def Nurse_MD(iteration):
model = stochpy.SSA()
model.Model(model_file='Nurse_MD.psc', dir=workingdir)
model.Endtime(end_time)
model.DoStochSim()
model.GetRegularGrid(n_samples=end_time)
outcomes = model.data_stochsim_grid.species
Incident = outcomes[6][0][-1]
acquisitions[iteration,1] = Incident
# Metapopulation Model Run
def MetaPop(iteration):
model = stochpy.SSA()
model.Model(model_file='MetaPop.psc', dir=workingdir)
model.Endtime(end_time)
model.DoStochSim()
model.GetRegularGrid(n_samples=end_time)
outcomes = model.data_stochsim_grid.species
Incident = outcomes[16][0][-1]
acquisitions[iteration,2] = Incident
for i in range(0,n_runs):
print("*** Iteration %i of %i ***" % (i+1,n_runs))
SST(i)
Nurse_MD(i)
MetaPop(i)
numpy.savetxt('model_data.csv',acquisitions,delimiter=',',header="SST,Nurse_MD,MetaPop",comments='')
print("*************************")
print("***** Runs Complete *****")
print("*************************")