-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparameter_setter.cpp
More file actions
192 lines (169 loc) · 11.8 KB
/
Copy pathparameter_setter.cpp
File metadata and controls
192 lines (169 loc) · 11.8 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#include "parameter_setter.h"
#include "abm/model.h"
#include <cmath>
// Age group constants
const auto age_group_0_to_4 = mio::AgeGroup(0);
const auto age_group_5_to_14 = mio::AgeGroup(1);
const auto age_group_15_to_34 = mio::AgeGroup(2);
const auto age_group_35_to_59 = mio::AgeGroup(3);
const auto age_group_60_to_79 = mio::AgeGroup(4);
const auto age_group_80_plus = mio::AgeGroup(5);
std::pair<double, double> get_mu_and_sigma(std::pair<double, double> mean_and_std)
{
auto mean = mean_and_std.first;
auto stddev = mean_and_std.second;
double mu = log(mean * mean / sqrt(mean * mean + stddev * stddev));
double sigma = sqrt(log(1 + stddev * stddev / (mean * mean)));
return {mu, sigma};
}
void set_world_parameters(mio::abm::Parameters& params)
{
auto incubation_period_mu_sigma = get_mu_and_sigma({4.5, 1.5});
params.get<mio::abm::TimeExposedToNoSymptoms>() =
mio::ParameterDistributionLogNormal(incubation_period_mu_sigma.first, incubation_period_mu_sigma.second);
auto InfectedNoSymptoms_to_symptoms_mu_sigma = get_mu_and_sigma({1.1, 0.9});
params.get<mio::abm::TimeInfectedNoSymptomsToSymptoms>() = mio::ParameterDistributionLogNormal(
InfectedNoSymptoms_to_symptoms_mu_sigma.first, InfectedNoSymptoms_to_symptoms_mu_sigma.second);
auto TimeInfectedNoSymptomsToRecovered_mu_sigma = get_mu_and_sigma({8.0, 2.0});
params.get<mio::abm::TimeInfectedNoSymptomsToRecovered>() = mio::ParameterDistributionLogNormal(
TimeInfectedNoSymptomsToRecovered_mu_sigma.first, TimeInfectedNoSymptomsToRecovered_mu_sigma.second);
auto TimeInfectedSymptomsToSevere_mu_sigma = get_mu_and_sigma({6.6, 4.9});
params.get<mio::abm::TimeInfectedSymptomsToSevere>() = mio::ParameterDistributionLogNormal(
TimeInfectedSymptomsToSevere_mu_sigma.first, TimeInfectedSymptomsToSevere_mu_sigma.second);
auto TimeInfectedSymptomsToRecovered_mu_sigma = get_mu_and_sigma({8.0, 2.0});
params.get<mio::abm::TimeInfectedSymptomsToRecovered>() = mio::ParameterDistributionLogNormal(
TimeInfectedSymptomsToRecovered_mu_sigma.first, TimeInfectedSymptomsToRecovered_mu_sigma.second);
auto TimeInfectedSevereToCritical_mu_sigma = get_mu_and_sigma({1.5, 2.0});
params.get<mio::abm::TimeInfectedSevereToCritical>() = mio::ParameterDistributionLogNormal(
TimeInfectedSevereToCritical_mu_sigma.first, TimeInfectedSevereToCritical_mu_sigma.second);
auto TimeInfectedSevereToRecovered_mu_sigma = get_mu_and_sigma({18.1, 6.3});
params.get<mio::abm::TimeInfectedSevereToRecovered>() = mio::ParameterDistributionLogNormal(
TimeInfectedSevereToRecovered_mu_sigma.first, TimeInfectedSevereToRecovered_mu_sigma.second);
auto TimeInfectedCriticalToDead_mu_sigma = get_mu_and_sigma({10.7, 4.8});
params.get<mio::abm::TimeInfectedCriticalToDead>() = mio::ParameterDistributionLogNormal(
TimeInfectedCriticalToDead_mu_sigma.first, TimeInfectedCriticalToDead_mu_sigma.second);
auto TimeInfectedCriticalToRecovered_mu_sigma = get_mu_and_sigma({18.1, 6.3});
params.get<mio::abm::TimeInfectedCriticalToRecovered>() = mio::ParameterDistributionLogNormal(
TimeInfectedCriticalToRecovered_mu_sigma.first, TimeInfectedCriticalToRecovered_mu_sigma.second);
// Set percentage parameters
params.get<mio::abm::SymptomsPerInfectedNoSymptoms>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.50;
params.get<mio::abm::SymptomsPerInfectedNoSymptoms>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.55;
params.get<mio::abm::SymptomsPerInfectedNoSymptoms>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] =
0.60;
params.get<mio::abm::SymptomsPerInfectedNoSymptoms>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] =
0.70;
params.get<mio::abm::SymptomsPerInfectedNoSymptoms>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] =
0.83;
params.get<mio::abm::SymptomsPerInfectedNoSymptoms>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.90;
params.get<mio::abm::SeverePerInfectedSymptoms>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.02;
params.get<mio::abm::SeverePerInfectedSymptoms>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.03;
params.get<mio::abm::SeverePerInfectedSymptoms>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.04;
params.get<mio::abm::SeverePerInfectedSymptoms>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.07;
params.get<mio::abm::SeverePerInfectedSymptoms>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.17;
params.get<mio::abm::SeverePerInfectedSymptoms>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.24;
params.get<mio::abm::CriticalPerInfectedSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.1;
params.get<mio::abm::CriticalPerInfectedSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.11;
params.get<mio::abm::CriticalPerInfectedSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.12;
params.get<mio::abm::CriticalPerInfectedSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.14;
params.get<mio::abm::CriticalPerInfectedSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.33;
params.get<mio::abm::CriticalPerInfectedSevere>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.62;
params.get<mio::abm::DeathsPerInfectedCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_0_to_4}] = 0.12;
params.get<mio::abm::DeathsPerInfectedCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_5_to_14}] = 0.13;
params.get<mio::abm::DeathsPerInfectedCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_15_to_34}] = 0.15;
params.get<mio::abm::DeathsPerInfectedCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_35_to_59}] = 0.26;
params.get<mio::abm::DeathsPerInfectedCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_60_to_79}] = 0.40;
params.get<mio::abm::DeathsPerInfectedCritical>()[{mio::abm::VirusVariant::Wildtype, age_group_80_plus}] = 0.48;
// Set infection parameters
params.get<mio::abm::InfectionRateFromViralShed>()[{mio::abm::VirusVariant::Wildtype}] = 5.0;
params.get<mio::abm::AerosolTransmissionRates>() = 0.0;
}
void set_local_parameters(mio::abm::Model& world)
{
const int n_age_groups = (int)world.parameters.get_num_groups();
// setting this up in matrix-form would be much nicer,
// but we somehow can't construct Eigen object with initializer lists
/* baseline_home
0.4413 0.4504 1.2383 0.8033 0.0494 0.0017
0.0485 0.7616 0.6532 1.1614 0.0256 0.0013
0.1800 0.1795 0.8806 0.6413 0.0429 0.0032
0.0495 0.2639 0.5189 0.8277 0.0679 0.0014
0.0087 0.0394 0.1417 0.3834 0.7064 0.0447
0.0292 0.0648 0.1248 0.4179 0.3497 0.1544
*/
Eigen::MatrixXd contacts_home(n_age_groups, n_age_groups);
contacts_home << 0.4413, 0.0504, 1.2383, 0.8033, 0.0494, 0.0017, 0.0485, 0.7616, 0.6532, 1.1614, 0.0256, 0.0013,
0.1800, 0.1795, 0.8806, 0.6413, 0.0429, 0.0032, 0.0495, 0.2639, 0.5189, 0.8277, 0.0679, 0.0014, 0.0087, 0.0394,
0.1417, 0.3834, 0.7064, 0.0447, 0.0292, 0.0648, 0.1248, 0.4179, 0.3497, 0.1544;
/* baseline_school
1.1165 0.2741 0.2235 0.1028 0.0007 0.0000
0.1627 1.9412 0.2431 0.1780 0.0130 0.0000
0.0148 0.1646 1.1266 0.0923 0.0074 0.0000
0.0367 0.1843 0.3265 0.0502 0.0021 0.0005
0.0004 0.0370 0.0115 0.0014 0.0039 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
*/
Eigen::MatrixXd contacts_school(n_age_groups, n_age_groups);
contacts_school << 1.1165, 0.2741, 0.2235, 0.1028, 0.0007, 0.0000, 0.1627, 1.9412, 0.2431, 0.1780, 0.0130, 0.0000,
0.0148, 0.1646, 1.1266, 0.0923, 0.0074, 0.0000, 0.0367, 0.1843, 0.3265, 0.0502, 0.0021, 0.0005, 0.0004, 0.0370,
0.0115, 0.0014, 0.0039, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000;
/* baseline_work
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 0.0127 1.7570 1.6050 0.0133 0.0000
0.0000 0.0020 1.0311 2.3166 0.0098 0.0000
0.0000 0.0002 0.0194 0.0325 0.0003 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
*/
Eigen::MatrixXd contacts_work(n_age_groups, n_age_groups);
contacts_work << 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.0127, 1.7570, 1.6050, 0.0133, 0.0000, 0.0000, 0.0020, 1.0311, 2.3166, 0.0098, 0.0000, 0.0000, 0.0002,
0.0194, 0.0325, 0.0003, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000;
/* baseline_other
0.5170 0.3997 0.7957 0.9958 0.3239 0.0428
0.0632 0.9121 0.3254 0.4731 0.2355 0.0148
0.0336 0.1604 1.7529 0.8622 0.1440 0.0077
0.0204 0.1444 0.5738 1.2127 0.3433 0.0178
0.0371 0.0393 0.4171 0.9666 0.7495 0.0257
0.0791 0.0800 0.3480 0.5588 0.2769 0.0180
*/
Eigen::MatrixXd contacts_other(n_age_groups, n_age_groups);
contacts_other << 0.5170, 0.3997, 0.7957, 0.9958, 0.3239, 0.0428, 0.0632, 0.9121, 0.3254, 0.4731, 0.2355, 0.0148,
0.0336, 0.1604, 1.7529, 0.8622, 0.1440, 0.0077, 0.0204, 0.1444, 0.5738, 1.2127, 0.3433, 0.0178, 0.0371, 0.0393,
0.4171, 0.9666, 0.7495, 0.0257, 0.0791, 0.0800, 0.3480, 0.5588, 0.2769, 0.0180;
Eigen::MatrixXd contacts_random = Eigen::MatrixXd::Ones(n_age_groups, n_age_groups);
for (auto& loc : world.get_locations()) {
switch (loc.get_type()) {
{
case mio::abm::LocationType::Home:
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() = contacts_home;
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() *=
1.4; //17 hours //intensity
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() *= 15.0; // Intensity
break;
case mio::abm::LocationType::School:
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() = contacts_school;
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() *= 4.8; //5h
break;
case mio::abm::LocationType::Work:
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() = contacts_work;
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() *= 3.0 * 0.5; // 7h
break;
case mio::abm::LocationType::SocialEvent:
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() = contacts_other;
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() *= 1.2; //aufteilung
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() *= 2.0; // intensity
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() *= 6.0; // 4 hours
break;
case mio::abm::LocationType::BasicsShop:
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() = contacts_other;
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() *= 0.8; //aufteilung
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() *= 0.33; // intensity
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() *= 12.0; // 2 hours
break;
default:
loc.get_infection_parameters().get<mio::abm::ContactRates>().get_baseline() = contacts_random;
break;
}
}
}
}