Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1036 Simulations from paper to investigate behavior of IDE model #1130

Open
wants to merge 78 commits into
base: main
Choose a base branch
from

Conversation

annawendler
Copy link
Member

@annawendler annawendler commented Sep 27, 2024

Changes and Information

  • Add simulations and plots from paper to main branch
  • In particular, the following simulations can be conducted with the added scripts:
    • Changepoint simulation
    • Scenario based on the spread of COVID-19 in Germany
    • Investigation of the rate of convergence of the implemented non-standard numerical solver

Merge Request - Guideline Checklist

Please check our git workflow. Use the draft feature if the Pull Request is not yet ready to review.

Checks by code author

  • Every addressed issue is linked (use the "Closes #ISSUE" keyword below)
  • New code adheres to coding guidelines
  • No large data files have been added (files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
  • Tests are added for new functionality and a local test run was successful (with and without OpenMP)
  • Appropriate documentation for new functionality has been added (Doxygen in the code and Markdown files if necessary)
  • Proper attention to licenses, especially no new third-party software with conflicting license has been added
  • (For ABM development) Checked benchmark results and ran and posted a local test above from before and after development to ensure performance is monitored.

Checks by code reviewer(s)

  • Corresponding issue(s) is/are linked and addressed
  • Code is clean of development artifacts (no deactivated or commented code lines, no debugging printouts, etc.)
  • Appropriate unit tests have been added, CI passes, code coverage and performance is acceptable (did not decrease)
  • No large data files added in the whole history of commits(files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
  • On merge, add 2-5 lines with the changes (main added features, changed items, or corrected bugs) to the merge-commit-message. This can be taken from the briefly-list-the-changes above (best case) or the separate commit messages (worst case).

Closes #1036
Closes #1097
Closes #411

annawendler and others added 30 commits May 21, 2024 08:37
…e-of-the-discretization-scheme-from-the-ide-model' into 1036-ide-simulations
Copy link
Member

@lenaploetzke lenaploetzke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First part of review


- Section 5.1: With the file [ide_convergence_rate](ide_convergence_rate.cpp) simulations with an integro-differential-based model (IDE model) and an ordinary differential-based model (ODE model) with different time step sizes can be performed to analyze the order of convergence of the introduced nonstandard numerical scheme. The visualization of the results can be done with [plot_convergence](plot_convergence.py).

- Section 5.2: In [ide_changepoints](ide_chanepoints.cpp) a simulation with both our IDE and an ODE model is performed where a change in the contact rate is applied after two days to investigate the model behavior at change points. The results can be visualized with [plot_changepoints](plot_changepoints.py).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Section 5.2: In [ide_changepoints](ide_chanepoints.cpp) a simulation with both our IDE and an ODE model is performed where a change in the contact rate is applied after two days to investigate the model behavior at change points. The results can be visualized with [plot_changepoints](plot_changepoints.py).
- Section 5.2: In [ide_changepoints](ide_chanepoints.cpp), a simulation with both our IDE and an ODE model is performed, where a change in the contact rate is applied after two days to investigate the model behavior at change points. The results can be visualized with [plot_changepoints](plot_changepoints.py).


Below is an overview of the files and the paper sections they belong to.

- Section 5.1: With the file [ide_convergence_rate](ide_convergence_rate.cpp) simulations with an integro-differential-based model (IDE model) and an ordinary differential-based model (ODE model) with different time step sizes can be performed to analyze the order of convergence of the introduced nonstandard numerical scheme. The visualization of the results can be done with [plot_convergence](plot_convergence.py).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Section 5.1: With the file [ide_convergence_rate](ide_convergence_rate.cpp) simulations with an integro-differential-based model (IDE model) and an ordinary differential-based model (ODE model) with different time step sizes can be performed to analyze the order of convergence of the introduced nonstandard numerical scheme. The visualization of the results can be done with [plot_convergence](plot_convergence.py).
- Section 5.1: With the file [ide_convergence_rate](ide_convergence_rate.cpp) simulations with an integro-differential equation-based model (IDE model) and an ordinary differential equation-based model (ODE model) with different time step sizes can be performed to analyze the order of convergence of the introduced nonstandard numerical scheme. The visualization of the results can be done with [plot_convergence](plot_convergence.py).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe nonstandard numerical scheme for the IDE model? Maybe add also somewhere a SECIR- ?


- Section 5.3: The COVID-19 inspired scenario can be run with [ide_covid_inspired_scenario](ide_covid_inspired_scenario.cpp).

For the transition probabilities we use data from [Assessment of effective mitigation and prediction of the spread of SARS-CoV-2 in Germany using demographic information and spatial resolution](https://doi.org/10.1016/j.mbs.2021.108648) and [Covasim: An agent-based model of COVID-19 dynamics and interventions](https://doi.org/10.1371/journal.pcbi.1009149). There, the data is age-resolved. We consider a model without age resolution which is why compute according parameters by averaging over the age groups. This is done in [compute_parameters](compute_parameters.cpp).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this also the case for the cangepoints? Maybe you can reformat this somehow or add a comment


For the transition probabilities we use data from [Assessment of effective mitigation and prediction of the spread of SARS-CoV-2 in Germany using demographic information and spatial resolution](https://doi.org/10.1016/j.mbs.2021.108648) and [Covasim: An agent-based model of COVID-19 dynamics and interventions](https://doi.org/10.1371/journal.pcbi.1009149). There, the data is age-resolved. We consider a model without age resolution which is why compute according parameters by averaging over the age groups. This is done in [compute_parameters](compute_parameters.cpp).

For the stay time distributions in the respective compartments we used lognormal distributions as in [Covasim: An agent-based model of COVID-19 dynamics and interventions](https://doi.org/10.1371/journal.pcbi.1009149). There, the mean and the standard deviation were given. In order to use it with our implementation, we computed the corresponding shape and scale parameters with [get_lognormal_parameters](get_lognormal_parameters.py).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For the stay time distributions in the respective compartments we used lognormal distributions as in [Covasim: An agent-based model of COVID-19 dynamics and interventions](https://doi.org/10.1371/journal.pcbi.1009149). There, the mean and the standard deviation were given. In order to use it with our implementation, we computed the corresponding shape and scale parameters with [get_lognormal_parameters](get_lognormal_parameters.py).
For the stay time distributions in the respective compartments, we used lognormal distributions as in [Covasim: An agent-based model of COVID-19 dynamics and interventions](https://doi.org/10.1371/journal.pcbi.1009149). There, the mean and the standard deviation were given. In order to use it with our implementation, we computed the corresponding shape and scale parameters with [get_lognormal_parameters](get_lognormal_parameters.py).

- Data on reported cases can be downloaded with [getCaseData](../../../pycode/memilio-epidata/memilio/epidata/getCaseData.py). To obtain the data, use the options moving_average = 7 and impute_dates = True when downloading the data. For the other function parameters, one can use default parameters from [defaultDict](../../../pycode/memilio-epidata/memilio/epidata/defaultDict.py).

When simulating, we set the contact rate such that the daily new transmissions of the IDE simulation are consistent with the reported data at the beginning of the simulation. The contact scaling and the visualization is done in [run_and_plot_covid_inspired_scenario](run_and_plot_covid_inspired_scenario.py). For the scaling and the subsequent visualization we used case data from RKI (not averaged) and data on ICU patients as reported from DIVI.
- To obtain the case data, use [getCaseData](../../../pycode/memilio-epidata/memilio/epidata/getCaseData.py) with the option impute_dates = True when downloading.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment that ma7 is not set here.


mio::osecir::Model<ScalarType> model_ode(1);

// Set initial values for compartments.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add comment that they are random


// Set parameters.
ScalarType cont_freq = simulation_parameter["cont_freq"];
// Set Seasonality=0 so that cont_freq_eff is equal to contact_matrix.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as abpve

simulation_parameter["total_population"]);

// Set parameters.
ScalarType cont_freq = simulation_parameter["cont_freq"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this extra variable

mio::isecir::Model model_ide(std::move(init_transitions), total_population, deaths, num_agegroups);

// Set parameters.
// Contact matrix; contact_matrix was already defined for ODE.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Contact matrix; contact_matrix was already defined for ODE.
// contact_matrix was already defined for ODE.


if (!result_dir.empty() && save_exponent > 0) {
// Create result directory if not existent yet.
boost::filesystem::path res_dir(result_dir);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boost filesystem header ?

Copy link
Member

@lenaploetzke lenaploetzke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really really nice work :)


// ----- Add NPIs to the contact matrices. -----
// Set of NPIs for October.
if (start_date == mio::Date(2020, 10, 1)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just if really 1.10. or also if maybe 30.9.? I mean for the simulations conducted, this is not relevant


/**
* @brief Set the contact pattern of parameters for a model without division in age groups without using the
* age-resolved contact_matrices.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somehow doubled

* @param[in] contact_matrices Contact matrices used.
* @param[in] data_dir Directory to files with minimum and baseline contact matrices and reported data from RKI.
* @param[in] save_dir Directory where simulation results will be stored.
* @returns Any IO errros that happen.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or a vector

* @param[in] start_date Start date of the simulation
* @param[in] simulation_time Duration of the simulation.
* @param[in] contact_matrices Contact matrices used.
* @param[in] data_dir Directory to files with minimum and baseline contact matrices and reported data from RKI.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported_data_dir

* @param[in] simulation_time Duration of the simulation.
* @param[in] contact_matrices Contact matrices used.
* @param[in] data_dir Directory to files with minimum and baseline contact matrices and reported data from RKI.
* @param[in] save_dir Directory where simulation results will be stored.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default

@returns df_result Dataframe containing processed RKI data.
"""
# Set start date and end date according to input arguments.
parameters['start_date'] = start_date
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

@param[in] start_date Start date of the simulations.
@param[in] simulation_time Duration of the simulation.
@param[in] fileending String that further specifies filename of plot.
@param[in] Directory where plot will be stored. If this is not set, the plot will not be stored.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@param[in] Directory where plot will be stored. If this is not set, the plot will not be stored.
@param[in] save_dir Directory where plot will be stored. If this is not set, the plot will not be stored.

@param[in] start_date Start date of the simulations.
@param[in] simulation_time Duration of the simulation.
@param[in] fileending String that further specifies filename of plot.
@param[in] Directory where plot will be stored. If this is not set, the plot will not be stored.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@param[in] Directory where plot will be stored. If this is not set, the plot will not be stored.
@param[in] save_dir Directory where plot will be stored. If this is not set, the plot will not be stored.

@param[in] start_date Start date of the simulations.
@param[in] simulation_time Duration of the simulation.
@param[in] fileending String that further specifies filename of plot.
@param[in] Directory where plot will be stored. If this is not set, the plot will not be stored.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@param[in] Directory where plot will be stored. If this is not set, the plot will not be stored.
@param[in] save_dir Directory where plot will be stored. If this is not set, the plot will not be stored.

""" Plots the number of ICU patients obtained by simulations with an ODE and an IDE model as well as
the number of ICU patients as reported by DIVI.

@param[in] files Expects list of two files with ODE and IDE simulation results for flows, respectively, in this order.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really flows? or compartments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants