-
Notifications
You must be signed in to change notification settings - Fork 6
/
PremadeModels.jl
210 lines (148 loc) · 3.34 KB
/
PremadeModels.jl
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
module PremadeModels
using ..StockFlow.Syntax
export seir, sis, sir, svi
"""
Return a new SEIR model
"""
function seir()
return deepcopy(seir_model)
end
"""
Return a new SIS model
"""
function sis()
return deepcopy(sis_model)
end
"""
Return a new SIR model
"""
function sir()
return deepcopy(sir_model)
end
"""
Return a new SVI model
"""
function svi()
return deepcopy(svi_model)
end
seir_model = @stock_and_flow begin
:stocks
S
E
I
R
:parameters
μ
β
tlatent
trecovery
δ
c
:dynamic_variables
v_prevalence = NI / NS
v_meanInfectiousContactsPerS = c * v_prevalence # where c doesn't matter, can just make it 1
v_perSIncidenceRate = β * v_meanInfectiousContactsPerS
v_newIncidence = S * v_perSIncidenceRate
v_birth = μ * N
v_inf = E / tlatent
v_rec = I / trecovery
v_deathS = δ * S
v_deathE = δ * E
v_deathI = δ * I
v_deathR = δ * R
:flows
CLOUD => f_birth(v_birth) => S
S => f_incid(v_newIncidence) => E
S => f_deathS(v_deathS) => CLOUD
E => f_inf(v_inf) => I
E => f_deathE(v_deathE) => CLOUD
I => f_rec(v_rec) => R
I => f_deathI(v_deathI) => CLOUD
R => f_deathR(v_deathR) => CLOUD
:sums
N = [S, E, I, R]
NI = [I]
NS = [S, E, I, R]
end
sis_model = @stock_and_flow begin
:stocks
S
I
:parameters
μ
β
trec # 1 / trecovery. This corresponds to σ.
δ
c
:dynamic_variables
v_deathsX = δ * S
v_births = μ * N
v_prevalence = NI / NS
v_meanInfectiousContactsPerS = c * v_prevalence
v_perSIncidenceRate = β * v_meanInfectiousContactsPerS
v_newIncidence = S * v_perSIncidenceRate
v_newRecovery = I * trec
v_deathsI = I * δ
:flows
S => f_deathsX(v_deathsX) => CLOUD
CLOUD => f_births(v_births) => S
S => f_newInfectious(v_newIncidence) => I
I => f_newRecovery(v_newRecovery) => S
I => f_deathsI(v_deathsI) => CLOUD
:sums
N = [S, I]
NI = [I]
NS = [S, I]
end
sir_model = @stock_and_flow begin
:stocks
S
I
R
:parameters
c
β
rRec
:dynamic_variables
v_prevalence = NI / NS
v_meanInfectiousContactsPerS = c * v_prevalence
v_perSIncidenceRate = β * v_meanInfectiousContactsPerS
v_newInfections = S * v_perSIncidenceRate
v_newRecovery = I * rRec
:flows
S => f_inf(v_newInfections) => I
I => f_rec(v_newRecovery) => R
:sums
N = [S, I, R]
NI = [I]
NS = [S,I,R]
end
svi_model = @stock_and_flow begin
:stocks
S
V
I
:parameters
rvaccine
δ
evaccine
c
β
:dynamic_variables
v_vacc = S * rvaccine
v_deathV = δ * V
v_prevalence = NI / NS
v_meanInfectiousContactsPerS = c * v_prevalence
v_perSIncidenceRate = β * v_meanInfectiousContactsPerS
v_vaccineInfectionRate = V / evaccine # same thing as multiplying by complement
v_perSIncidenceVaccinated = v_vaccineInfectionRate * v_perSIncidenceRate
:flows
S => f_vacc(v_vacc) => V
V => f_deathV(v_deathV) => CLOUD
V => f_infV(v_perSIncidenceVaccinated) => I
:sums
N = [S, V, I]
NI = [I]
NS = [S, V, I]
end
end