Simpact Cyan
Population based event driven simulation using mNRM
hazardfunctionexp.h
Go to the documentation of this file.
1 #ifndef HAZARDFUNCTIONEXP_H
2 
3 #define HAZARDFUNCTIONEXP_H
4 
9 #include "hazardfunction.h"
10 #include <cmath>
11 
16 {
17 public:
19  HazardFunctionExp(double A = 0, double B = 0) : m_A(A), m_B(B) { }
20  ~HazardFunctionExp() { }
21 
22  double evaluate(double t);
23  double calculateInternalTimeInterval(double t0, double dt);
24  double solveForRealTimeInterval(double t0, double Tdiff);
25 protected:
26  void setAB(double A, double B) { m_A = A; m_B = B; }
27 private:
28  double m_A, m_B;
29 };
30 
31 inline double HazardFunctionExp::evaluate(double t)
32 {
33  return std::exp(m_A + m_B * t);
34 }
35 
36 inline double HazardFunctionExp::calculateInternalTimeInterval(double t0, double dt)
37 {
38  if (m_B == 0)
39  return dt*std::exp(m_A);
40 
41  return (std::exp(m_A + m_B*t0)/m_B)*(std::exp(m_B * dt) - 1.0);
42 }
43 
44 inline double HazardFunctionExp::solveForRealTimeInterval(double t0, double Tdiff)
45 {
46  if (m_B == 0)
47  return Tdiff/std::exp(m_A);
48 
49  return (1.0/m_B)*std::log((m_B*Tdiff)/std::exp(m_A + m_B*t0) + 1.0);
50 }
51 
52 #endif // HAZARDFUNCTIONEXP_H
Abstract base class which can be used for a hazard.
Definition: hazardfunction.h:18
double solveForRealTimeInterval(double t0, double Tdiff)
For the specified internal time interval Tdiff, calculate the corresponding real-world time interval...
Definition: hazardfunctionexp.h:44
HazardFunctionExp(double A=0, double B=0)
Constructor which specifies the parameters in exp(A+Bt).
Definition: hazardfunctionexp.h:19
double evaluate(double t)
Evaluate the hazard at time t.
Definition: hazardfunctionexp.h:31
double calculateInternalTimeInterval(double t0, double dt)
Map the real-world time dt to an internal time interval.
Definition: hazardfunctionexp.h:36
Helper class for time dependent exponential hazards.
Definition: hazardfunctionexp.h:15