10 struct PolicyInterval;
31 const std::string &
name() const noexcept
override {
return name_; }
34 std::string name_{
"Intervention"};
59 std::optional<unsigned int> end_age = std::nullopt)
60 : risk_factor{
std::move(risk_factor_key)}, value{policy_impact}, from_age{start_age},
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.");
75 unsigned int from_age{};
78 std::optional<unsigned int> to_age{};
83 bool contains(
const unsigned int &age)
const noexcept {
88 if (to_age.has_value()) {
89 return age <= to_age.value();
103 PolicyInterval(
int start_at_time, std::optional<int> finish_at_time = std::nullopt)
104 : start_time{start_at_time}, finish_time{finish_at_time} {
105 if (start_at_time < 0) {
106 throw std::out_of_range(
"Policy start time must not be negative.");
109 if (finish_at_time.has_value() && start_at_time > finish_at_time.value()) {
110 throw std::out_of_range(
111 "Policy finish time must be equal or greater than the start time.");
118 std::optional<int> finish_time{};
124 if (time < start_time) {
128 if (finish_time.has_value()) {
129 return time <= finish_time.value();
143 if (parameters.size() !=
size_t{3}) {
144 throw std::invalid_argument(
145 "The vector of dynamic arguments must have size = 3 [alpha, beta, gamma]");
148 for (
const auto &p : parameters) {
149 if (0.0 > p || p > 1.0) {
150 throw std::out_of_range(
"Dynamic argument: " + std::to_string(p) +
151 ", outside range [0.0, 1.0]");
155 alpha = parameters.at(0);
156 beta = parameters.at(1);
157 gamma = parameters.at(2);
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
ScenarioType type() const noexcept override
Gets the scenario type identifier.
Definition: intervention_scenario.h:29
const std::string & name() const noexcept override
Gets the scenario type name.
Definition: intervention_scenario.h:31
virtual const PolicyInterval & active_period() const noexcept=0
Gets the intervention active period.
virtual const std::vector< PolicyImpact > & impacts() const noexcept=0
Gets the intervention impacts by risk factor and age range.
Health-GPS simulation scenario interface.
Definition: scenario.h:30
Top-level namespace for Health-GPS C++ API.
Definition: analysis_definition.h:8
ScenarioType
Health GPS policy scenario types enumeration.
Definition: scenario.h:17
@ intervention
Intervention scenario.
Global namespace.
Definition: jsonparser.h:88
Defines the policy dynamic parameters.
Definition: intervention_scenario.h:137
PolicyDynamic(const std::vector< double > ¶meters)
Initialises a new instance of the PolicyDynamic structure.
Definition: intervention_scenario.h:142
Defines the policy impact on risk factors data structure.
Definition: intervention_scenario.h:49
bool contains(const unsigned int &age) const noexcept
Determine whether this impact should be applied to a given age.
Definition: intervention_scenario.h:83
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:97
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:103
bool contains(const int &time) const noexcept
Determine whether this interval contains a given time.
Definition: intervention_scenario.h:123
Entity unique identifier data type.
Definition: identifier.h:17