JSON - MikeLydeamore/JCompSim GitHub Wiki
For 'simple' models, it is possible to represent the state-transition system using two JSON files which can be directly inputted into the simulator without changing any code. Two JSON files are required: one representing the states and one representing the transitions.
States
The states JSON lists each state of the model and it's initial value. An example:
{
"S": 90,
"I": 10,
"R": 0
}
This defines 3 states: S, I and R with initial values 90, 10 and 0 respectively.
Transitions
The transitions JSON is slightly more involved. All types of transitions require:
source_state
,destination_state
,parameter
.
Additionally, one must specify the type of transition. The following type of transitions are available:
-
Individual:
Specify"transition_type": "individual"
Rate will be of the formparameter * source_state
. -
Mass Action:
Specify"transition_type": "mass-action"
Optional"governing_states": ["list", "of", "states"]
Rate will be of the formparameter * source_state * sum(governing_states)
. -
Constant:
Specify"transition_type": "constant"
Rate will be of the formparameter * Indicator(source_state > 0)
.
Example
For the SIR model, the following transitions JSON is used:
[
{
"source_state": "S",
"destination_state": "I",
"parameter": 0.018,
"transition_type": "mass-action",
"governing_states": ["I"]
},
{
"source_state": "I",
"destination_state": "R",
"parameter": 1,
"transition_type": "individual"
}
]
More examples are available inside the repository's Models
directory.