-
Notifications
You must be signed in to change notification settings - Fork 14
Implementation details
Serge Stinckwich edited this page Dec 12, 2019
·
1 revision
An Epi Model in Kendrick
-
A model is an instance of KEModel class, having:
- a list of attributes (ex: model addAttributes: {#status->#(#S #I #R). #species->#(#bird #human)})
- a list of parameters (ex: model addParameters: {#beta. #gamma}).
- Two parameters are implicitly defined: #N is the population size, #t is the instant time t
- a list of compartments
- a list of transitions
-
A transition of a model has a from-state, a to-state and a rate: an expression that can be evaluated at instant time t
- A list of transitions of a model is then all the non-zero elements of the matrix Q in the mathematical model
-
Tensor Sum
- a concern is integrated into a model through the tensor sum operator
- the tensor sum allows to generate a new list of transitions resulting from the combination of two transition rate matrice
-
Naming compartments
- name of compartments of the model is automatically generated through the list of attributes
- Equivalent relation is restricted to equality expressions of attributes
- each name is a dictionary (of type Dictionary in Smalltalk) with a key is an attribute name, value is an attribute value
- ex: Dictionary(#status->#S, #species->#human) is a compartment name
- why choose Dictionary? compartment name expresses the state of the model or the SAN. The interaction between concerns (automata) is through functional rates (the rate of a transition is a function depending on the state of one or more concerns/automata). To evaluate the rate of a functional transition at the time t, we need to know what is the current state of a concern/automaton. Using Dictionary to store the name of a compartment, we can easily access the state of concern through attribute key. For example: model with two concerns SIR and multi-species above. we can know the state of the multi-species concern by asking for the value of the key: #species.
-
Initializing compartments and addParameters
- This is done separately from the definition of model/concern
- We assign a value for a parameter through its name or for a compartment also through its name
- Ex1: model atParameter: #beta put: 0.005. ==> beta is a constant function
- Ex2: model atParameter: #beta put: '0.5*sin(t)' ==> beta is a temporal function depending on time t
- Ex3: model atParameter: #gamma put: [:aModel| |c| c := aModel currentCompartment at: #species. c = #human ifTrue: [^ 0.03]. c = #bird ifTrue: [^ 0.003]]. ==> gamma is a functional rate depending on the state of the multi-species concern. With sugar syntax we can simple write: gamma_species: #(0.003 0.03).
- Assign value to a compartment through its name
- Currently, the implementation allows only assign value to a smallest equivalent class. Example: model with two concerns above we can assign value to its 6 compartments: model atCompartment: {#status->#S. #species->#human} put: 1000 atOthers: 0. model atCompartment: {#status->#I. #species->#human} put: 100. ==> S_human = 1000, I_human = 100 and others compartments: 0
-
Accessing the cardinality of a compartment through its name:
- at the time t, we want to know the cardinality of a compartment, we just use: model atCompartment: [a Compartment name] example: model atCompartment: {#status->#S. #species->#human} returns the cardinality of this compartments model atCompartment: {#status->#S} returns the cardinality of all compartments with the #status->#S in their name.
-
Evaluating the value of a parameter through its name:
- at the time t, we want to know the value of a parameter, just use: model atParameter: #beta. If beta is a constant function ==> return its constant value If beta is a temporal function ==> return its value by evaluating the function by t (t is another parameter). If beta is a functional rate ==> evaluating the state of the corresponding concern, then returning the value