Skip to content

Commit fdd469d

Browse files
committed
Revision and addition of documentation for workshop
1 parent 742a1e5 commit fdd469d

10 files changed

Lines changed: 95 additions & 47 deletions

File tree

cpp/memilio/compartments/flow_model.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ class FlowModel : public CompartmentalModel<FP, Comp, Pop, Params>
236236
};
237237

238238
/**
239-
* @brief Concept to check if a type is a valid flow model.
239+
* @brief Concept to check if a type is a valid FlowModel.
240240
* Note that Model must be the first template argument
241-
* @tparam Model A type that may or may not be a flow model.
241+
* @tparam Model A type that may or may not be a FlowModel.
242242
* @tparam FP A floating point type, e.g. double.
243243
*/
244244
template <class Model, typename FP>

cpp/memilio/compartments/flow_simulation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class FlowSimulation : public details::FlowSimulationBase<FP, M, OdeIntegrator<F
4242

4343
/**
4444
* @brief Set up the simulation with an ODE solver.
45-
* @param[in] model An instance of a flow model.
45+
* @param[in] model An instance of a FlowModel.
4646
* @param[in] t0 Start time.
4747
* @param[in] dt Initial step size of integration.
4848
*/

cpp/memilio/compartments/flow_simulation_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class FlowSimulationBase : public SimulationBase<FP, M, Integrands...>
4848

