Stride Reference Manual  - generated for commit 9643b11
HouseholdPopulator.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 "geopop/GeoGrid.h"
19 #include "geopop/GeoGridConfig.h"
20 #include "geopop/Location.h"
21 #include "pop/Population.h"
22 
23 namespace geopop {
24 
25 using namespace std;
26 using namespace stride::ContactType;
27 
28 template<>
30 {
31  m_logger->trace("Starting to populate Households");
32 
33  auto person_id = 0U;
34  auto hh_dist = m_rn_man.GetUniformIntGenerator(0, static_cast<int>(geoGridConfig.refHH.ages.size()), 0U);
35  auto pop = geoGrid.GetPopulation();
36 
37  for (const shared_ptr<Location>& loc : geoGrid) {
38  for (auto& pool : loc->RefPools(Id::Household)) {
39  const auto hDraw = static_cast<unsigned int>(hh_dist());
40  for (const auto& age : geoGridConfig.refHH.ages[hDraw]) {
41  const auto p = pop->CreatePerson(person_id++, age, pool->GetId(), 0, 0, 0, 0, 0);
42  pool->AddMember(p);
43  }
44  }
45  }
46 
47  m_logger->trace("Done populating Households");
48 }
49 
50 } // namespace geopop
stride::Population * GetPopulation() const
Get the Population associated with this GeoGrid.
Definition: GeoGrid.h:63
Configuration data mostly for generating a population, but also for computing the required number of ...
Definition: GeoGridConfig.h:35
struct geopop::GeoGridConfig::@1 refHH
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
Person * CreatePerson(unsigned int id, double age, unsigned int householdId, unsigned int k12SchoolId, unsigned int collegeId, unsigned int workId, unsigned int primaryCommunityId, unsigned int secondaryCommunityId)
Create Person in the population.
Definition: Population.cpp:108
std::vector< std::vector< unsigned int > > ages
Age profile per reference household.
Definition: GeoGridConfig.h:85
Header file for the core Population class.
Namespace to manage types of ContactPool.
Definition: ContactType.cpp:28