-
Notifications
You must be signed in to change notification settings - Fork 16
323 SECIRTS model with waning immunity #963
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
Merged
Merged
Changes from all commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
4621dab
SECIRTS model (init and eq)
HenrZu bb3be6e
[wip] fix build
HenrZu 82deb6f
again
HenrZu 6dc2b16
fix epi data io tests and hopefully msvc
HenrZu 286aff5
vacc data with multiple vacc
HenrZu 60d3d5c
fix tests
HenrZu edf6b14
fix msvc
HenrZu 8f5b4e1
fix gcc
HenrZu b7a1ff0
move h5 to right dir
HenrZu fd7ac98
missing init files
HenrZu e4007ba
missing file
HenrZu 420afe2
diff in line ending between Linux/Win
HenrZu 13afaf9
disable vvs example
HenrZu f5af938
add some tests
HenrZu ab1041a
more tests + fix msvc
HenrZu 30f2060
improve draw_sample_demographics
HenrZu 4f9e512
remove unused entries from test data
HenrZu 4c3ee09
example, some namings
HenrZu c8e261b
Merge branch 'main' into 323-waning-immunity-model
HenrZu aeb5e4a
fixes from merge
HenrZu 4a8dc03
Merge branch 'main' into 323-waning-immunity-model
HenrZu bade952
vaccinations at t = 0
HenrZu 02db84e
typo booster vacc
HenrZu a7d95a2
naming + parameter space static var
HenrZu 6a1119d
smooth vaccinations
HenrZu d9fb617
smoothing vaccinations + tests
HenrZu 69f45f8
move into own directory secirts
HenrZu 5f15d46
Merge branch 'main' into 323-waning-immunity-model
HenrZu 4b4e685
reset changes vvs, adjust tests, naming
HenrZu 30a7977
[ci skip] reset readme secirvvs
HenrZu 40910b5
fix test data, static cast for msvc
HenrZu dcb27b1
some more casts
HenrZu d216878
again
HenrZu f67eaf7
doc
HenrZu 1148eff
libary in example cmakelist
HenrZu d48e76c
Merge branch 'main' into 323-waning-immunity-model
HenrZu c778797
add template for params .............
HenrZu 14d2d8b
fix template args for msvc, rm run_simulation test
HenrZu 718a1fd
Merge branch 'main' into 323-waning-immunity-model
HenrZu ebb991f
rm template from get_num_groups
HenrZu 1be3faa
tests for get_flows, sim and flow sim
HenrZu 48dffed
clean up infection_states
HenrZu 381914a
fix init pop
HenrZu 30603d2
Merge branch 'main' into 323-waning-immunity-model
HenrZu 0f4b1cd
rename params
HenrZu 4ca0d3e
bound checking vaccinations_at
HenrZu 929988b
vaccination(s) to plural
HenrZu 158cdba
[ci skip] example description, first and additional vacc
HenrZu 495eab7
complete rework parameters_io.h
HenrZu d2a3976
rm old immunity files. Optional args
HenrZu f2c4d54
doc for parameters, rm unused param
HenrZu 240270d
some doc about the different immunity layers
HenrZu b22e49d
Merge branch 'main' into 323-waning-immunity-model
HenrZu eb6d181
fixes from merge
HenrZu 69d545a
fix msvc
HenrZu ce425b3
next try mvsc
HenrZu 3e165b7
and again
HenrZu 311ad77
rm doubled in check_constraint, bounds in vaccinations
HenrZu 90f1a96
some naming, more tests in parameters_io
HenrZu de4a21d
rm old immunity txt file
HenrZu 343af7a
rework for review comments
HenrZu 5d0749c
Update cpp/simulations/CMakeLists.txt
HenrZu 8039e02
Update cpp/models/ode_secirts/parameters_io.h
HenrZu 0243aab
Merge branch 'main' into 323-waning-immunity-model
HenrZu 309f351
update author list
HenrZu a4f217d
Update cpp/models/ode_secirts/README.md
HenrZu 6b7433f
rename TIs, PR 982, PR 1104, Factors TT,
HenrZu a2c9fb3
update test and trace
HenrZu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/* | ||
* Copyright (C) 2020-2024 MEmilio | ||
* | ||
* Authors: Henrik Zunker | ||
* | ||
* Contact: Martin J. Kuehn <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include "ode_secirts/analyze_result.h" | ||
#include "ode_secirts/model.h" | ||
#include "ode_secirts/parameters.h" | ||
#include "memilio/compartments/simulation.h" | ||
#include "memilio/utils/logging.h" | ||
|
||
int main() | ||
{ | ||
// This example demonstrates how to simulate a SECIRTS model. | ||
// The SECIRTS model is an extension of the SECIRVVS model that includes waning and temporary immunity. | ||
// After the simulation, the aggregated size of the temporary immunity states are printed. | ||
mio::set_log_level(mio::LogLevel::debug); | ||
|
||
double t0 = 0; | ||
double tmax = 100; | ||
double dt = 0.1; | ||
|
||
mio::log_info("Simulating SECIRTS; t={} ... {} with dt = {}.", t0, tmax, dt); | ||
|
||
mio::osecirts::Model<double> model(3); | ||
auto nb_groups = model.parameters.get_num_groups(); | ||
|
||
for (mio::AgeGroup i = 0; i < nb_groups; i++) { | ||
// population | ||
model.populations[{i, mio::osecirts::InfectionState::ExposedNaive}] = 20; | ||
model.populations[{i, mio::osecirts::InfectionState::ExposedImprovedImmunity}] = 20; | ||
model.populations[{i, mio::osecirts::InfectionState::ExposedPartialImmunity}] = 20; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedNoSymptomsNaive}] = 30; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedNoSymptomsNaiveConfirmed}] = 0; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedNoSymptomsPartialImmunity}] = 30; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedNoSymptomsPartialImmunityConfirmed}] = 0; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedNoSymptomsImprovedImmunity}] = 30; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedNoSymptomsImprovedImmunityConfirmed}] = 0; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedSymptomsNaive}] = 40; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedSymptomsNaiveConfirmed}] = 0; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedSymptomsPartialImmunity}] = 40; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedSymptomsPartialImmunityConfirmed}] = 0; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedSymptomsImprovedImmunity}] = 40; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedSymptomsImprovedImmunityConfirmed}] = 0; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedSevereNaive}] = 30; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedSevereImprovedImmunity}] = 30; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedSeverePartialImmunity}] = 30; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedCriticalNaive}] = 20; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedCriticalPartialImmunity}] = 20; | ||
model.populations[{i, mio::osecirts::InfectionState::InfectedCriticalImprovedImmunity}] = 20; | ||
model.populations[{i, mio::osecirts::InfectionState::SusceptibleNaive}] = 1000; | ||
model.populations[{i, mio::osecirts::InfectionState::SusceptiblePartialImmunity}] = 1200; | ||
model.populations[{i, mio::osecirts::InfectionState::SusceptibleImprovedImmunity}] = 1000; | ||
model.populations[{i, mio::osecirts::InfectionState::TemporaryImmunePartialImmunity}] = 60; | ||
model.populations[{i, mio::osecirts::InfectionState::TemporaryImmuneImprovedImmunity}] = 70; | ||
model.populations[{i, mio::osecirts::InfectionState::DeadNaive}] = 0; | ||
model.populations[{i, mio::osecirts::InfectionState::DeadPartialImmunity}] = 0; | ||
model.populations[{i, mio::osecirts::InfectionState::DeadImprovedImmunity}] = 0; | ||
|
||
// parameters | ||
//times | ||
model.parameters.get<mio::osecirts::TimeExposed<double>>()[i] = 3.33; | ||
model.parameters.get<mio::osecirts::TimeInfectedNoSymptoms<double>>()[i] = 1.87; | ||
model.parameters.get<mio::osecirts::TimeInfectedSymptoms<double>>()[i] = 7; | ||
model.parameters.get<mio::osecirts::TimeInfectedSevere<double>>()[i] = 6; | ||
model.parameters.get<mio::osecirts::TimeInfectedCritical<double>>()[i] = 7; | ||
model.parameters.get<mio::osecirts::TimeTemporaryImmunityPI<double>>()[i] = 60; | ||
model.parameters.get<mio::osecirts::TimeTemporaryImmunityII<double>>()[i] = 60; | ||
model.parameters.get<mio::osecirts::TimeWaningPartialImmunity<double>>()[i] = 180; | ||
model.parameters.get<mio::osecirts::TimeWaningImprovedImmunity<double>>()[i] = 180; | ||
|
||
//probabilities | ||
model.parameters.get<mio::osecirts::TransmissionProbabilityOnContact<double>>()[i] = 0.15; | ||
model.parameters.get<mio::osecirts::RelativeTransmissionNoSymptoms<double>>()[i] = 0.5; | ||
model.parameters.get<mio::osecirts::RiskOfInfectionFromSymptomatic<double>>()[i] = 0.0; | ||
model.parameters.get<mio::osecirts::MaxRiskOfInfectionFromSymptomatic<double>>()[i] = 0.4; | ||
model.parameters.get<mio::osecirts::RecoveredPerInfectedNoSymptoms<double>>()[i] = 0.2; | ||
model.parameters.get<mio::osecirts::SeverePerInfectedSymptoms<double>>()[i] = 0.1; | ||
model.parameters.get<mio::osecirts::CriticalPerSevere<double>>()[i] = 0.1; | ||
model.parameters.get<mio::osecirts::DeathsPerCritical<double>>()[i] = 0.1; | ||
|
||
model.parameters.get<mio::osecirts::ReducExposedPartialImmunity<double>>()[i] = 0.8; | ||
model.parameters.get<mio::osecirts::ReducExposedImprovedImmunity<double>>()[i] = 0.331; | ||
model.parameters.get<mio::osecirts::ReducInfectedSymptomsPartialImmunity<double>>()[i] = 0.65; | ||
model.parameters.get<mio::osecirts::ReducInfectedSymptomsImprovedImmunity<double>>()[i] = 0.243; | ||
model.parameters.get<mio::osecirts::ReducInfectedSevereCriticalDeadPartialImmunity<double>>()[i] = 0.1; | ||
model.parameters.get<mio::osecirts::ReducInfectedSevereCriticalDeadImprovedImmunity<double>>()[i] = 0.091; | ||
model.parameters.get<mio::osecirts::ReducTimeInfectedMild<double>>()[i] = 0.9; | ||
} | ||
|
||
model.parameters.get<mio::osecirts::ICUCapacity<double>>() = 100; | ||
model.parameters.get<mio::osecirts::TestAndTraceCapacity<double>>() = 0.0143; | ||
const size_t daily_vaccinations = 10; | ||
const size_t num_days = 300; | ||
model.parameters.get<mio::osecirts::DailyPartialVaccinations<double>>().resize(mio::SimulationDay(num_days)); | ||
model.parameters.get<mio::osecirts::DailyFullVaccinations<double>>().resize(mio::SimulationDay(num_days)); | ||
model.parameters.get<mio::osecirts::DailyBoosterVaccinations<double>>().resize(mio::SimulationDay(num_days)); | ||
for (size_t i = 0; i < num_days; ++i) { | ||
for (mio::AgeGroup j = 0; j < nb_groups; ++j) { | ||
auto num_vaccinations = static_cast<double>(i * daily_vaccinations); | ||
model.parameters.get<mio::osecirts::DailyPartialVaccinations<double>>()[{j, mio::SimulationDay(i)}] = | ||
num_vaccinations; | ||
model.parameters.get<mio::osecirts::DailyFullVaccinations<double>>()[{j, mio::SimulationDay(i)}] = | ||
num_vaccinations; | ||
model.parameters.get<mio::osecirts::DailyBoosterVaccinations<double>>()[{j, mio::SimulationDay(i)}] = | ||
num_vaccinations; | ||
} | ||
} | ||
|
||
mio::ContactMatrixGroup& contact_matrix = model.parameters.get<mio::osecirts::ContactPatterns<double>>(); | ||
const double cont_freq = 10; | ||
const double fact = 1.0 / (double)(size_t)nb_groups; | ||
contact_matrix[0] = | ||
mio::ContactMatrix(Eigen::MatrixXd::Constant((size_t)nb_groups, (size_t)nb_groups, fact * cont_freq)); | ||
contact_matrix.add_damping(Eigen::MatrixXd::Constant((size_t)nb_groups, (size_t)nb_groups, 0.7), | ||
mio::SimulationTime(30.)); | ||
|
||
model.parameters.get<mio::osecirts::Seasonality<double>>() = 0.2; | ||
|
||
model.apply_constraints(); | ||
|
||
mio::TimeSeries<double> result = simulate(t0, tmax, dt, model); | ||
|
||
bool print_to_terminal = true; | ||
|
||
if (print_to_terminal) { | ||
auto result_interpolated = mio::interpolate_simulation_result(result); | ||
for (auto t_indx = 0; t_indx < result_interpolated.get_num_time_points(); t_indx++) { | ||
double timm_pi = 0.0; | ||
double timm_ii = 0.0; | ||
for (mio::AgeGroup i = 0; i < nb_groups; i++) { | ||
timm_pi += result_interpolated.get_value(t_indx)[model.populations.get_flat_index( | ||
{i, mio::osecirts::InfectionState::TemporaryImmunePartialImmunity})]; | ||
timm_ii += result_interpolated.get_value(t_indx)[model.populations.get_flat_index( | ||
{i, mio::osecirts::InfectionState::TemporaryImmuneImprovedImmunity})]; | ||
} | ||
printf("t=%i, timm_pi=%f, timm_ii=%f\n", int(result_interpolated.get_time(t_indx)), timm_pi, timm_ii); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.