Stride Reference Manual  1.0
Cluster.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This is free software: you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * any later version.
7  * The software is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License
12  * along with the software. If not, see <http://www.gnu.org/licenses/>.
13  *
14  * Copyright 2017, Willem L, Kuylen E, Stijven S & Broeckhove J
15  */
16 
22 #include "core/ClusterType.h"
23 #include "core/ContactProfile.h"
24 #include "core/LogMode.h"
25 #include "pop/Person.h"
26 #include "pop/PopulationBuilder.h"
27 #include "sim/Simulator.h"
28 #include "util/GeoCoordinate.h"
30 
31 #include <array>
32 #include <cstddef>
33 #include <vector>
34 
35 namespace stride {
36 
37 using namespace util;
38 
39 class RngHandler;
40 
41 class Calendar;
42 
46 class Cluster {
47 public:
49  Cluster(std::size_t cluster_id, ClusterType cluster_type, GeoCoordinate coordinate = GeoCoordinate(0, 0));
50 
52  void addPerson(Simulator::PersonType* p);
53 
55  void removePerson(unsigned int id);
56 
58  std::size_t getSize() const { return m_members.size(); }
59 
61  std::size_t getActiveClusterMembers() const;
62 
64  std::size_t getInfectedCount() const;
65 
67  ClusterType getClusterType() const { return m_cluster_type; }
68 
70  GeoCoordinate getLocation() const { return m_coordinate; }
71 
73  double getContactRate(const Simulator::PersonType* p) const {
74  return g_profiles.at(toSizeType(m_cluster_type))[effectiveAge(p->getAge())] / m_members.size();;
75  }
76 
78  std::size_t getId() const { return m_cluster_id; }
79 
82  const std::vector<std::pair<Simulator::PersonType*, bool>>& getMembers() const { return m_members; }
83 
84 public:
86  static void addContactProfile(ClusterType cluster_type, const ContactProfile& profile);
87 
88 private:
90  std::tuple<bool, size_t> sortMembers();
91 
93  template<LogMode log_level, bool track_index_case, typename local_information_policy>
94  friend
95  class Infector;
96 
98  void updateMemberPresence();
99 
100 private:
101  std::size_t m_cluster_id;
102  ClusterType m_cluster_type;
103  std::size_t m_index_immune;
104  std::vector<std::pair<Simulator::PersonType*, bool>> m_members;
105  const ContactProfile& m_profile;
106  const GeoCoordinate m_coordinate;
107 private:
108  static std::array<ContactProfile, numOfClusterTypes()> g_profiles;
109 
110 private:
111  friend class Hdf5Loader;
113  friend class Hdf5Saver;
114 };
115 
116 }
GeoCoordinate getLocation() const
Return the geo coordinates (latitude-longitude) of the cluster.
Definition: Cluster.h:70
double getContactRate(const Simulator::PersonType *p) const
Get basic contact rate in this cluster.
Definition: Cluster.h:73
double getAge() const
Get the age.
Definition: Person.h:70
ClusterType getClusterType() const
Return the type of this cluster.
Definition: Cluster.h:67
Time Dependent Person DataType.
Definition: NoBehaviour.h:17
std::size_t toSizeType(ClusterType c)
Cast for array access.
Definition: ClusterType.h:36
Header file for the Person class.
std::size_t getSize() const
Return number of persons in this cluster.
Definition: Cluster.h:58
Header for the Simulator class.
Header file for the Loader class for the checkpointing functionality.
Forward declaration of class Person.
Definition: ThresholdData.h:15
const std::vector< std::pair< Simulator::PersonType *, bool > > & getMembers() const
Get the members of this vector Rather for testing purposes.
Definition: Cluster.h:82
Actual contacts and transmission in cluster (primary template).
Definition: Infector.h:42
Definition of ClusterType.
std::size_t getId() const
Get the ID of this cluster.
Definition: Cluster.h:78
Header for the LogMode class.
Represents a location for social contacts, an group of people.
Definition: Cluster.h:46
unsigned int effectiveAge(unsigned int age)
Effective age (topping of at maximum).
Definition: Age.h:33
ClusterType
Enumerates the cluster types.
Definition: ClusterType.h:28
Initialize populations.
Contact profile.