Stride Reference Manual  - generated for commit 9643b11
PublicHealthAgency.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 2018, Willem L, Kuylen E, Broeckhove J
14  */
15 
21 #include "PublicHealthAgency.h"
22 
23 #include "pop/Population.h"
24 #include "util/RnMan.h"
25 
26 #include <numeric>
27 #include <vector>
28 
29 namespace stride {
30 
31 using namespace std;
32 using namespace util;
33 
34 void PublicHealthAgency::Exec(std::shared_ptr<Population> pop, util::RnMan& rnManager, unsigned short int simDay)
35 {
36  PerformCaseFinding(std::move(pop), rnManager, simDay);
37 }
38 
39 void PublicHealthAgency::Initialize(double detection_probability) { m_detection_probability = detection_probability; }
40 
41 void PublicHealthAgency::PerformCaseFinding(std::shared_ptr<Population> pop, util::RnMan& rnMan,
42  unsigned short int simDay)
43 {
44  // perform case finding, only if the probability is > 0.0
45  if (m_detection_probability <= 0.0) {
46  return;
47  }
48 
49  using namespace ContactType;
50  auto uniform01Gen = rnMan.GetUniform01Generator(0U);
51  auto& logger = pop->RefContactLogger();
52 
54  std::initializer_list<Id> AgencyPoolIdList{Id::Household};
55 
56  for (auto& p_case : *pop) {
57  if (p_case.GetHealth().IsSymptomatic() && p_case.GetHealth().SymptomsStartedToday()) {
58  for (Id typ : AgencyPoolIdList) {
59 
60  const auto& pools = pop->CRefPoolSys().CRefPools(typ);
61  const auto poolId = p_case.GetPoolId(typ);
62  if (poolId == 0) {
63  continue;
64  }
65 
66  for (const auto& p_member : pools[poolId].GetPool()) {
67  if (p_case != *p_member && p_member->GetHealth().IsSusceptible() &&
68  uniform01Gen() < m_detection_probability) {
69 
70  // set immune
71  p_member->GetHealth().SetImmune();
72 
73  // TODO: check log_level
74  logger->info("[VACC] {} {} {} {} {} {} {}", p_member->GetId(),
75  p_member->GetAge(), ToString(typ), poolId, p_case.GetId(),
76  p_case.GetAge(), simDay);
77  }
78  }
79  }
80  }
81  }
82 }
83 
84 } // namespace stride
string ToString(Id l)
Converts a LogMode value to corresponding name.
void PerformCaseFinding(std::shared_ptr< Population > pop, util::RnMan &rnMan, unsigned short int simDay)
Public Health Strategy: look for symptomatic cases and vaccinate their household. ...
void Exec(std::shared_ptr< Population > pop, util::RnMan &rnManager, unsigned short int sim_day)
Execute.
STL namespace.
Interface of RnMan.
void Initialize(double detection_probability)
Initialize.
std::function< double()> GetUniform01Generator(unsigned int i=0U)
Return a generator for uniform doubles in [0, 1[ using i-th random stream.
Definition: RnMan.cpp:72
Header file for the core Population class.
Header for the PublicHealthAgency class.
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28