@@ -50,26 +50,39 @@ void write_results_to_file(const mio::abm::Simulation& sim)
5050
5151int main ()
5252{
53- // Set global infection parameters (similar to infection parameters in SECIR model) and initialize the world
54- mio::abm::GlobalInfectionParameters infection_params;
53+ // This is a minimal example with children and adults < 60 year old.
54+ // We divided them into 3 different age groups, which are defined as follows:
55+ size_t NUM_AGE_GROUPS = 4 ;
56+ const auto AGE_GROUP_0_TO_4 = mio::AgeGroup (NUM_AGE_GROUPS - 4 );
57+ const auto AGE_GROUP_5_TO_14 = mio::AgeGroup (NUM_AGE_GROUPS - 3 );
58+ const auto AGE_GROUP_15_TO_34 = mio::AgeGroup (NUM_AGE_GROUPS - 2 );
59+ const auto AGE_GROUP_35_TO_59 = mio::AgeGroup (NUM_AGE_GROUPS - 1 );
60+
61+ // Create the world with 3 age groups.
62+ auto world = mio::abm::World (NUM_AGE_GROUPS);
5563
5664 // Set same infection parameter for all age groups. For example, the incubation period is 4 days.
57- infection_params.get <mio::abm::IncubationPeriod>() = 4 .;
65+ world.parameters .get <mio::abm::IncubationPeriod>() = 4 .;
66+
67+ // Set the age group the can go to school is AgeGroup(1) (i.e. 5-14)
68+ world.parameters .get <mio::abm::AgeGroupGotoSchool>() = {AGE_GROUP_5_TO_14};
69+ // Set the age group the can go to work is AgeGroup(2) and AgeGroup(3) (i.e. 15-34 and 35-59)
70+ world.parameters .get <mio::abm::AgeGroupGotoWork>() = {AGE_GROUP_15_TO_34, AGE_GROUP_35_TO_59};
5871
59- // Create the world with infection parameters .
60- auto world = mio::abm::World (infection_params );
72+ // Check if the parameters satisfy their contraints .
73+ world. parameters . check_constraints ( );
6174
6275 // There are 3 households for each household group.
6376 int n_households = 3 ;
6477
6578 // For more than 1 family households we need families. These are parents and children and randoms (which are distributed like the data we have for these households).
66- auto child = mio::abm::HouseholdMember (); // A child is 50/50% 0-4 or 5-14.
67- child.set_age_weight (mio::abm::AgeGroup::Age0to4 , 1 );
68- child.set_age_weight (mio::abm::AgeGroup::Age5to14 , 1 );
79+ auto child = mio::abm::HouseholdMember (NUM_AGE_GROUPS ); // A child is 50/50% 0-4 or 5-14.
80+ child.set_age_weight (AGE_GROUP_0_TO_4 , 1 );
81+ child.set_age_weight (AGE_GROUP_0_TO_4 , 1 );
6982
70- auto parent = mio::abm::HouseholdMember (); // A parent is 50/50% 15-34 or 35-59.
71- parent.set_age_weight (mio::abm::AgeGroup::Age15to34 , 1 );
72- parent.set_age_weight (mio::abm::AgeGroup::Age35to59 , 1 );
83+ auto parent = mio::abm::HouseholdMember (NUM_AGE_GROUPS ); // A parent is 50/50% 15-34 or 35-59.
84+ parent.set_age_weight (AGE_GROUP_15_TO_34 , 1 );
85+ parent.set_age_weight (AGE_GROUP_35_TO_59 , 1 );
7386
7487 // Two-person household with one parent and one child.
7588 auto twoPersonHousehold_group = mio::abm::HouseholdGroup ();
@@ -128,8 +141,7 @@ int main()
128141 auto rng = mio::abm::Person::RandomNumberGenerator (world.get_rng (), person);
129142 if (infection_state != mio::abm::InfectionState::Susceptible) {
130143 person.add_new_infection (mio::abm::Infection (rng, mio::abm::VirusVariant::Wildtype, person.get_age (),
131- world.get_global_infection_parameters (), start_date,
132- infection_state));
144+ world.parameters , start_date, infection_state));
133145 }
134146 }
135147
@@ -142,17 +154,17 @@ int main()
142154 person.set_assigned_location (hospital);
143155 person.set_assigned_location (icu);
144156 // assign work/school to people depending on their age
145- if (person.get_age () == mio::abm::AgeGroup::Age5to14 ) {
157+ if (person.get_age () == AGE_GROUP_0_TO_4 ) {
146158 person.set_assigned_location (school);
147159 }
148- if (person.get_age () == mio::abm::AgeGroup::Age15to34 || person.get_age () == mio::abm::AgeGroup::Age35to59 ) {
160+ if (person.get_age () == AGE_GROUP_15_TO_34 || person.get_age () == AGE_GROUP_35_TO_59 ) {
149161 person.set_assigned_location (work);
150162 }
151163 }
152164
153165 // During the lockdown, social events are closed for 90% of people.
154166 auto t_lockdown = mio::abm::TimePoint (0 ) + mio::abm::days (10 );
155- mio::abm::close_social_events (t_lockdown, 0.9 , world.get_migration_parameters () );
167+ mio::abm::close_social_events (t_lockdown, 0.9 , world.parameters );
156168
157169 auto t0 = mio::abm::TimePoint (0 );
158170 auto tmax = mio::abm::TimePoint (0 ) + mio::abm::days (30 );
0 commit comments