-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathode_secir_save_results.cpp
More file actions
88 lines (73 loc) · 4.54 KB
/
ode_secir_save_results.cpp
File metadata and controls
88 lines (73 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* Copyright (C) 2020-2025 MEmilio
*
* Authors: Daniel Abele, Wadim Koslow
*
* Contact: Martin J. Kuehn <Martin.Kuehn@DLR.de>
*
* 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_secir/model.h"
#include "memilio/io/result_io.h"
#include <iostream>
int main()
{
const auto t0 = 0.;
const auto tmax = 10.;
const auto dt = 1.; //time step of mobility, not integration
ScalarType cont_freq = 10; // see Polymod study
ScalarType nb_total_t0 = 10000, nb_exp_t0 = 100, nb_inf_t0 = 50, nb_car_t0 = 50, nb_hosp_t0 = 20, nb_icu_t0 = 10,
nb_rec_t0 = 10, nb_dead_t0 = 0;
mio::osecir::Model<ScalarType> model(1);
mio::AgeGroup nb_groups = model.parameters.get_num_groups();
ScalarType fact = 1.0 / (ScalarType)(size_t)nb_groups;
auto& params = model.parameters;
params.set<mio::osecir::ICUCapacity<ScalarType>>(std::numeric_limits<ScalarType>::max());
params.set<mio::osecir::StartDay<ScalarType>>(0);
params.set<mio::osecir::Seasonality<ScalarType>>(0);
for (auto i = mio::AgeGroup(0); i < nb_groups; i++) {
params.get<mio::osecir::TimeExposed<ScalarType>>()[i] = 3.2;
params.get<mio::osecir::TimeInfectedNoSymptoms<ScalarType>>()[i] = 2.0;
params.get<mio::osecir::TimeInfectedSymptoms<ScalarType>>()[i] = 6.;
params.get<mio::osecir::TimeInfectedSevere<ScalarType>>()[i] = 12;
params.get<mio::osecir::TimeInfectedCritical<ScalarType>>()[i] = 8;
model.populations[{i, mio::osecir::InfectionState::Exposed}] = fact * nb_exp_t0;
model.populations[{i, mio::osecir::InfectionState::InfectedNoSymptoms}] = fact * nb_car_t0;
model.populations[{i, mio::osecir::InfectionState::InfectedNoSymptomsConfirmed}] = 0;
model.populations[{i, mio::osecir::InfectionState::InfectedSymptoms}] = fact * nb_inf_t0;
model.populations[{i, mio::osecir::InfectionState::InfectedSymptomsConfirmed}] = 0;
model.populations[{i, mio::osecir::InfectionState::InfectedSevere}] = fact * nb_hosp_t0;
model.populations[{i, mio::osecir::InfectionState::InfectedCritical}] = fact * nb_icu_t0;
model.populations[{i, mio::osecir::InfectionState::Recovered}] = fact * nb_rec_t0;
model.populations[{i, mio::osecir::InfectionState::Dead}] = fact * nb_dead_t0;
model.populations.set_difference_from_group_total<mio::AgeGroup>({i, mio::osecir::InfectionState::Susceptible},
fact * nb_total_t0);
params.get<mio::osecir::TransmissionProbabilityOnContact<ScalarType>>()[i] = 0.05;
params.get<mio::osecir::RelativeTransmissionNoSymptoms<ScalarType>>()[i] = 0.67;
params.get<mio::osecir::RecoveredPerInfectedNoSymptoms<ScalarType>>()[i] = 0.09;
params.get<mio::osecir::RiskOfInfectionFromSymptomatic<ScalarType>>()[i] = 0.25;
params.get<mio::osecir::SeverePerInfectedSymptoms<ScalarType>>()[i] = 0.2;
params.get<mio::osecir::CriticalPerSevere<ScalarType>>()[i] = 0.25;
params.get<mio::osecir::DeathsPerCritical<ScalarType>>()[i] = 0.3;
}
params.apply_constraints();
mio::ContactMatrixGroup<ScalarType>& contact_matrix = params.get<mio::osecir::ContactPatterns<ScalarType>>();
contact_matrix[0] = mio::ContactMatrix<ScalarType>(
Eigen::MatrixX<ScalarType>::Constant((size_t)nb_groups, (size_t)nb_groups, fact * cont_freq));
contact_matrix.add_damping(0.3, mio::SimulationTime<ScalarType>(30.));
auto result_from_sim = mio::osecir::simulate<ScalarType>(t0, tmax, dt, model);
std::vector<mio::TimeSeries<ScalarType>> results_from_sim = {result_from_sim, result_from_sim};
std::vector<int> ids = {1, 2};
auto save_result_status =
mio::save_result<ScalarType>(results_from_sim, ids, (int)(size_t)nb_groups, "test_result.h5");
}