Stride Reference Manual  - generated for commit 9643b11
HouseholdGenerator.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 "Generator.h"
17 
18 namespace geopop {
19 
20 using namespace std;
21 using namespace stride;
22 using namespace stride::ContactType;
23 
24 template<>
26 {
27  vector<double> weights;
28  for (const auto& loc : geoGrid) {
29  weights.push_back(loc->GetPopFraction());
30  }
31 
32  if (weights.empty()) {
33  // trng can't handle empty vectors
34  return;
35  }
36 
37  const auto dist = m_rn_man.GetDiscreteGenerator(weights, 0U);
38  auto pop = geoGrid.GetPopulation();
39 
40  for (auto i = 0U; i < ggConfig.info.count_households; i++) {
41  const auto loc = geoGrid[dist()];
42  AddPools(*loc, pop, ggConfig);
43  }
44 }
45 
46 } // namespace geopop
struct geopop::GeoGridConfig::@2 info
Configuration data mostly for generating a population, but also for computing the required number of ...
Definition: GeoGridConfig.h:35
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 &)
Generate ContactPools for ContactType::Id as sepcified by data in GeoGridConfig.
Definition: Generator.h:52
unsigned int count_households
The number of households.
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28
Namespace to manage types of ContactPool.
Definition: ContactType.cpp:28