Skip to content

Commit 6c83abd

Browse files
mknaranjakilianvolmerjubickerannawendlercharlie0614
authored
1233 further enhance read the docs (#1289)
- Updated and enhanced the existing Readthedocs documentation - Updated the PR template for better visibility of the documentation needs - Replaced READMEs in the model folders by links to corresponding documentation and code examples - Minor bugfixes Co-authored-by: Kilian Volmer <13285635+kilianvolmer@users.noreply.github.com> Co-authored-by: jubicker <113909589+jubicker@users.noreply.github.com> Co-authored-by: Anna Wendler <106674756+annawendler@users.noreply.github.com> Co-authored-by: Carlotta Gerstein <carlotta-gerstein@web.de> Co-authored-by: Henrik Zunker <henrik.zunker@dlr.de> Co-authored-by: Sascha <51127093+xsaschako@users.noreply.github.com> Co-authored-by: annawendler <annawendler@users.noreply.github.com> Co-authored-by: Martin J. Kühn <mknaranja@users.noreply.github.com> Co-authored-by: Carlotta Gerstein <charlie0614@users.noreply.github.com> Co-authored-by: HenrZu <69154294+HenrZu@users.noreply.github.com> Co-authored-by: MaxBetz <crowtolp@gmail.com>
1 parent ddb324d commit 6c83abd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+5296
-2447
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Please check our [git workflow](https://memilio.readthedocs.io/en/latest/develop
2222
- [ ] New code adheres to [coding guidelines](https://memilio.readthedocs.io/en/latest/development.html#coding-guidelines)
2323
- [ ] No large data files have been added (files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
2424
- [ ] Tests are added for new functionality and a local test run was successful (with and without OpenMP)
25-
- [ ] Appropriate **documentation** for new functionality has been added (Doxygen in the code and Markdown files if necessary)
25+
- [ ] Appropriate **documentation** for new functionality has been added (Doxygen in the code and explanations in the online documentation)
2626
- [ ] Proper attention to licenses, especially no new third-party software with conflicting license has been added
2727
- [ ] (For ABM development) Checked [benchmark results](https://memilio.readthedocs.io/en/latest/development.html#agent-based-model-development) and ran and posted a local test above from before and after development to ensure performance is monitored.
2828

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,4 +283,7 @@ docs/xml
283283
docs/source/api
284284
docs/source/generated
285285

286+
# VS Code
287+
.vscode/
288+
286289
# End of https://www.gitignore.io/api/c++,node,python

README.md

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,19 @@ and, in particular, for
1515

1616
- Ordinary differential equation-based (ODE) and Graph-ODE models: Zunker H, Schmieding R, Kerkmann D, Schengen A, Diexer S, et al. (2024). *Novel travel time aware metapopulation models and multi-layer waning immunity for late-phase epidemic and endemic scenarios*. *PLOS Computational Biology* 20(12): e1012630. `https://doi.org/10.1371/journal.pcbi.1012630`
1717
- Integro-differential equation-based (IDE) models: Wendler AC, Plötzke L, Tritzschak H, Kühn MJ. (2024). *A nonstandard numerical scheme for a novel SECIR integro differential equation-based model with nonexponentially distributed stay times*. Submitted for publication. `https://arxiv.org/abs/2408.12228`
18-
- Agent-based models (ABMs): Kerkmann D, Korf S, Nguyen K, Abele D, Schengen A, et al. (2024). *Agent-based modeling for realistic reproduction of human mobility and contact behavior to evaluate test and isolation strategies in epidemic infectious disease spread*. arXiv. `https://arxiv.org/abs/2410.08050`
18+
- Agent-based models (ABMs): Kerkmann D, Korf S, Nguyen K, Abele D, Schengen A, et al. (2025). *Agent-based modeling for realistic reproduction of human mobility and contact behavior to evaluate test and isolation strategies in epidemic infectious disease spread*. *Computers in Biology and Medicine* 193: 110269. `DOI:10.1016/j.compbiomed.2025.110269 <https://doi.org/10.1016/j.compbiomed.2025.110269>`_
1919
- Hybrid agent-metapopulation-based models: Bicker J, Schmieding R, Meyer-Hermann M, Kühn MJ. (2025). *Hybrid metapopulation agent-based epidemiological models for efficient insight on the individual scale: A contribution to green computing*. *Infectious Disease Modelling* 10(2): 571-590. `https://doi.org/10.1016/j.idm.2024.12.015`
2020
- Graph Neural Networks: Schmidt A, Zunker H, Heinlein A, Kühn MJ. (2024). *Towards Graph Neural Network Surrogates Leveraging Mechanistic Expert Knowledge for Pandemic Response*. arXiv. `https://arxiv.org/abs/2411.06500`
2121
- ODE-based models with Linear Chain Trick: Plötzke L, Wendler A, Schmieding R, Kühn MJ. (2024). *Revisiting the Linear Chain Trick in epidemiological models: Implications of underlying assumptions for numerical solutions*. Submitted for publication. `https://doi.org/10.48550/arXiv.2412.09140`
2222
- Behavior-based ODE models: Zunker H, Dönges P, Lenz P, Contreras S, Kühn MJ. (2025). *Risk-mediated dynamic regulation of effective contacts de-synchronizes outbreaks in metapopulation epidemic models*. arXiv. `https://arxiv.org/abs/2502.14428`
2323

2424
**Getting started**
2525

26-
MEmilio builds upon different model types, equation-based and agent-based. Furthermore, there are hybrid, graph-ODE-based models. Among the equation-based models, we provide ordinary differential equation (ODE) and integro-differential equation (IDE) based models. In order to provide highly efficient model implementations, MEmilio builds upon a C++ backend for its model and simulation-related content. Data acquisition, plotting, and machine-learnt models are provided in Python.
2726

28-
Details of the C++ implementation of the epidemiological models can be found in the cpp directory (see the [README](cpp/README.md) there).
29-
30-
Some regularly used data for simulations of a pathogen's spread in Germany, like contact and inter-county mobility, can be found in [data](data/README.md).
31-
32-
In pycode, different MEmilio python packages are defined. Via our [memilio-simulation](pycode/memilio-simulation) package, you can run our C++ backend from python; this package uses [pybind11](https://github.com/pybind/pybind11) to bind our C++ model code. The [memilio-epidata](pycode/memilio-epidata) package provides tools to download and structure important data such as infection or mobility data. More about the python packages can be found in [Python README](pycode/README.rst).
33-
34-
**Documentation**
35-
36-
Each important part of the project described above is described in detail in the README in the corresponding directory. The README contains e.g. configuration and usage instructions for users and developers.
37-
38-
Also, the code is documented with doxygen and instructions on how to obtain it can be found in the docs folder.
39-
The documentation of the code of the main branch can be found at the following URL:
40-
41-
https://scicompmod.github.io/memilio/documentation/index.html
42-
43-
**Installation, Usage and Requirements**
44-
45-
Each part has different requirements and usage. Detailed instruction can be found in the corresponding READMEs.
27+
The documentation for MEmilio can be found at
28+
https://memilio.readthedocs.io/en/latest/index.html
4629

4730
**Development**
4831

49-
* [Git workflow and change process](https://github.com/SciCompMod/memilio/wiki/git-workflow)
50-
* [Coding Guidelines](https://github.com/SciCompMod/memilio/wiki/coding-guidelines)
32+
The coding guidelines and git workflow description can be found in the documentation at
33+
https://memilio.readthedocs.io/en/latest/development.html

cpp/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Options can be specified with `cmake .. -D<OPTION>=<VALUE>` or by editing the `b
6262
- `MEMILIO_ENABLE_WARNINGS`: enable compilation warnings (beyond those enabled in the compiler by default). ON or OFF, default ON.
6363
- `MEMILIO_ENABLE_WARNINGS_AS_ERRORS`: compilation warnings are treated as compilation errors. ON or OFF, default ON.
6464
- `MEMILIO_ENABLE_PROFILING`: compile with runtime profiling support. ON or OFF, default OFF. See [here](benchmarks/profiling.md) for information.
65+
- `MEMILIO_ENABLE_LIKWID_MARKER`: compile MEmilio with likwid markers. ON or OFF, default OFF.
6566

6667
Other important options may need:
6768
- `CMAKE_BUILD_TYPE`: controls compiler optimizations and diagnostics, Debug, Release, or RelWithDebInfo; not available for Multi-Config CMake Generators like Visual Studio, set the build type in the IDE or when running the compiler.

cpp/memilio/compartments/simulation.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ class Simulation
119119
return m_result;
120120
}
121121

122-
/**
123-
* @brief get_result returns the final simulation result
124-
* @return a TimeSeries to represent the final simulation result
125-
*/
126122
const TimeSeries<FP>& get_result() const
127123
{
128124
return m_result;

cpp/models/abm/README.md

Lines changed: 5 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,8 @@
11
# Agent-Based Model
22

3-
This module models and simulates the epidemic using an agent-based model (*ABM*) approach. Unlike compartmental models like the [SECIR](../ode_secir/README.md) model that uses a system of ODEs, this model simulates the spread of COVID-19 in a population with discrete persons (the agents) moving throughout locations in the model and interacting with (infecting) each other.
3+
This directory contains the agent based model.
4+
To get started, check out the [official documentation](https://memilio.readthedocs.io/en/latest/cpp/mobility_based_abm.html)
5+
or the code examples
46

5-
## Structure
6-
7-
The model consists of the following major classes:
8-
9-
1. Person: represents an agent of the model. A person has an ID, i.e. a unique number, an age, a location and a list with their assigned locations, i.e. the locations it can visit during the simulation. They can perform tests and wear masks. Every person has lists with past and current infections and vaccinations.
10-
2. Infection: collection of all information about a persons' infection, i.e. infectiousness, infection course, virus variant. The infection course is drawn stochastically from the infection states that are similar to the compartments of the SECIR model.
11-
3. Location: represents places in the model where people meet and interact, e.g. home, school, work, social event sites. A location can be split into cells to model parts of a location, like classrooms in a school. Some infection parameters are location-specific and one can activate NPIs like mandatory masks or tests to enter the location.
12-
4. Model: collection of all persons and locations. It also holds information about the testing strategy of the simulation and holds the rules for the mobility phase.
13-
5. Simulation: runs the simulation and stores results.
14-
15-
## Simulation
16-
17-
The simulation runs in discrete time steps. Each step has two phases, an interaction phase and a mobility phase.
18-
19-
### Interaction Phase
20-
21-
In this phase, each person interacts with the other persons at the same location. This interaction determines the transmission of the disease. A susceptible person can become infected by contact with an infected person. The probability of infection depends on a multitude of factors, such as the viral load and infectiousness of the infected and the immunity level of the susceptible person at the time of transmission.
22-
23-
### Mobility Phase
24-
25-
During the mobility phase, each person may change their location. Mobility follows complex [rules](../abm/mobility_rules.cpp), considering the current location, time of day, and properties of the person (e.g. age). Some location changes are deterministic and regular (e.g. going to work), others are random (e.g. going to shopping or to a social event in the evening/on the weekend). When agents are tested positive, they are quarantined and cannot leave their home, unless their infection becomes worse and they have to go to the hospital or the ICU. In general, if an agent suffers from severe or critical symptoms, it will move to the hospital or ICU with highest priority. Some mobility rules can be restricted by allowing only a proportion of people to enter specific locations.
26-
27-
Another way of mobility we use in the simulation of Braunschweig (simulations/abm_braunschweig.cpp) is using trips. A trip consists of the ID of the person that performs this trip, a time point when this trip is performed and where the person is heading to. At the beginning of the simulation, a list with all trips is initialized and followed during the simulation. There can be different trips on the weekend than during the week, but other than that, the agents do the same trips every day. As before, agents that are in quarantine or in the hospital cannot change their location.
28-
29-
## Get Started
30-
31-
This section gives an introduction to how to use the ABM and set up your own simulation. For a quick overview, can find a full example in the [ABM minimal example](../../examples/abm_minimal.cpp) and a more detailed Doxygen documentation [here](https://scicompmod.github.io/memilio/documentation/index.html ). For a guide on installation and running the simulations and examples, see this [README](../../README.md).
32-
33-
Every person in the ABM belongs to an AgeGroup, which we can define as follows:
34-
35-
```cpp
36-
size_t num_age_groups = 4;
37-
const auto age_group_0_to_4 = mio::AgeGroup(0);
38-
const auto age_group_5_to_14 = mio::AgeGroup(1);
39-
... = ...
40-
```
41-
42-
Note that every age group has to have values strictly smaller than the number of age groups `num_age_groups`.
43-
With this number we create an empty model:
44-
45-
```cpp
46-
auto model = mio::abm::Model(num_age_groups);
47-
```
48-
49-
We can set several general parameters, which you can find [here](../abm/parameters.h). Here is an example where we set the time to go from Exposed to InfectedNoSymptoms to 4 days:
50-
51-
```cpp
52-
model.parameters.get<mio::abm::TimeExposedToNoSymptoms>() = mio::ParameterDistributionConstant(4.);
53-
```
54-
55-
To add a location to the model, we have to specify the kind of location.
56-
57-
```cpp
58-
auto home = model.add_location(mio::abm::LocationType::Home);
59-
```
60-
61-
People are added with an age. Then we have to assign them, so the model knows they can travel to this location.
62-
63-
```cpp
64-
auto person = model.add_person(home, age_group_0_to_4);
65-
person.set_assigned_location(home);
66-
```
67-
68-
For adding more people to the model, we create households. A Household holds a vector of HouseholdMembers, which in turn hold a weighted distribution, such that we can randomly draw the age of each Person belonging to the Household. To manage multiple Households of the same type, we can use a HouseholdGroup.
69-
In our example, we categorize individuals into two groups: children and parents.
70-
71-
- Children: They can either belong to AgeGroup(0) or AgeGroup(1). The probability of a child belonging to either group is 0.5.
72-
- Parents: They can either belong to AgeGroup(2) or AgeGroup(3). The probability of a parent belonging to either group is also 0.5.
73-
74-
We then form households in two ways:
75-
76-
1. Households with one parent and one child.
77-
2. Households with two parents and one child.
78-
79-
```cpp
80-
auto child = mio::abm::HouseholdMember(num_age_groups);
81-
child.set_age_weight(age_group_0_to_4, 1);
82-
child.set_age_weight(age_group_0_to_4, 1);
83-
84-
auto parent = mio::abm::HouseholdMember(num_age_groups);
85-
parent.set_age_weight(age_groups_15_to_34, 1);
86-
parent.set_age_weight(age_groups_35_to_59, 1);
87-
88-
// Two-person household with one parent and one child.
89-
auto twoPersonHousehold_group = mio::abm::HouseholdGroup();
90-
auto twoPersonHousehold_full = mio::abm::Household();
91-
twoPersonHousehold_full.add_members(child, 1);
92-
twoPersonHousehold_full.add_members(parent, 1);
93-
twoPersonHousehold_group.add_households(twoPersonHousehold_full, n_households);
94-
add_household_group_to_model(model, twoPersonHousehold_group);
95-
96-
```
97-
98-
During the simulation, people can get tested, and we have to specify the scheme for that:
99-
100-
```cpp
101-
auto probability = 0.5;
102-
auto start_date = mio::abm::TimePoint(0);
103-
auto end_date = mio::abm::TimePoint(0) + mio::abm::days(30);
104-
auto test_type = mio::abm::AntigenTest();
105-
auto test_at_work = std::vector<mio::abm::LocationType>{mio::abm::LocationType::Work};
106-
auto testing_criteria_work =
107-
std::vector<mio::abm::TestingCriteria>{mio::abm::TestingCriteria({}, test_at_work, {})};
108-
auto testing_scheme_work =
109-
mio::abm::TestingScheme(testing_criteria_work, start_date, end_date, test_type, probability);
110-
model.get_testing_strategy().add_testing_scheme(testing_scheme_work);
111-
```
112-
113-
For some infections to happen during the simulation, we have to initialize people with infections.
114-
115-
```cpp
116-
person.add_new_infection(mio::abm::Infection(rng, mio::abm::VirusVariant::Wildtype, person.get_age(), model.parameters, start_date, infection_state));
117-
```
118-
119-
We can add restrictions for people after a specific date. For example, only 10% of the people go to social events after day 10.
120-
121-
```cpp
122-
auto t_lockdown = mio::abm::TimePoint(0) + mio::abm::days(10);
123-
mio::abm::close_social_events(t_lockdown, 0.9, model.parameters);
124-
```
125-
126-
Then we run the simulation.
127-
128-
```cpp
129-
sim.advance(mio::abm::TimePoint(0) + mio::abm::days(30));
130-
```
131-
132-
Alternitavely, if we want to track things in the simulation, we need to set up a [history](../../memilio/io/README.md#the-history-object), for example, to track all the Infection states of each simulation step.
133-
134-
```cpp
135-
mio::History<mio::abm::TimeSeriesWriter, mio::abm::LogInfectionState> history;
136-
```
137-
138-
Then we can run the simulation with the history object and one can access the data it through get_log.
139-
140-
```cpp
141-
sim.advance(tmax, history);
142-
auto log = history.get_log();
143-
```
144-
145-
Finally we can print the data to a text file.
146-
147-
```cpp
148-
std::ofstream outfile("abm_minimal.txt");
149-
std::get<0>(log).print_table({"S", "E", "I_NS", "I_Sy", "I_Sev", "I_Crit", "R", "D"}, 7, 4, outfile);
150-
std::cout << "Results written to abm_minimal.txt" << std::endl;
151-
```
152-
153-
## Current Limitations
154-
155-
Currently, a few things are not yet implemented, such as:
156-
157-
- Different trips for each day.
158-
- Test and Trace functionality
7+
- [examples/abm.cpp](../../examples/abm_minimal.cpp)
8+
- [examples/abm_minimal.cpp](../../examples/abm_history_object.cpp)

cpp/models/d_abm/README.md

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
# Diffusive Agent-Based Model
22

3-
This agent-based model uses a Markov process to simulate disease dynamics. The features of an agent are position and infection state. The evolution of the system state is determined by the following master equation
4-
5-
```math
6-
\partial_t p(X,Z;t) = G p(X,Z;t) + L p(X,Z;t)
7-
```
8-
The operator $G$ defines the infection state adoptions and only acts on $Z$, while $L$ defines location changes, only acting on $X$. Infection state adoptions are modeled with independent Poisson processes given by adoption rate functions. Movement is modeled with independent diffusion processes. A temporal Gillespie algorithm is used for simulation, a direct method without rejection sampling. Therefore, $G$ and $L$ are not implemented explicitly, instead their effects are sampled via the `move` and `adoption_rate` functions, respectively.
9-
10-
The Model class needs an Implementation class as template argument which provides the domain agents move and interact in. We here implemented a quadwell potential given in the class QuadWellModel, but any other suitable potential can be used as implementation.
11-
12-
## Simulation
13-
14-
The simulation runs in discrete time steps. In every step we advance the model until the next infection state adoption event, then adopt the corresponding agent's infection state and draw a new waiting time until the next adoption event. If the waiting time until the next adoption event is bigger than the remaining time in the time step, we advance the model until the end of the time step.
15-
16-
For a detailed description and application of the model, see:
17-
18-
- Bicker J, Schmieding R, et al. (2025) Hybrid metapopulation agent-based epidemiological models for efficient insight on the individual scale: A contribution to green computing.
19-
Infectious Disease Modelling, Volume 10, Issue 2. https://doi.org/10.1016/j.idm.2024.12.015
3+
This directory contains the diffusive agent based model implementation.
4+
To get started, check out the [official documentation](https://memilio.readthedocs.io/en/latest/cpp/diffusive_abm.html)
5+
or the [code examples](../../examples/d_abm.cpp).

0 commit comments

Comments
 (0)