Stride Reference Manual  1.0
Threshold.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "core/Health.h"
5 
6 namespace stride {
7 
9 template<typename BehaviourPolicy, typename BeliefPolicy>
10 class Person;
11 
12 template<bool threshold_infected, bool threshold_adopted>
13 class Threshold {
14 public:
16 
17  static void initialize(Data& belief_data, double risk_averseness) {
18  if (threshold_infected) {
19  belief_data.setThresholdInfected(1 - risk_averseness);
20  }
21  if (threshold_adopted) {
22  belief_data.setThresholdAdopted(1 - risk_averseness);
23  }
24  }
25 
26  static void update(Data& belief_data, Health& health_data) {}
27 
28  template<typename BehaviourPolicy>
29  static void
30  update(Data& belief_data, const Person<BehaviourPolicy, Threshold<threshold_infected, threshold_adopted>>* p) {
31  belief_data.contact<BehaviourPolicy, Threshold<threshold_infected, threshold_adopted>>(p);
32  }
33 
34  static bool hasAdopted(const Data& belief_data) {
35  if (threshold_infected) {
36  if (belief_data.getFractionInfected() > belief_data.getThresholdInfected()) {
37  return true;
38  }
39  }
40  if (threshold_adopted) {
41  if (belief_data.getFractionAdopted() > belief_data.getThresholdAdopted()) {
42  return true;
43  }
44  }
45 
46  return false;
47  }
48 
49 };
50 
52 extern template
54 
55 extern template
57 
58 extern template
60 
61 }
void setThresholdAdopted(double threshold)
Definition: ThresholdData.h:35
Time Dependent Person DataType.
Definition: NoBehaviour.h:17
static void update(Data &belief_data, Health &health_data)
Definition: Threshold.h:26
Forward declaration of class Person.
Definition: ThresholdData.h:15
double getThresholdInfected() const
Definition: ThresholdData.h:31
void setThresholdInfected(double threshold)
Definition: ThresholdData.h:27
static void update(Data &belief_data, const Person< BehaviourPolicy, Threshold< threshold_infected, threshold_adopted >> *p)
Definition: Threshold.h:30
void contact(const Person< BehaviourPolicy, BeliefPolicy > *p)
static bool hasAdopted(const Data &belief_data)
Definition: Threshold.h:34
double getFractionInfected() const
Definition: ThresholdData.h:43
double getThresholdAdopted() const
Definition: ThresholdData.h:39
double getFractionAdopted() const
Definition: ThresholdData.h:50
static void initialize(Data &belief_data, double risk_averseness)
Definition: Threshold.h:17