Health-GPS  1.2.2.0
Global Health Policy Simulation model (Health-GPS)
energy_balance_hierarchical_model.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "interfaces.h"
4 #include "mapping.h"
5 #include "random_algorithm.h"
6 
7 namespace hgps {
8 
12  std::string name;
13 
15  std::map<core::Identifier, double> coefficients{};
16 
19 };
20 
25 
27  std::map<core::Identifier, FactorDynamicEquation> male{};
28 
30  std::map<core::Identifier, FactorDynamicEquation> female{};
31 };
32 
37  public:
43  const std::map<core::IntegerInterval, AgeGroupGenderEquation> &equations,
44  const std::map<core::Identifier, core::Identifier> &variables,
45  const double boundary_percentage);
46 
47  HierarchicalModelType type() const noexcept override;
48 
49  std::string name() const noexcept override;
50 
53  void generate_risk_factors(RuntimeContext &context) override;
54 
55  void update_risk_factors(RuntimeContext &context) override;
56 
57  private:
58  const std::map<core::IntegerInterval, AgeGroupGenderEquation> &equations_;
59  const std::map<core::Identifier, core::Identifier> &variables_;
60  double boundary_percentage_;
61 
62  const AgeGroupGenderEquation &equations_at(const int &age) const;
63 
64  void update_risk_factors_exposure(
65  RuntimeContext &context, Person &entity,
66  const std::map<core::Identifier, double> &current_risk_factors,
67  const std::map<core::Identifier, FactorDynamicEquation> &equations);
68 
69  std::map<core::Identifier, double> get_current_risk_factors(const HierarchicalMapping &mapping,
70  Person &entity,
71  int time_year) const;
72 
73  double sample_normal_with_boundary(Random &random, double mean, double standard_deviation,
74  double boundary) const;
75 };
76 
79  public:
86  std::map<core::IntegerInterval, AgeGroupGenderEquation> equations,
87  std::map<core::Identifier, core::Identifier> variables,
88  const double boundary_percentage = 0.05);
89 
92  std::unique_ptr<HierarchicalLinearModel> create_model() const override;
93 
94  private:
95  std::map<core::IntegerInterval, AgeGroupGenderEquation> equations_;
96  std::map<core::Identifier, core::Identifier> variables_;
97  double boundary_percentage_;
98 };
99 
100 } // namespace hgps
Implements the dynamic hierarchical linear model (energy balance) type.
Definition: energy_balance_hierarchical_model.h:36
HierarchicalModelType type() const noexcept override
Gets the model type identifier.
Definition: energy_balance_hierarchical_model.cpp:20
void update_risk_factors(RuntimeContext &context) override
Update risk factors for population.
Definition: energy_balance_hierarchical_model.cpp:32
std::string name() const noexcept override
Gets the model name.
Definition: energy_balance_hierarchical_model.cpp:24
void generate_risk_factors(RuntimeContext &context) override
Generates the initial risk factors for a population and newborns.
Definition: energy_balance_hierarchical_model.cpp:26
EnergyBalanceHierarchicalModel(const std::map< core::IntegerInterval, AgeGroupGenderEquation > &equations, const std::map< core::Identifier, core::Identifier > &variables, const double boundary_percentage)
Initialises a new instance of the EnergyBalanceHierarchicalModel class.
Definition: energy_balance_hierarchical_model.cpp:6
Hierarchical linear model interface.
Definition: interfaces.h:137
Defines the hierarchical model mapping data type.
Definition: mapping.h:128
Defines the lite hierarchical linear model data type.
Definition: energy_balance_hierarchical_model.h:78
LiteHierarchicalModelDefinition(std::map< core::IntegerInterval, AgeGroupGenderEquation > equations, std::map< core::Identifier, core::Identifier > variables, const double boundary_percentage=0.05)
Initialises a new instance of the LiteHierarchicalModelDefinition class.
Definition: energy_balance_hierarchical_model.cpp:132
std::unique_ptr< HierarchicalLinearModel > create_model() const override
Construct a new EnergyBalanceHierarchicalModel from this definition.
Definition: energy_balance_hierarchical_model.cpp:147
General purpose Random number generator algorithms.
Definition: random_algorithm.h:8
Risk factor model definition interface.
Definition: interfaces.h:160
Defines the Simulation runtime context data type.
Definition: runtime_context.h:21
Numeric interval representation data type.
Definition: interval.h:10
Top-level namespace for Health-GPS C++ API.
Definition: analysis_definition.h:8
HierarchicalModelType
Health GPS risk factor module types enumeration.
Definition: interfaces.h:29
Define the age group dynamic equations data type.
Definition: energy_balance_hierarchical_model.h:22
std::map< core::Identifier, FactorDynamicEquation > male
The males dynamic equations.
Definition: energy_balance_hierarchical_model.h:27
std::map< core::Identifier, FactorDynamicEquation > female
The females dynamic equations.
Definition: energy_balance_hierarchical_model.h:30
core::IntegerInterval age_group
The reference age group.
Definition: energy_balance_hierarchical_model.h:24
Defines a factor linear regression equation.
Definition: energy_balance_hierarchical_model.h:10
std::map< core::Identifier, double > coefficients
The regression model coefficients.
Definition: energy_balance_hierarchical_model.h:15
std::string name
The factor name.
Definition: energy_balance_hierarchical_model.h:12
double residuals_standard_deviation
The residuals standard deviation.
Definition: energy_balance_hierarchical_model.h:18
Defines a virtual population person data type.
Definition: person.h:40