-
Notifications
You must be signed in to change notification settings - Fork 14
Example 7: SEIRS Model using dependent concern
Bui Thi Mai Anh edited this page Jul 3, 2018
·
1 revision
We specify the SEIRS Model by combining the SEIR Concern and the SEIRS Concern that extends SEIR one
KendrickModel SampleModel
population: 5000.
Concern SEIRConcern
attribute: #(status -> S E I R);
parameters: #(beta lambda sigma gamma mu);
lambda: #(beta*I/N);
transitions: #(
S -- lambda --> E.
E -- sigma --> I.
I -- gamma --> R.
status -- mu --> Empty.
Empty -- mu --> S.
).
Composition SEIRModel
model: 'SampleModel';
concern: 'SEIRConcern';
S: 4999;
I: 1;
others: 0;
mu: 0.0000351;
sigma: 0.125;
gamma: 0.143;
beta: 2.14.
Simulation SEIRRK rungeKutta
for: 'SEIRModel';
from: 0;
to: 365;
step: 1.
(Visualization SEIRDiagramViz diagram
for: 'SEIRRK';
xLabel: 'Time (days)') open.
Concern SEIRSConcern
extends: 'SEIRConcern';
parameters: #(v);
addTransition: #(R -- v --> S).
Composition SEIRSModel
model: 'SEIRModel';
concern: 'SEIRSConcern';
S: 4999;
I: 1;
others: 0;
v: 0.00274.
Simulation SEIRSRK rungeKutta
for: 'SEIRSModel';
from: 0;
to: 365;
step: 1.
(Visualization SEIRSDiagramViz diagram
for: 'SEIRSRK';
xLabel: 'Time (days)') open.
| model SEIRConcern SEIRSConcern simulator dB|
model := KEModel new.
model population: (KEPopulation size: 5000).
SEIRConcern := KEConcern new.
SEIRConcern attributes: {#status->#(#S #E #I #R)}.
SEIRConcern addParameters: { #beta. #gamma. #mu. #sigma }.
SEIRConcern
addTransitionFrom: '{#status: #S}'
to: '{#status: #E}'
probability: [ :aModel |
(aModel atParameter: #beta) *
(aModel atCompartment: {#status->#I}) / (aModel atParameter: #N) ].
SEIRConcern
addTransitionFrom: '{#status: #E}'
to: '{#status: #I}'
probability: [ :aModel | aModel atParameter: #sigma ].
SEIRConcern
addTransitionFrom: '{#status: #I}'
to: '{#status: #R}'
probability: [ :aModel | aModel atParameter: #gamma ].
SEIRConcern
addTransitionFrom: '{#status: #S}'
to: #empty
probability: [ :aModel | aModel atParameter: #mu ].
SEIRConcern
addTransitionFrom: '{#status: #I}'
to: #empty
probability: [ :aModel | aModel atParameter: #mu ].
SEIRConcern
addTransitionFrom: '{#status: #R}'
to: #empty
probability: [ :aModel | aModel atParameter: #mu ].
SEIRConcern
addTransitionFrom: '{#status: #E}'
to: #empty
probability: [ :aModel | aModel atParameter: #mu ].
SEIRConcern
addTransitionFrom: #empty
to: '{#status: #S}'
probability: [ :aModel | aModel atParameter: #mu ].
model integrate: SEIRConcern.
model atParameter: #beta assignValue: 2.14.
model atParameter: #gamma assignValue: 0.143.
model atParameter: #sigma assignValue: 0.125.
model atParameter: #mu assignValue: 0.0000351.
model atCompartment: { #status->#S } put: 4999.
model atCompartment: { #status->#I } put: 1.
model atCompartment: { #status->#R } put: 0.
model atCompartment: { #status->#E } put: 0.
simulator := KESimulator new: #RungeKutta from: 0.0 to: 100 step: 1.
simulator executeOn: model.
dB := KEDiagramBuilder new.
dB data: (simulator timeSeriesAt: '{#status: #I}').
dB xLabel: 'Time (year)'.
dB open.
SEIRSConcern := KEConcern dependOn: SEIRConcern.
SEIRSConcern addParameter: #v.
SEIRSConcern addTransitionFrom: { #status->#R } to: { #status->#S } probability: [ :aModel| aModel atParameter: #v].
model integrate: SEIRSConcern.
model atParameter: #v assignValue: 0.0.
model atCompartment: { #status->#S } put: 4999.
model atCompartment: { #status->#I } put: 1.
model atCompartment: { #status->#R } put: 0.
model atCompartment: { #status->#E } put: 0.
simulator := KESimulator new: #RungeKutta from: 0.0 to: 100 step: 1.
simulator executeOn: model.
dB := KEDiagramBuilder new.
dB data: (simulator timeSeriesAt: '{#status: #I}').
dB xLabel: 'Time (year)'.
dB open.