Stride Reference Manual  - generated for commit 9643b11
AgeContactProfile.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 2017, Kuylen E, Willem L, Broeckhove J
14  */
15 
21 #include "AgeContactProfile.h"
22 
23 #include <boost/property_tree/ptree.hpp>
24 
25 namespace stride {
26 
27 using namespace std;
28 using namespace stride::ContactType;
29 using namespace boost::property_tree;
30 
31 AgeContactProfile::AgeContactProfile(Id poolType, const ptree& contactPt) : std::array<double, MaximumAge() + 1>()
32 {
33  string typeKey = ContactType::ToString(poolType);
34  // TODO ELiminate this hack by fixing the data file
35  if (poolType == Id::K12School || poolType == Id::College) {
36  typeKey = "school";
37  } else if (poolType == Id::Household) {
38  typeKey = "household";
39  } else if (poolType == Id::Workplace) {
40  typeKey = "work";
41  } else if (poolType == Id::PrimaryCommunity) {
42  typeKey = "primary_community";
43  } else if (poolType == Id::SecondaryCommunity) {
44  typeKey = "secondary_community";
45  }
46  const string key{string("matrices.").append(typeKey)};
47  unsigned int i = 0U;
48  for (const auto& participant : contactPt.get_child(key)) {
49  double totalContacts = 0;
50  for (const auto& contact : participant.second.get_child("contacts")) {
51  totalContacts += contact.second.get<double>("rate");
52  }
53  (*this)[i++] = totalContacts;
54  }
55 }
56 
57 } // namespace stride
Id
Enumerates the ContactPool types.
Definition: ContactType.h:34
Contact profile.
STL namespace.
constexpr unsigned int MaximumAge()
Maximum age for Persons.
Definition: Age.h:26
AgeContactProfile()=default
Need to keep the default constructor available.
string ToString(Id c)
Converts a ContactPoolType::Id value to corresponding name.
Definition: ContactType.cpp:63
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28
Namespace to manage types of ContactPool.
Definition: ContactType.cpp:28