4949
/**
5050
* @brief Create a FlowSimulationBase.
51-
* @param[in] model An instance of a flow model.
51+
* @param[in] model An instance of a FlowModel.
5252
* @param[in] integrator_core A unique pointer to an object derived from IntegratorCore.
5353
* @param[in] t0 Start time.
5454
* @param[in] dt Initial step size of integration.

docs/source/cpp/aggregated_models.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
Aggregated models
22
=================
33

4-
There are different equation-based models implemented in MEmilio that consider an aggregated population.
4+
There are different equation-based or compartmental models implemented in MEmilio that consider an aggregated population as shown in the following figure.
5+
6+
.. image:: http://martinkuehn.eu/research/images/aggregated.png
7+
:alt: Overview on MEmilio's models using aggregated populations.
8+
:width: 100%
59

610
.. toctree::
711
:maxdepth: 1

docs/source/cpp/diffusive_abm.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. include:: ../literature.rst
22

3-
Diffusive agent-based model
4-
===========================
3+
Agent-based model (with diffusion)
4+
===================================
55

66
This agent-based model uses a Markov process to simulate disease dynamics. The Markov process is given by agent movement and the evolution of disease dynamics i.e. disease transmission and progression.
77
The features of an agent are its position and its infection state. The evolution of the system state is determined by the following master equation

docs/source/cpp/mobility_based_abm.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. include:: ../literature.rst
22

3-
Agent-based model
4-
=================
3+
Agent-based model (with activities and mobility)
4+
================================================
55

66
This module models and simulates the epidemic using an agent-based model (*ABM*) approach. Unlike the compartmental models that use a system of ODEs, this model simulates
77
the spread of an epidemic in a population with discrete persons (the agents) moving throughout locations in the

docs/source/cpp/ode_creation.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ example being adding :code:`mio::AgeGroups` to the template.
162162
where we use ``populations.get_flat_index`` to get the correct index in the flat state and derivative vectors.
163163
You may also want to change the Parameters to use age groups, check out the available ODE models as reference.
164164

165-
Define a compartmental model class
165+
Define a CompartmentalModel class
166166
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
167167

168168
Now we can define the model:
@@ -219,7 +219,7 @@ Continue :doc:`here<ode>` to learn how to use this model, or read on if you want
219219
Implement the ODE model using flows
220220
-----------------------------------
221221

222-
A flow model is a special case of a compartmental model, where the derivative of each compartment over time
222+
A FlowModel is a special case of a CompartmentalModel, where the derivative of each compartment over time
223223
:math:`Z_i'(t)` can be written as
224224

225225
.. math::
@@ -230,7 +230,7 @@ where the flows :math:`f_{Z_i \rightarrow Z_j} \gt 0` are the amount of populati
230230
:math:`Z_i` to :math:`Z_j` at time :math:`t`. So the first sum accumulates all inflows, the second subtracts all
231231
outflows.
232232

233-
The SIRD model from above can be expressed as a flow model with only three flows:
233+
The SIRD model from above can be expressed as a FlowModel with only three flows:
234234

235235
.. math::
236236
@@ -245,7 +245,7 @@ Note that all other possible flows, like :math:`f_{I \rightarrow S}`, are consta
245245
Flows
246246
~~~~~
247247

248-
To use a flow model, we need to create a list of all flows. These are used by the model to automatically assemble the
248+
To use a FlowModel, we need to create a list of all flows. These are used by the model to automatically assemble the
249249
compartments. We use a :code:`mio::TypeList` with a :code:`mio::Flow` for each mathematical flow. For the SIRD model
250250
we get:
251251

@@ -258,12 +258,12 @@ we get:
258258
The first term in each :code:`mio::Flow` is the source compartment, the second the target. As a convention, we always
259259
compute non-negative outflows. Hence, we only list the flow :math:`S \rightarrow I`, but not :math:`I \rightarrow S`.
260260

261-
Infection states, Parameters and Population
261+
InfectionStates, Parameters and Population
262262
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
263263

264-
Since a Flow model is just a special case of a compartmental model, all of these are defined exactly as described above.
264+
Since a FlowModel is just a special case of a CompartmentalModel, all of these are defined exactly as described above.
265265

266-
Define a flow model class
266+
Define a FlowModel class
267267
~~~~~~~~~~~~~~~~~~~~~~~~~
268268

269269
With the flows and classes also used by the CompartmentalModel, we can define a FlowModel as such:
@@ -294,7 +294,7 @@ With the flows and classes also used by the CompartmentalModel, we can define a
294294
}
295295
};
296296
297-
This is mostly analogous to the definition of a compartmental model, with a few important differences. First, we now
297+
This is mostly analogous to the definition of a CompartmentalModel, with a few important differences. First, we now
298298
inherit from ``FlowModel``, which gets the ``Flows`` as an additional template argument. The ``Base`` alias changes
299299
accordingly. Secondly, the function we implement is called ``get_flows`` and computes the derivative of y in terms of
300300
its flows.

docs/source/cpp/overview.rst

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@ Overview
22
============
33

44

5+
Model structure
6+
----------------
7+
8+
The MEmilio library uses a modular organization of models where :doc:`compartmental or aggregated models<cpp/aggregated_models>` based on ODEs (ordinary differential equations) without and with Linear Chain Trick, IDEs (integro-differential equations), and SDEs (stochastic differential equations) share a maximum properties and interfaces (implemented in the *memilio* folder) to allow simple and straightforward model adaption with, e.g., demographic or spatial stratification (e.g. found in the *memilio/mobility* folder to create :doc:`metapopulation models<cpp/metapop>`) as shown in the following figure. :doc:`Agent-based models<cpp/individual_models>` are furthermore harmonized with most structures such as parameters, contact patterns, and non-pharmaceutical interventions (e.g. found in *memilio/epidemiology*).
9+
10+
.. image:: http://martinkuehn.eu/research/images/memilio_backend.png
11+
:alt: Overview on MEmilio's model backend
12+
:width: 100%
13+
14+
For a quick run through MEmilio's functionality see :doc:`installation`.
15+
516
The MEmilio C++ project is organized as follows:
617

7-
Main Directory Structure
18+
Main directory structure
819
---------------------------
920

1021
The main directory structure in the ``cpp`` directory includes:
@@ -33,31 +44,7 @@ The main directory structure in the ``cpp`` directory includes:
3344

3445
- **benchmarks/**: Analyzing runtime performance
3546

36-
Model Structure
37-
-----------------
38-
39-
The MEmilio library uses a modular organization of models, where generic implementations are inherited by specific implementations:
40-
41-
.. image:: http://martinkuehn.eu/research/images/overview.png
42-
:alt: Model Hierarchy
43-
:width: 100%
44-
45-
**CompartmentalModel**: The base class for all compartment-based models in MEmilio. It defines the fundamental structure for epidemiological models with compartments (e.g., SEIR, SECIR) and provides methods like ``eval_right_hand_side`` and ``get_initial_values`` required for ODE solvers.
46-
47-
**FlowModel**: Inherits from CompartmentalModel and extends it with the concept of flows between compartments. Instead of directly defining derivatives, it specifies the flows between compartments.
48-
49-
**Specific Model Implementations**:
50-
51-
- **ODE Model** (Ordinary Differential Equations): Deterministic models for continuous populations described by ordinary differential equations.
52-
53-
- **IDE Model** (Integro-Differential Equations): Extends the ODE model integration terms.
54-
55-
- **SDE Model** (Stochastic Differential Equations): Adds stochastic components to model uncertainties and random effects.
56-
57-
**Individual-based Model**: Stands separate from the compartmental hierarchy and models each individual explicitly with its own properties and interactions. This enables more detailed simulations.
58-
59-
60-
Build System
47+
Build system
6148
-------------
6249

6350
The project uses CMake as a build system with various configuration options.

docs/source/getting_started.rst

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Overview
88

99

1010
MEmilio is an extensive framework for tasks around infectious disease modeling. It supports a multitude of :ref:`model <model-faq>` types
11-
including :doc:`equation-based<cpp/aggregated_models>`, :doc:`agent-based <cpp/individual_models>`,
11+
including :doc:`equation-based or compartmental<cpp/aggregated_models>`, :doc:`agent-based <cpp/individual_models>`,
1212
and :doc:`hybrid graph-ODE-based models <cpp/graph_metapop>`. It furthermore provides ready-to-use tools for data integration and visualizations.
1313
Among the equation-based models, we provide models based on :doc:`ordinary differential equations <cpp/ode>`,
1414
:doc:`the linear chain trick (LCT), <cpp/lct>` and a recent :doc:`generalized LCT <cpp/glct>`, :doc:`integro-differential equations <cpp/ide>`
@@ -54,9 +54,66 @@ For Python, please see, e.g., :doc:`ODE-based SECIRTS model <python/m-simulation
5454

5555
When individual-level interactions and heterogeneity are crucial, :doc:`individual-based models <cpp/individual_models>` provide a detailed representation of disease dynamics. These models can capture complex behaviors and interactions, making them valuable for understanding transmission dynamics in specific settings. Individual-based models are computationally intensive but offer unparalleled detail for certain research questions such as in-household transmission or vaccination and testing strategies targeting individuals that satisfy specific properties with respect to age, previous infections, immunity levels, or particular workplaces. The most versatile individual-based model in MEmilio is the :doc:`(mobility-based) agent-based model <cpp/mobility_based_abm>`.
5656

57+
A quick tour through MEmilio
58+
-----------------------------
5759

58-
How to use MEmilio
59-
------------------
60+
While MEmilio harmonizes much of its structures across all model classes, we first distinguish between :doc:`compartmental or aggregated models<cpp/aggregated_models>` based on ODEs (ordinary differential equations) without and with Linear Chain Trick, IDEs (integro-differential equations), and SDEs (stochastic differential equations) and :doc:`Agent-based models<cpp/individual_models>`. The following subsections give a brief overview on essential functionality, each presented in a particular and function-specific tutorial. While several tutorials build on previous tutorials, experienced users or users interested in other models might also want jump to later parts of this walkthrough guide.
61+
62+
An additional overview on MEmilio's elementary model structure is given by the following figure.
63+
64+
.. image:: http://martinkuehn.eu/research/images/model_structure.png
65+
:alt: Overview on MEmilio's model structure.
66+
:width: 100%
67+
68+
MEmilio benefits from a harmonized description of its models in infection states and parameters, and, potentially, a list of flows between the compartments; see the following figure. All models derive their infection states from a flexible and simple list of InfectionStates. For FlowModels (see below for an explanation), particular transitions are defined evenly flexible as a list of flows between the states. Parameters are also mostly in an identical fashion.
69+
70+
.. image:: http://martinkuehn.eu/research/images/uniform.png
71+
:alt: MEmilio's uniform model description.
72+
:width: 100%
73+
74+
Below we guide you through several tutorials on using MEmilio's models through its Python interface. More experience users might directly start with the `Python exercises <https://github.com/SciCompMod/memilio-tutorials/tree/main/exercises>`_ which are derived versions from the tutorials or with `tutorial and exercises in C++ <https://github.com/SciCompMod/memilio-tutorials/tree/main/cpp-tutorials>`_. For more advanced aggregated models using the Linear Chain Trick or IDE-formulations, we currently only provided tutorials and exercises in C++. For the individual- or agent-based model (ABM), we currently only provide `ABM tutorials in C++ <
75+
https://github.com/SciCompMod/memilio-tutorials/tree/main/cpp-tutorials/abm>`_.
76+
77+
78+
Simple compartmental models
79+
****************************
80+
81+
Most of MEmilio's compartmental or aggregated models share the same interface derived from a high-level **CompartmentalModel** (see above). It defines the fundamental structure for epidemiological models with compartments (e.g., SEIR, SECIR, SIRS, etc.).
82+
83+
In `Tutorial 01 <https://github.com/SciCompMod/memilio-tutorials/blob/main/tutorial01.py>`_, we show how set up and simulate a simple setting for our :doc:`ODE-SECIR model <models/osecir>`. The result of the tutorial is a figure of a well-known epidemic outcome.
84+
85+
.. image:: http://martinkuehn.eu/research/images/tutorial01.png
86+
:alt: A well-known epidemic outcome as a result of Tutorial 01.
87+
:width: 100%
88+
89+
90+
Flows between compartments
91+
**************************
92+
93+
**FlowModel**: Inherits from CompartmentalModel and extends it with the concept of flows between compartments. Instead of directly defining derivatives, it specifies the flows between compartments.
94+
95+
96+
Demography and contact structures
97+
*********************************
98+
99+
100+
101+
102+
Metapopulation and mobility
103+
***************************
104+
105+
106+
107+
Fixed time-point interventions
108+
******************************
109+
110+
111+
Dynamic interventions
112+
*********************
113+
114+
115+
Download and installation
116+
-------------------------
60117

61118
The installation and use of MEmilio might look overwhelming at first due to the many features and models included.
62119
We have structured this documentation to guide you step-by-step through the installation and usage process.

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Welcome
1414

1515
MEmilio implements various models for infectious disease dynamics, ranging from simple compartmental models to complex Integro-Differential and agent-based models. Its modular design enables the combination of different models with distinct mobility patterns. Through efficient implementation and parallelization in C++ and an easy-to-use python interface, MEmilio delivers cutting-edge and compute-intensive epidemiological models to broad range of applications and users, providing precise and high-resolution spatiotemporal infectious disease dynamics. MEmilio is continuously extended and is available open-source for community use.
1616

17-
.. image:: http://martinkuehn.eu/research/images/MEmilio_small.png
17+
.. image:: http://martinkuehn.eu/research/images/memilio_small_new.png
1818
:alt: Memilio Overview
1919

2020
If you use MEmilio, please :doc:`cite our work<citation>`.

0 commit comments

Comments
 (0)