Stride Reference Manual  - generated for commit 9643b11
K12SchoolPopulator.cpp
Go to the documentation of this file.
1 /*
2  * This is free software: you can redistribute it and/or modify it
3  * under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * any later version.
6  * The software is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  * You should have received a copy of the GNU General Public License
11  * along with the software. If not, see <http://www.gnu.org/licenses/>.
12  *
13  * Copyright 2018, 2019, Jan Broeckhove and Bistromatics group.
14  */
15 
16 #include "Populator.h"
17 
18 #include "contact/AgeBrackets.h"
19 #include "contact/ContactPool.h"
20 #include "geopop/GeoGrid.h"
21 #include "geopop/Location.h"
22 #include "pop/Person.h"
23 
24 namespace geopop {
25 
26 using namespace std;
27 using namespace stride;
28 using namespace stride::ContactType;
29 
30 template<>
32 {
33  m_logger->trace("Starting to populate Schools");
34 
35  for (const auto& loc : geoGrid) {
36  if (loc->GetPopCount() == 0) {
37  continue;
38  }
39 
40  // 1. find all schools in an area of 10-k*10 km
41  const vector<ContactPool*>& classes = geoGrid.GetNearbyPools(Id::K12School, *loc);
42 
43  auto dist = m_rn_man.GetUniformIntGenerator(0, static_cast<int>(classes.size()), 0U);
44 
45  // 2. for every student assign a class
46  for (auto& pool : loc->RefPools(Id::Household)) {
47  for (Person* p : *pool) {
48  if (AgeBrackets::K12School::HasAge(p->GetAge())) {
49  auto& c = classes[dist()];
50  c->AddMember(p);
51  p->SetPoolId(Id::K12School, c->GetId());
52  }
53  }
54  }
55  }
56 
57  m_logger->trace("Done populating K12Schools");
58 }
59 
60 } // namespace geopop
Header file for the Person class.
Configuration data mostly for generating a population, but also for computing the required number of ...
Definition: GeoGridConfig.h:35
Header for the core ContactPool class.
STL namespace.
A Geographic grid of simulation region contains Locations that in turn contain an index to the Contac...
Definition: GeoGrid.h:41
Namespace for the geographic and demograhic classes.
Definition: Coordinate.h:21
void Apply(GeoGrid &, const GeoGridConfig &)
Populate the ContactPools type ID. This is a placeholder for the specializations. ...
Definition: Populator.h:51
Store and handle person data.
Definition: Person.h:34
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28
Namespace to manage types of ContactPool.
Definition: ContactType.cpp:28