Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
runtime_context.h
Go to the documentation of this file.
1#pragma once
2
3#include "event_aggregator.h"
4#include "mapping.h"
5#include "modelinput.h"
6#include "population.h"
7#include "random_algorithm.h"
8#include "runtime_metric.h"
9#include "scenario.h"
10
11#include <functional>
12#include <vector>
13
14namespace hgps {
15
23 public:
24 RuntimeContext() = delete;
29 RuntimeContext(std::shared_ptr<const EventAggregator> bus,
30 std::shared_ptr<const ModelInput> inputs, std::unique_ptr<Scenario> scenario);
31
34 int time_now() const noexcept;
35
38 int start_time() const noexcept;
39
42 unsigned int current_run() const noexcept;
43
46 int sync_timeout_millis() const noexcept;
47
50 Population &population() noexcept;
51
54 const Population &population() const noexcept;
55
58 RuntimeMetric &metrics() noexcept;
59
62 const ModelInput &inputs() const noexcept;
63
66 Scenario &scenario() const noexcept;
67
70 Random &random() const noexcept;
71
74 const HierarchicalMapping &mapping() const noexcept;
75
78 const std::vector<core::DiseaseInfo> &diseases() const noexcept;
79
82 const core::IntegerInterval &age_range() const noexcept;
83
86 const std::string &identifier() const noexcept;
87
90 void set_current_time(const int time_now) noexcept;
91
94 void set_current_run(const unsigned int run_number) noexcept;
95
98 void reset_population(std::size_t initial_pop_size);
99
102 void publish(std::unique_ptr<EventMessage> message) const noexcept;
103
106 void publish_async(std::unique_ptr<EventMessage> message) const noexcept;
107
108 private:
109 std::shared_ptr<const EventAggregator> event_bus_;
110 std::shared_ptr<const ModelInput> inputs_;
111 std::unique_ptr<Scenario> scenario_;
112 Population population_;
113 mutable Random random_{};
114 RuntimeMetric metrics_{};
115 unsigned int current_run_{};
116 int model_start_time_{};
117 int time_now_{};
118};
119
120} // namespace hgps
Defines the event aggregator interface type.
Definition event_aggregator.h:59
Defines the hierarchical model mapping data type.
Definition mapping.h:61
Defines the Simulation model inputs data type.
Definition modelinput.h:49
Defines the virtual population data type.
Definition population.h:19
General purpose Random number generator algorithms.
Definition random_algorithm.h:8
Defines the Simulation runtime context data type.
Definition runtime_context.h:22
RuntimeMetric & metrics() noexcept
Gets a reference to the runtime metrics container.
Definition runtime_context.cpp:23
const core::IntegerInterval & age_range() const noexcept
Gets a read-only reference to the population age range constraints.
Definition runtime_context.cpp:39
unsigned int current_run() const noexcept
Gets the experiment current run number.
Definition runtime_context.cpp:15
int sync_timeout_millis() const noexcept
Gets the data synchronisation timeout in milliseconds.
Definition runtime_context.cpp:17
void set_current_time(const int time_now) noexcept
Sets the current simulation time value.
Definition runtime_context.cpp:45
Population & population() noexcept
Gets a reference to the virtual population container.
Definition runtime_context.cpp:19
const std::vector< core::DiseaseInfo > & diseases() const noexcept
Gets a read-only reference to the select diseases information.
Definition runtime_context.cpp:35
const ModelInput & inputs() const noexcept
Gets a reference to the model inputs definition.
Definition runtime_context.cpp:25
void publish_async(std::unique_ptr< EventMessage > message) const noexcept
Publishes a polymorphic new message to the outside world asynchronously.
Definition runtime_context.cpp:60
int time_now() const noexcept
Gets the current simulation time.
Definition runtime_context.cpp:11
const HierarchicalMapping & mapping() const noexcept
Gets a read-only reference to the hierarchical risk factors mapping.
Definition runtime_context.cpp:31
const std::string & identifier() const noexcept
Gets the simulation identifier for outside world messages.
Definition runtime_context.cpp:43
void publish(std::unique_ptr< EventMessage > message) const noexcept
Publishes a polymorphic new message to the outside world synchronously.
Definition runtime_context.cpp:56
Scenario & scenario() const noexcept
Gets a reference to the simulation scenario instance.
Definition runtime_context.cpp:27
void set_current_run(const unsigned int run_number) noexcept
Sets the current simulation run number.
Definition runtime_context.cpp:47
Random & random() const noexcept
Gets a reference to the engine random number generator.
Definition runtime_context.cpp:29
int start_time() const noexcept
Gets the experiment start time.
Definition runtime_context.cpp:13
void reset_population(std::size_t initial_pop_size)
Resets the virtual population to an initial size, with only new individuals.
Definition runtime_context.cpp:51
Defines the Simulation run-time metrics container data type.
Definition runtime_metric.h:12
Health-GPS simulation scenario interface.
Definition scenario.h:30
Top-level namespace for Health-GPS Console host application.
Definition command_options.cpp:8
Global namespace.
Definition column_iterator.h:123
Simulation event messages interface.
Definition event_message.h:29