Stride Reference Manual  1.0
ThresholdData.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 /*
6  * Possible variants:
7  * + fraction adopted over entire simulation
8  * + with awareness
9  * + with history
10  * + and off course all combinations
11  */
12 namespace stride {
13 
14 template<typename BehaviourPolicy, typename BeliefPolicy>
15 class Person;
16 
17 template<bool threshold_infected, bool threshold_adopted>
18 class Threshold;
19 
21 public:
26 
27  void setThresholdInfected(double threshold) {
28  m_threshold_infected = threshold;
29  }
30 
31  double getThresholdInfected() const {
32  return m_threshold_infected;
33  }
34 
35  void setThresholdAdopted(double threshold) {
36  m_threshold_adopted = threshold;
37  }
38 
39  double getThresholdAdopted() const {
40  return m_threshold_adopted;
41  }
42 
43  double getFractionInfected() const {
44  if (m_num_contacts == 0) {
45  return 0;
46  }
47  return (double) m_num_contacts_infected / m_num_contacts;
48  }
49 
50  double getFractionAdopted() const {
51  if (m_num_contacts == 0) {
52  return 0;
53  }
54  return (double) m_num_contacts_adopted / m_num_contacts;
55  }
56 
57  template<typename BehaviourPolicy, typename BeliefPolicy>
59 
60 private:
61  unsigned int m_num_contacts;
62  unsigned int m_num_contacts_infected;
63  unsigned int m_num_contacts_adopted;
64 
67 
68 };
69 
70 extern template void ThresholdData::contact<Vaccination<Threshold<true, false>>, Threshold<true, false>>(
72 
73 extern template void ThresholdData::contact<Vaccination<Threshold<true, false>>, Threshold<false, true>>(
74  const Person<Vaccination<Threshold<true, false>>, Threshold<false, true>>* p);
75 
76 extern template void ThresholdData::contact<Vaccination<Threshold<true, false>>, Threshold<true, true>>(
77  const Person<Vaccination<Threshold<true, false>>, Threshold<true, true>>* p);
78 
79 
80 }
void setThresholdAdopted(double threshold)
Definition: ThresholdData.h:35
unsigned int m_num_contacts
Definition: ThresholdData.h:61
unsigned int m_num_contacts_adopted
Definition: ThresholdData.h:63
Time Dependent Person DataType.
Definition: NoBehaviour.h:17
double m_threshold_adopted
Fraction of contacts that needs to have adopted the belief for person to also adopt.
Definition: ThresholdData.h:66
ThresholdData()
Default constructor.
Definition: ThresholdData.h:23
Forward declaration of class Person.
Definition: ThresholdData.h:15
double getThresholdInfected() const
Definition: ThresholdData.h:31
void setThresholdInfected(double threshold)
Definition: ThresholdData.h:27
unsigned int m_num_contacts_infected
Definition: ThresholdData.h:62
void contact(const Person< BehaviourPolicy, BeliefPolicy > *p)
double m_threshold_infected
Fraction of contacts that needs to be infected before person adopts belief.
Definition: ThresholdData.h:65
double getFractionInfected() const
Definition: ThresholdData.h:43
double getThresholdAdopted() const
Definition: ThresholdData.h:39
double getFractionAdopted() const
Definition: ThresholdData.h:50