Skip to content

Commit 0613878

Browse files
committed
fix bug in abm tutorials
1 parent 2271029 commit 0613878

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

cpp-tutorials/abm/tutorial_abm_households.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,10 @@ int main(int argc, char* argv[])
7777
const auto age_group_60_to_79 = mio::AgeGroup(4); // seniors
7878
const auto age_group_80_plus = mio::AgeGroup(5); // elderly
7979

80-
// *** Create the model and set infection parameters. ***
81-
// The Model holds all persons, locations, and parameters. We hand over the
82-
// number of age groups so that all parameter arrays are sized correctly.
83-
// `set_local_parameters` and `set_world_parameters` fill in realistic
84-
// epidemiological values (see parameter_setter.h).
80+
// *** Create the model. ***
81+
// The Model holds all persons, locations, and parameters. We need to add the locations
82+
// before we set the parameters as some parameters depend on the locations.
8583
auto model = mio::abm::Model(num_age_groups);
86-
set_local_parameters(model);
87-
set_world_parameters(model.parameters);
8884

8985
// Define which age groups are eligible to go to school and to work.
9086
// The AgeGroupGotoSchool / AgeGroupGotoWork arrays default to false for
@@ -187,6 +183,12 @@ int main(int argc, char* argv[])
187183
// One workplace for all working adults.
188184
auto work = model.add_location(mio::abm::LocationType::Work);
189185

186+
// *** Set paramters for all locations. ***
187+
// `set_local_parameters` and `set_world_parameters` fill in realistic
188+
// epidemiological values (see parameter_setter.h).
189+
set_local_parameters(model);
190+
set_world_parameters(model.parameters);
191+
190192
// *** Assign initial infection states. ***
191193
// Each person draws a random infection state from the distribution below.
192194
// Persons who are not Susceptible receive a full Infection object so their

cpp-tutorials/abm/tutorial_abm_testing.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ int main(int argc, char* argv[])
117117

118118
// *** Create the model and set infection parameters. ***
119119
auto model = mio::abm::Model(num_age_groups);
120-
set_local_parameters(model);
121-
set_world_parameters(model.parameters);
122120

123121
// Define which age groups are eligible to go to school and to work.
124122
// The AgeGroupGotoSchool / AgeGroupGotoWork arrays default to false for
@@ -218,6 +216,10 @@ int main(int argc, char* argv[])
218216
// One workplace for all working adults.
219217
auto work = model.add_location(mio::abm::LocationType::Work);
220218

219+
// *** Set paramters for all locations (same as Tutorial 1). ***
220+
set_local_parameters(model);
221+
set_world_parameters(model.parameters);
222+
221223
// *** Assign initial infection states. ***
222224
//
223225
// Index | InfectionState | Probability

0 commit comments

Comments
 (0)