-
Notifications
You must be signed in to change notification settings - Fork 14
Examples illustrating the Kendrick syntax
As Kendrick is an embedded DSL for epidemiology, its syntax is based on the host-language: Smalltalk. The following sugar syntactic is used to define Kendrick models:
- Define Kendrick concern:
KendrickModel SIR
attribute: #(status -> S I R);
parameters: #(beta lambda gamma mu);
transitions: #(
S -- lambda --> I.
I -- gamma --> R.
status -- mu --> Empty.
Empty -- mu --> S.).
It is also possible to using equation-based syntax to define Kendrick concern
KendrickModel SIR
attribute: #(status -> S I R);
parameters: #(beta lambda gamma mu);
equations: #(
S:t = mu*N - beta*S*I - mu*S.
I:t = beta*S*I - gamma*I - mu*I.
R:t = gamma*I - mu*R.).
A concern may contains no transitions or params, like:
KendrickModel TwoSpecies
attribute: #(species -> human bird).
- Combining concerns to create new a concern/model
Composition SIRTwoSpecies
model: 'SIR';
model: 'TwoSpecies'.
- Specifying scenarios to use Kendrick models This phase is called instantiation phase when specifying Kendrick model in which we assign values to parameters and assign initial values to compartments (initializing the population). The scenarios of Kendrick then will be used in simulation to do experimentations.
Scenario SIRTwoSpeciesParams
on: 'SIRTwoSpecies';
populationSize: 5500;
S_species: #(500 4990);
I_species: #(0 10);
mu_species: #(0.000365 0.00137);
beta_species: #(#(0 0.21) #(0 0.42));
gamma_species: #(0.25 0.233);
lambda: #(beta*I/N sum);
N: #(species).
We can have multiple scenarios specified for one model, i.e., two scenarios: the first one for population specification and the second one for parameter specification.
Scenario SIRTwoSpeciesParams
on: 'SIRTwoSpecies';
mu_species: #(0.000365 0.00137);
beta_species: #(#(0 0.21) #(0 0.42));
gamma_species: #(0.25 0.233);
lambda: #(beta*I/N sum);
N: #(species).
Scenario SIRTwoSpeciesPop
on: 'SIRTwoSpecies';
populationSize: 5500;
S_species: #(500 4990);
I_species: #(0 10).
- Specifying simulation and visualization for experimenting Kendrick models
Simulation SIRTwoSpeciesSim1 rungeKutta
scenarios: #(SIRTwoSpeciesParams SIRTwoSpeciesPop);
from: 0;
to: 500;
step: 1.
Visualization SIRTwoSpeciesViz diagram
for: 'SIRTwoSpeciesSim1';
xLabel: 'Time (days)';
exportToPng.
It is possible to create different kinds of visualization for one simulation i.e., diagram, map etc.
- Assigning values to parameters of Kendrick models It is important to note that we can assign values to parameters of Kendrick concern/model in any of three phases: the definition phase (1), the composition phase (2) and the instantiation phase (3).
For example:
KendrickModel SIR
attribute: #(status -> S I R);
parameters: #(beta lambda gamma mu);
equations: #(
S:t = mu*N - lambda*S - mu*S.
I:t = lambda*S - gamma*I - mu*I.
R:t = gamma*I - mu*R.);
beta: 0.001;
gamma: 0.1;
mu: 0.05;
lambda: #(beta*I/N).
Composition Influenza
model: SIR;
model: TwoSpecies;
lambda: #(beta*I/N sum).
- Spatial Entities
In order to simplify the specification of spatial concerns, we have developed some entities for example: Map, Network. Other entities may be considered in future to enable different kinds of spatial models in epidemiology (i.e., meta-population or patch models, network models, household models etc.).
Map IndoChina
for: #(country -> MyanmarBurma Cambodia Laos Thailand Vietnam);
borders: #(
#(0 0 0 1 0)
#(0 0 0 0 1)
#(1 0 0 0 0)
#(0 1 0 0 0)
#(0 0 1 0 0)
).
This script specifies a map of 5 countries in IndoChina region based on the geographical borders between countries. We then use it to define the spatial concern as follows:
KendrickModel Spatial
maps: 'IndoChina';
withTransitionRate: #(rho).
Here we assume that the transition rate between each pair of countries is rho. It is also possible to define for each transition a different rate, i.e., CountryA -- rate --> CountryB.