22
33## Generate the Model and Dataset
44
5- ``` @example scenario1
6- prob = nothing
7- p_init = nothing # or box constraints
8- tsave, data = nothing, nothing
5+ ### Setup
6+
7+ ```
8+ using Catlab, Catlab.CategoricalAlgebra, Catlab.Programs, Catlab.WiringDiagrams, Catlab.Graphics
9+ using AlgebraicPetri
10+ using AlgebraicPetri.BilayerNetworks
11+ using AlgebraicDynamics.UWDDynam
12+ using LabelledArrays
13+ using OrdinaryDiffEq, DelayDiffEq
14+ using Plots
15+
16+ using ASKEM.Dec2022Demo: formSIRD, formInfType, augLabelledPetriNet, sirdAugStates, typeSIRD,
17+ makeMultiAge, typeAge, typed_stratify, formVax, vaxAugStates, typeVax, writeMdlStrat,
18+ loadSVIIvR, sviivrAugStates, typeSVIIvR
19+ using ASKEM.SubACSets: mca
20+ using ASKEM.Stratify: stratify_typed
21+
22+ types′ = LabelledPetriNet([:Pop],
23+ :infect => ((:Pop, :Pop) => (:Pop, :Pop)),
24+ :disease => (:Pop => :Pop),
25+ :strata => (:Pop => :Pop),
26+ :natural => (:Pop => :Pop),
27+ )
28+ types = map(types′, Name=name -> nothing)
29+
30+ # Parts of type system for ease of reference
31+ s, = parts(types′, :S)
32+ t_interact, t_disease, t_strata,t_natural = parts(types′, :T)
33+ i_interact1, i_interact2, i_disease, i_strata, i_natural = parts(types′, :I)
34+ o_interact1, o_interact2, o_disease, o_strata, o_natural = parts(types′, :O);
35+ ```
36+
37+ ### Original SEIRD model from the paper
38+
39+ ```
40+ seirdnat = LabelledPetriNet([:S, :E, :I, :R, :D],
41+ :inf => ((:S, :I) => (:E, :I)),
42+ :conv => (:E => :I),
43+ :rec => (:I => :R),
44+ :death => (:I => :D),
45+ :nat_d_s => (:S => ()),
46+ :nat_d_e => (:E => ()),
47+ :nat_d_i => (:I => ()),
48+ :nat_d_r => (:R => ()),
49+ :nat_birth => (() => :S),
50+ )
51+
52+ # seirdnat_aug = augLabelledPetriNet(seirdnat, [:S, :E, :I, :R])
53+ seirdnat_typed = ACSetTransformation(seirdnat, types,
54+ S=[s, s, s, s, s],
55+ T=[t_interact, t_disease, t_disease, t_disease, t_disease, t_disease, t_disease, t_disease, t_natural],
56+ I=[i_interact1, i_interact2, i_disease, i_disease, i_disease, i_disease, i_disease, i_disease, i_disease],
57+ O=[o_interact1, o_interact2, o_disease, o_disease, o_disease, o_natural],
58+ Name=name -> nothing
59+ )
60+ @assert is_natural(seirdnat_typed)
61+ ```
62+
63+ ### Model of vaccination process
64+
65+ ```
66+ vax_lpn = LabelledPetriNet([:U, :V],
67+ :infuu => ((:U, :U) => (:U, :U)),
68+ :infvu => ((:V, :U) => (:V, :U)),
69+ :infuv => ((:U, :V) => (:U, :V)),
70+ :infvv => ((:V, :V) => (:V, :V)),
71+ :vax => (:U => :V),
72+ )
73+
74+ Vax_aug_typed = ACSetTransformation(vax_lpn, types,
75+ S=[s, s],
76+ T=[t_interact, t_interact, t_interact, t_interact, t_strata],
77+ I=[i_interact1, i_interact2, i_interact1, i_interact2, i_interact1, i_interact2, i_interact1, i_interact2, i_strata],
78+ O=[o_interact1, o_interact2, o_interact1, o_interact2, o_interact1, o_interact2, o_interact1, o_interact2, o_strata],
79+ Name=name -> nothing
80+ )
81+ @assert is_natural(Vax_aug_typed)
82+ ```
83+
84+ ### Original model stratified with vaccination
85+
86+ ```
87+ seirdnat_vax = stratify_typed(
88+ seirdnat_typed=>[[:strata],[:strata],[:strata],[:strata],[]],
89+ Vax_aug_typed=>[[:disease,:natural],[:disease,]],
90+ types′)
91+ ```
92+
93+ conv: exposed => infected
94+
95+ ### Model 3.a.i for comparison
96+
97+ ```
98+ # SEIRDnat "stratified with vax"
99+ function formSEIRDnatV()
100+ SEIRDnatV = LabelledPetriNet([:Sv, :Ev, :Iv, :Rv, :D],
101+ :inf => ((:Sv, :Iv) => (:Ev, :Iv)),
102+ :conv => (:Ev => :Iv),
103+ :rec => (:Iv => :Rv),
104+ :death => (:Iv => :D),
105+ :nat_d_s => (:Sv => ()),
106+ :nat_d_e => (:Ev => ()),
107+ :nat_d_i => (:Iv => ()),
108+ :nat_d_r => (:Rv => ()),
109+ )
110+ return SEIRDnatV
111+ end
112+
113+ seirdnat_v = formSEIRDnatV()
114+ ```
115+
116+ ### Model 3.a.ii for comparison
117+
118+ ```
119+ # CHIMESVIIvR
120+ sviivr_lbn_pth = joinpath(@__DIR__, "CHIME_SVIIvR_dynamics_BiLayer.json")
121+ sviivr_lbn = read_json_acset(LabelledBilayerNetwork, sviivr_lbn_pth)
122+ sviivr = LabelledPetriNet()
123+ migrate!(sviivr, sviivr_lbn)
9124```
10125
11126## Model Analysis
@@ -16,6 +131,28 @@ tsave, data = nothing, nothing
16131> i. Vaccine efficacy = 75%, population vaccinated = 10%
17132> ii. Vaccine efficacy = 75%, population vaccinated = 80%
18133
134+ E(0) = 99500 # exposed
135+ I(0) = 1 # infected
136+ recovered, deceased = 0
137+ N = 10000000
138+ mu = 0.012048 # death rate
139+ alpha = 0.00142 # fatality rate among unvaccinated
140+ alpha_v = 0.00142 # fatality rate among vaccinated
141+ beta_uu = 0.75 # probability of transmission per unvax contact * # of unvax contacts per time
142+ gamma^-1 = 3.31 # reciprocal of recovery rate of unvax
143+ gamma_v^-1 = 3.31 # " vax
144+ eps^-1 = 5.7 # reciprocal of rate of exposed,unvax => infectious,unvax
145+ eps_v^-1 = 5.79 # " vax
146+ xi = 0.5 # vaccine efficacy
147+ kappa # fraction vaccinated
148+
149+ #### Run model 3ai
150+
151+ system = ODESystem(seirdnat_v)
152+ prob = ODEProblem(system, [ 10000000-99500, 99500, 1, 0, 0.0] , [ 0, 100] ,
153+ [ 0.75, 1/5.7, 1/3.31, 0.012048, 1e-3, 1e-3, 1e-3, 1e-3] )
154+
155+
19156### Question 4
20157
21158> Create an equally weighted ensemble model using the three models in 3b, and replicate the scenarios in 3.c.i and 3.c.ii. How does the ensemble model output compare to the output from the individual component models?
0 commit comments