Stride Reference Manual  - generated for commit 9643b11
TransmissionProfile.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, Kuylen E, Willem L, Broeckhove J
14  */
15 
21 #include "TransmissionProfile.h"
22 
23 #include <cmath>
24 
25 namespace stride {
26 
27 using namespace std;
28 using namespace boost::property_tree;
29 
30 
31 void TransmissionProfile::Initialize(const ptree& configPt, const ptree& diseasePt)
32 {
33  boost::optional<double> r0 = configPt.get_optional<double>("run.r0");
34  if (r0) {
35  // Use a quadratic model, fitted to simulation data:
36  // Expected(R0) = (0 + b1*transm_probability + b2*transm_probability^2).
37  const auto b0 = diseasePt.get<double>("disease.transmission.b0");
38  const auto b1 = diseasePt.get<double>("disease.transmission.b1");
39  const auto b2 = diseasePt.get<double>("disease.transmission.b2");
40 
41  // Find root
42  const auto a = b2;
43  const auto b = b1;
44  const auto c = b0 - *r0;
45 
46  // To obtain a real values (instead of complex)
47  if (*r0 < (-(b * b) / (4 * a))) {
48  const double determ = (b * b) - 4 * a * c;
49  double transmission_rate = (-b + sqrt(determ)) / (2 * a);
50  m_transmission_probability = 1.0 - std::exp(-transmission_rate);
51  } else {
52  throw runtime_error("TransmissionProfile::Initialize> Illegal input values.");
53  }
54 
55  } else {
56  // Use transmission probability parameter
57  m_transmission_probability = configPt.get<double>("run.transmission_probability");
58  }
59 }
60 
61 } // namespace stride
Header for the TransmissionProfile class.
STL namespace.
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28
void Initialize(const boost::property_tree::ptree &configPt, const boost::property_tree::ptree &diseasePt)
Initialize.