Stride Reference Manual  1.0
Person.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, Willem L, Kuylen E, Stijven S & Broeckhove J
14  */
15 
16 
17 #include "Age.h"
18 #include "Person.h"
19 
20 #include "core/ClusterType.h"
21 
22 namespace stride {
23 
24 using namespace std;
25 
26 template<class BehaviourPolicy, class BeliefPolicy>
28  switch (cluster_type) {
30  return m_household_id;
32  return m_school_id;
33  case ClusterType::Work:
34  return m_work_id;
36  return m_primary_community_id;
38  return m_secondary_community_id;
39  default:
40  throw runtime_error(string(__func__) + "> Should not reach default.");
41  }
42 }
43 
44 template<class BehaviourPolicy, class BeliefPolicy>
46  switch (c) {
48  return m_at_household && !m_is_on_vacation;
50  return m_at_school && !m_is_on_vacation;
51  case ClusterType::Work:
52  return m_at_work && !m_is_on_vacation;
54  return m_at_primary_community && !m_is_on_vacation;
56  return m_at_secondary_community && !m_is_on_vacation;
57  default:
58  throw runtime_error(string(__func__) + "> Should not reach default.");
59  }
60 }
61 
62 template<class BehaviourPolicy, class BeliefPolicy>
63 void Person<BehaviourPolicy, BeliefPolicy>::update(bool is_work_off, bool is_school_off, double fraction_infected) {
64  m_health.update();
65 
66  // Vaccination behavior
67  // As long as people are susceptible to a disease
68  // (or think they are: they have been infected but are not yet symptomatic) they can choose to get vaccinated
69  if (m_health.isSusceptible() || (m_health.isInfected() && (!m_health.isSymptomatic()))) {
70  if (BehaviourPolicy::practicesVaccination(m_belief_data)) {
71  m_health.setImmune();
72  }
73  }
74 
75  // Update presence in clusters.
76  if (is_work_off || (m_age <= minAdultAge() && is_school_off)) {
77  m_at_school = false;
78  m_at_work = false;
79  m_at_secondary_community = false;
80  m_at_primary_community = true;
81  } else {
82  m_at_school = true;
83  m_at_work = true;
84  m_at_secondary_community = true;
85  m_at_primary_community = false;
86  }
87 
88  BeliefPolicy::update(m_belief_data, m_health);
89 }
90 
91 template<class BehaviourPolicy, class BeliefPolicy>
93  //BeliefPolicy::update(m_belief_data, p->getBeliefData(), p->getHealth());
94  BeliefPolicy::update(m_belief_data, p);
95 }
96 
97 //--------------------------------------------------------------------------
98 // All explicit instantiations.
99 //--------------------------------------------------------------------------
100 template
102 
103 template
105 
106 template
108 
109 template
111 
112 }
Time Dependent Person DataType.
Definition: NoBehaviour.h:17
Header file for the Person class.
Forward declaration of class Person.
Definition: ThresholdData.h:15
Helpers for age.
Definition of ClusterType.
STL namespace.
unsigned int getClusterId(ClusterType cluster_type) const
Get cluster ID of cluster_type.
Definition: Person.cpp:27
bool isInCluster(ClusterType c) const
Check if a person is present today in a given cluster.
Definition: Person.cpp:45
ClusterType
Enumerates the cluster types.
Definition: ClusterType.h:28
constexpr unsigned int minAdultAge()
Maximum age for Person&#39;s.
Definition: Age.h:30
void update(bool is_work_off, bool is_school_off, double fraction_infected)
Update the health status and presence in clusters.
Definition: Person.cpp:63