Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
food_labelling_scenario.h
Go to the documentation of this file.
1#pragma once
2#include "gender_value.h"
4
5#include <functional>
6#include <set>
7#include <string>
8#include <unordered_map>
9#include <vector>
10
11namespace hgps {
12
18 AdjustmentFactor(std::string factor_name, double value)
19 : identifier{factor_name}, adjustment{value} {}
20
23
25 double adjustment{};
26};
27
30 PolicyCoverage() = delete;
31
36 PolicyCoverage(const std::vector<double> &rates, unsigned int effect_time)
37 : cutoff_time{effect_time} {
38 if (rates.size() != 2) {
39 throw std::invalid_argument(
40 "The number of transfer coefficients must be 2 (short, long) term.");
41 }
42
43 short_term_rate = rates[0];
44 long_term_rate = rates[1];
45 }
46
49
52
54 unsigned int cutoff_time{};
55};
56
60
65 TransferCoefficient(std::vector<double> values, unsigned int child_age)
66 : child{}, adult{}, child_cutoff_age{child_age} {
67 if (values.size() != 4) {
68 throw std::out_of_range("The number of transfer coefficients must be 4.");
69 }
70
71 child.males = values[0];
72 child.females = values[1];
73 adult.males = values[2];
74 adult.females = values[3];
75 }
76
79
82
84 unsigned int child_cutoff_age{};
85
90 double get_value(core::Gender gender, unsigned int age) const noexcept {
91 if (gender == core::Gender::male) {
92 if (age <= child_cutoff_age) {
93 return child.males;
94 }
95
96 return adult.males;
97 }
98
99 if (age <= child_cutoff_age) {
100 return child.females;
101 }
102
103 return adult.females;
104 }
105};
106
124
127 public:
129
136
137 SyncChannel &channel() override;
138
139 void clear() noexcept override;
140
141 double apply(Random &generator, Person &entity, int time,
142 const core::Identifier &risk_factor_key, double value) override;
143
144 const PolicyInterval &active_period() const noexcept override;
145
146 const std::vector<PolicyImpact> &impacts() const noexcept override;
147
148 private:
149 std::reference_wrapper<SyncChannel> channel_;
150 FoodLabellingDefinition definition_;
151 std::set<core::Identifier> factor_impact_;
152 std::unordered_map<std::size_t, int> interventions_book_{};
153
154 double calculate_policy_impact(const Person &entity) const noexcept;
155};
156} // namespace hgps
Thread-safe communication channel data type.
Definition channel.h:24
Implements the food labelling intervention scenario.
Definition food_labelling_scenario.h:126
const PolicyInterval & active_period() const noexcept override
Gets the intervention active period.
Definition food_labelling_scenario.cpp:67
void clear() noexcept override
Clear the scenario log book data.
Definition food_labelling_scenario.cpp:30
const std::vector< PolicyImpact > & impacts() const noexcept override
Gets the intervention impacts by risk factor and age range.
Definition food_labelling_scenario.cpp:71
double apply(Random &generator, Person &entity, int time, const core::Identifier &risk_factor_key, double value) override
Applies this Scenario to the Person instance.
Definition food_labelling_scenario.cpp:32
SyncChannel & channel() override
Gets the Scenario communication channel.
Definition food_labelling_scenario.cpp:28
Health-GPS scripted intervention policy scenario interface.
Definition intervention_scenario.h:19
General purpose Random number generator algorithms.
Definition random_algorithm.h:8
Gender
Enumerates gender types.
Definition forward_type.h:18
Top-level namespace for Health-GPS Console host application.
Definition command_options.cpp:8
Global namespace.
Definition column_iterator.h:123
Defined the risk factor adjustment data type.
Definition food_labelling_scenario.h:14
double adjustment
The adjustment value.
Definition food_labelling_scenario.h:25
AdjustmentFactor(std::string factor_name, double value)
Initialise a new instance of the AdjustmentFactor structure.
Definition food_labelling_scenario.h:18
core::Identifier identifier
The risk factor identifier.
Definition food_labelling_scenario.h:22
Food labelling intervention definition data type.
Definition food_labelling_scenario.h:108
PolicyInterval active_period
Intervention active period.
Definition food_labelling_scenario.h:110
TransferCoefficient transfer_coefficient
The transfer coefficient values.
Definition food_labelling_scenario.h:122
AdjustmentFactor adjustment_risk_factor
The adjustments on risk factors.
Definition food_labelling_scenario.h:116
PolicyCoverage coverage
The intervention population coverage.
Definition food_labelling_scenario.h:119
std::vector< PolicyImpact > impacts
Intervention impacts on risk factors.
Definition food_labelling_scenario.h:113
T females
Females value.
Definition gender_value.h:23
T males
Males value.
Definition gender_value.h:20
Defines a virtual population person data type.
Definition person.h:39
Define the policy population coverage data type.
Definition food_labelling_scenario.h:29
PolicyCoverage(const std::vector< double > &rates, unsigned int effect_time)
Initialise a new instance of the PolicyCoverage structure.
Definition food_labelling_scenario.h:36
unsigned int cutoff_time
The coverage effect cut-off time.
Definition food_labelling_scenario.h:54
double short_term_rate
The short term transfer coefficient value.
Definition food_labelling_scenario.h:48
double long_term_rate
The long term transfer coefficient value.
Definition food_labelling_scenario.h:51
Defines the policy impact on risk factors data structure.
Definition intervention_scenario.h:49
Defines the policy active interval.
Definition intervention_scenario.h:99
Define the transfer coefficient data type.
Definition food_labelling_scenario.h:58
unsigned int child_cutoff_age
The child cut-off age (before adult)
Definition food_labelling_scenario.h:84
double get_value(core::Gender gender, unsigned int age) const noexcept
Gets the transfer coefficient value for a given gender and age.
Definition food_labelling_scenario.h:90
DoubleGenderValue child
Children transfer coefficient values.
Definition food_labelling_scenario.h:78
DoubleGenderValue adult
Adult transfer coefficient values.
Definition food_labelling_scenario.h:81
TransferCoefficient(std::vector< double > values, unsigned int child_age)
Initialise a new instance of the TransferCoefficient structure.
Definition food_labelling_scenario.h:65
Entity unique identifier data type.
Definition identifier.h:20