Stride Reference Manual  - generated for commit 9643b11
PrimaryCommunityPopulator.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/ContactPool.h"
19 #include "geopop/GeoGrid.h"
20 #include "geopop/Location.h"
21 #include "pop/Person.h"
22 
23 using namespace std;
24 using namespace stride::ContactType;
25 
26 namespace geopop {
27 
28 template<>
30 {
31  m_logger->trace("Starting to populate Primary Communities");
32 
33  for (const shared_ptr<Location>& loc : geoGrid) {
34  if (loc->GetPopCount() == 0) {
35  continue;
36  }
37 
38  // 1. find all communities in an area of 10-k*10 km
39  const auto nearbyPools = geoGrid.GetNearbyPools(Id::PrimaryCommunity, *loc);
40 
41  if (nearbyPools.empty()) { // apparently no commumity pools present, so nothing to populate
42  return;
43  }
44 
45  // 2. for every household assign a community
46  const auto dist = m_rn_man.GetUniformIntGenerator(0, static_cast<int>(nearbyPools.size()), 0U);
47  for (auto& hhPool : loc->RefPools(Id::Household)) {
48  for (auto p : *hhPool) {
49  auto& pcPool = nearbyPools[dist()];
50  pcPool->AddMember(p);
51  p->SetPoolId(Id::PrimaryCommunity, pcPool->GetId());
52  }
53  }
54  }
55 
56  m_logger->trace("Done populating Primary Communities");
57 }
58 
59 } // 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
Populator uses geo & pop data to populate ContactPools in the GeoGrid.
Definition: Populator.h:36
Namespace to manage types of ContactPool.
Definition: ContactType.cpp:28