Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
intervention_scenario.h
Go to the documentation of this file.
1#pragma once
2#include "scenario.h"
3
4#include <optional>
5#include <vector>
6
7namespace hgps {
8
9struct PolicyImpact;
10struct PolicyInterval;
11struct PolicyDynamic;
12
20 public:
23 virtual const PolicyInterval &active_period() const noexcept = 0;
24
27 virtual const std::vector<PolicyImpact> &impacts() const noexcept = 0;
28
29 ScenarioType type() const noexcept override { return ScenarioType::intervention; }
30
31 const std::string &name() const noexcept override { return name_; }
32
33 private:
34 std::string name_{"Intervention"};
35};
36
42 public:
45 virtual const PolicyDynamic &dynamic() const noexcept = 0;
46};
47
50 PolicyImpact() = delete;
51
58 PolicyImpact(core::Identifier risk_factor_key, double policy_impact, unsigned int start_age,
59 std::optional<unsigned int> end_age = std::nullopt)
60 : risk_factor{std::move(risk_factor_key)}, value{policy_impact}, from_age{start_age},
61 to_age{end_age} {
62
63 if (end_age.has_value() && start_age > end_age.value()) {
64 throw std::out_of_range("Impact end age must be equal or greater than the start age.");
65 }
66 }
67
69 core::Identifier risk_factor{};
70
72 double value{};
73
75 unsigned int from_age{};
76
78 std::optional<unsigned int> to_age{};
79
80 // NOLINTBEGIN(bugprone-exception-escape)
84 bool contains(unsigned int age) const noexcept {
85 if (age < from_age) {
86 return false;
87 }
88
89 if (to_age.has_value()) {
90 return age <= to_age.value();
91 }
92
93 return true;
94 }
95 // NOLINTEND(bugprone-exception-escape)
96};
97
100
105 PolicyInterval(int start_at_time, std::optional<int> finish_at_time = std::nullopt)
106 : start_time{start_at_time}, finish_time{finish_at_time} {
107 if (start_at_time < 0) {
108 throw std::out_of_range("Policy start time must not be negative.");
109 }
110
111 if (finish_at_time.has_value() && start_at_time > finish_at_time.value()) {
112 throw std::out_of_range(
113 "Policy finish time must be equal or greater than the start time.");
114 }
115 }
116
118 int start_time{};
120 std::optional<int> finish_time{};
121
122 // NOLINTBEGIN(bugprone-exception-escape)
126 bool contains(int time) const noexcept {
127 if (time < start_time) {
128 return false;
129 }
130
131 if (finish_time.has_value()) {
132 return time <= finish_time.value();
133 }
134
135 return true;
136 }
137 // NOLINTEND(bugprone-exception-escape)
138};
139
146 PolicyDynamic(const std::vector<double> &parameters) {
147 if (parameters.size() != size_t{3}) {
148 throw std::invalid_argument(
149 "The vector of dynamic arguments must have size = 3 [alpha, beta, gamma]");
150 }
151
152 for (const auto &p : parameters) {
153 if (0.0 > p || p > 1.0) {
154 throw std::out_of_range("Dynamic argument: " + std::to_string(p) +
155 ", outside range [0.0, 1.0]");
156 }
157 }
158
159 alpha = parameters.at(0);
160 beta = parameters.at(1);
161 gamma = parameters.at(2);
162 }
163
165 double alpha{1.0};
166
168 double beta{0.0};
169
171 double gamma{0.0};
172};
173} // namespace hgps
Health-GPS dynamic intervention policy scenario interface.
Definition intervention_scenario.h:41
virtual const PolicyDynamic & dynamic() const noexcept=0
Gets the System Dynamic model parameters.
Health-GPS scripted intervention policy scenario interface.
Definition intervention_scenario.h:19
virtual const std::vector< PolicyImpact > & impacts() const noexcept=0
Gets the intervention impacts by risk factor and age range.
const std::string & name() const noexcept override
Gets the scenario type name.
Definition intervention_scenario.h:31
ScenarioType type() const noexcept override
Gets the scenario type identifier.
Definition intervention_scenario.h:29
virtual const PolicyInterval & active_period() const noexcept=0
Gets the intervention active period.
Health-GPS simulation scenario interface.
Definition scenario.h:30
Top-level namespace for Health-GPS Console host application.
Definition command_options.cpp:8
ScenarioType
Health GPS policy scenario types enumeration.
Definition scenario.h:17
@ intervention
Intervention scenario.
Global namespace.
Definition column_iterator.h:123
Defines the policy dynamic parameters.
Definition intervention_scenario.h:141
PolicyDynamic(const std::vector< double > &parameters)
Initialises a new instance of the PolicyDynamic structure.
Definition intervention_scenario.h:146
Defines the policy impact on risk factors data structure.
Definition intervention_scenario.h:49
bool contains(unsigned int age) const noexcept
Determine whether this impact should be applied to a given age.
Definition intervention_scenario.h:84
PolicyImpact(core::Identifier risk_factor_key, double policy_impact, unsigned int start_age, std::optional< unsigned int > end_age=std::nullopt)
Initialise a new instance of the PolicyImpact structure.
Definition intervention_scenario.h:58
Defines the policy active interval.
Definition intervention_scenario.h:99
PolicyInterval(int start_at_time, std::optional< int > finish_at_time=std::nullopt)
Initialise a new instance of the PolicyInterval structure.
Definition intervention_scenario.h:105
bool contains(int time) const noexcept
Determine whether this interval contains a given time.
Definition intervention_scenario.h:126
Entity unique identifier data type.
Definition identifier.h:20