Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
kevin_hall_model.h
Go to the documentation of this file.
1#pragma once
2
4
5#include "interfaces.h"
6#include "map2d.h"
7#include "mapping.h"
9
10#include <optional>
11#include <string_view>
12#include <vector>
13
14namespace hgps {
15
17 double slope{};
18 double stddev{};
19};
20
23
28 public:
43 std::shared_ptr<RiskFactorSexAgeTable> expected,
44 std::shared_ptr<std::unordered_map<core::Identifier, double>> expected_trend,
45 std::shared_ptr<std::unordered_map<core::Identifier, int>> trend_steps,
46 const std::unordered_map<core::Identifier, double> &energy_equation,
47 const std::unordered_map<core::Identifier, core::DoubleInterval> &nutrient_ranges,
48 const std::unordered_map<core::Identifier, std::map<core::Identifier, double>>
49 &nutrient_equations,
50 const std::unordered_map<core::Identifier, std::optional<double>> &food_prices,
51 const std::unordered_map<core::Gender, std::vector<std::vector<double>>>
52 &weight_quantiles_by_stratum,
53 const std::vector<double> &epa_quantiles,
54 std::unordered_map<core::Gender, std::vector<HeightModelParams>> height_params);
55
56 RiskFactorModelType type() const noexcept override;
57
58 std::string name() const noexcept override;
59
60 void generate_risk_factors(RuntimeContext &context) override;
61
62 void update_risk_factors(RuntimeContext &context) override;
63
67 void validate_weight_in_config_range(const RuntimeContext &context, const Person &person,
68 std::string_view phase) const;
69
70 private:
73 void update_newborns(RuntimeContext &context) const;
74
77 void update_non_newborns(RuntimeContext &context) const;
78
81 void initialise_nutrient_intakes(Person &person) const;
82
85 void update_nutrient_intakes(Person &person) const;
86
89 void compute_nutrient_intakes(Person &person) const;
90
93 void initialise_energy_intake(Person &person) const;
94
97 void update_energy_intake(Person &person) const;
98
101 void compute_energy_intake(Person &person) const;
102
108 double compute_G(double CI, double CI_0, double G_0) const;
109
116 double compute_ECF(double delta_Na, double CI, double CI_0, double ECF_0) const;
117
125 double compute_delta(int age, core::Gender sex, double PAL, double BW, double H) const;
126
136 double compute_EE(double BW, double F, double L, double EI, double K, double delta,
137 double x) const;
138
141 void compute_bmi(Person &person) const;
142
146 void initialise_weight(RuntimeContext &context, Person &person) const;
147
152 void initialise_kevin_hall_state(const RuntimeContext &context, Person &person,
153 std::optional<double> adjustment = std::nullopt) const;
154
158 void kevin_hall_run(const RuntimeContext &context, Person &person) const;
159
164 void adjust_weight(const RuntimeContext &context, Person &person, double adjustment) const;
165
169 KevinHallAdjustmentTable receive_weight_adjustments(RuntimeContext &context) const;
170
174 void send_weight_adjustments(RuntimeContext &context,
175 KevinHallAdjustmentTable &&adjustments) const;
176
182 compute_weight_adjustments(RuntimeContext &context,
183 std::optional<unsigned> age = std::nullopt) const;
184
193 double get_expected(RuntimeContext &context, core::Gender sex, int age,
194 const core::Identifier &factor, OptionalRange range,
195 bool apply_trend) const override;
196
200 double get_weight_quantile(double epa_quantile, const std::vector<double> &quantiles) const;
201
207 KevinHallAdjustmentTable compute_mean_weight(
208 Population &population,
209 std::optional<std::unordered_map<core::Gender, double>> power = std::nullopt,
210 std::optional<unsigned> age = std::nullopt) const;
212 compute_mean_weight_for_height(Population &population,
213 std::optional<unsigned> age = std::nullopt) const;
214
220 void initialise_height(RuntimeContext &context, Person &person, double W_power_mean,
221 Random &random) const;
222
227 void update_height(RuntimeContext &context, Person &person, double W_power_mean) const;
228
230 void print_height_summary_tables(RuntimeContext &context, std::string_view phase) const;
231
233 void print_weight_summary_tables(RuntimeContext &context, std::string_view phase) const;
234
235 // NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members) references to model definition
236 // data
237 const std::unordered_map<core::Identifier, double> &energy_equation_;
238 const std::unordered_map<core::Identifier, core::DoubleInterval> &nutrient_ranges_;
239 const std::unordered_map<core::Identifier, std::map<core::Identifier, double>>
240 &nutrient_equations_;
241 const std::unordered_map<core::Identifier, std::optional<double>> &food_prices_;
242 const std::unordered_map<core::Gender, std::vector<std::vector<double>>>
243 &weight_quantiles_by_stratum_;
244 const std::vector<double> &epa_quantiles_;
245 // NOLINTEND(cppcoreguidelines-avoid-const-or-ref-data-members)
246 std::unordered_map<core::Gender, std::vector<HeightModelParams>> height_params_;
247
248 // Model parameters.
249 static constexpr int kevin_hall_age_min = 19; // Start age for the main Kevin Hall model.
250 static constexpr double rho_F = 39.5e3; // Energy content of fat (kJ/kg).
251 static constexpr double rho_L = 7.6e3; // Energy content of lean (kJ/kg).
252 static constexpr double rho_G = 17.6e3; // Energy content of glycogen (kJ/kg).
253 static constexpr double gamma_F = 13.0; // RMR fat coefficients (kJ/kg/day).
254 static constexpr double gamma_L = 92.0; // RMR lean coefficients (kJ/kg/day).
255 static constexpr double eta_F = 750.0; // Fat synthesis energy coefficient (kJ/kg).
256 static constexpr double eta_L = 960.0; // Lean synthesis energy coefficient (kJ/kg).
257 static constexpr double beta_TEF = 0.1; // TEF from energy intake (unitless).
258 static constexpr double beta_AT = 0.14; // AT from energy intake (unitless).
259 static constexpr double xi_Na = 3000.0; // Na from ECF changes (mg/L/day).
260 static constexpr double xi_CI = 4000.0; // Na from carbohydrate changes (mg/day).
261};
262
265 public:
280 std::unique_ptr<RiskFactorSexAgeTable> expected,
281 std::unique_ptr<std::unordered_map<core::Identifier, double>> expected_trend,
282 std::unique_ptr<std::unordered_map<core::Identifier, int>> trend_steps,
283 std::unordered_map<core::Identifier, double> energy_equation,
284 std::unordered_map<core::Identifier, core::DoubleInterval> nutrient_ranges,
285 std::unordered_map<core::Identifier, std::map<core::Identifier, double>> nutrient_equations,
286 std::unordered_map<core::Identifier, std::optional<double>> food_prices,
287 std::unordered_map<core::Gender, std::vector<std::vector<double>>>
288 weight_quantiles_by_stratum,
289 std::vector<double> epa_quantiles,
290 std::unordered_map<core::Gender, std::vector<HeightModelParams>> height_params);
291
294 std::unique_ptr<RiskFactorModel> create_model() const override;
295
296 private:
297 std::unordered_map<core::Identifier, double> energy_equation_;
298 std::unordered_map<core::Identifier, core::DoubleInterval> nutrient_ranges_;
299 std::unordered_map<core::Identifier, std::map<core::Identifier, double>> nutrient_equations_;
300 std::unordered_map<core::Identifier, std::optional<double>> food_prices_;
301 std::unordered_map<core::Gender, std::vector<std::vector<double>>> weight_quantiles_by_stratum_;
302 std::vector<double> epa_quantiles_;
303 std::unordered_map<core::Gender, std::vector<HeightModelParams>> height_params_;
304};
305
306} // namespace hgps
Defines the energy balance model data type.
Definition kevin_hall_model.h:264
std::unique_ptr< RiskFactorModel > create_model() const override
Construct a new KevinHallModel from this definition.
Definition kevin_hall_model.cpp:1454
Implements the energy balance model type.
Definition kevin_hall_model.h:27
void validate_weight_in_config_range(const RuntimeContext &context, const Person &person, std::string_view phase) const
Checks person weight against modelling.risk_factors.Weight range from config. Below minimum: throws a...
Definition kevin_hall_model.cpp:1164
RiskFactorModelType type() const noexcept override
Gets the model type identifier.
Definition kevin_hall_model.cpp:447
void generate_risk_factors(RuntimeContext &context) override
Generates the initial risk factors for a population and newborns.
Definition kevin_hall_model.cpp:451
std::string name() const noexcept override
Gets the model name.
Definition kevin_hall_model.cpp:449
void update_risk_factors(RuntimeContext &context) override
Update risk factors for population.
Definition kevin_hall_model.cpp:487
Defines the two-dimensional map (lookup table) data type.
Definition map2d.h:14
Defines the virtual population data type.
Definition population.h:19
General purpose Random number generator algorithms.
Definition random_algorithm.h:8
Risk factor adjustable model definition interface.
Definition risk_factor_adjustable_model.h:158
Risk factor model interface with mean adjustment by sex and age.
Definition risk_factor_adjustable_model.h:63
Defines the Simulation runtime context data type.
Definition runtime_context.h:22
Gender
Enumerates gender types.
Definition forward_type.h:18
Top-level namespace for Health-GPS Console host application.
Definition command_options.cpp:8
RiskFactorModelType
Health GPS risk factor module types enumeration.
Definition risk_factor_model.h:12
Definition kevin_hall_model.h:16
double slope
Definition kevin_hall_model.h:17
double stddev
Definition kevin_hall_model.h:18
Defines a virtual population person data type.
Definition person.h:39
Entity unique identifier data type.
Definition identifier.h:20