Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
simulation.h
Go to the documentation of this file.
1#pragma once
2
4
5#include "event_aggregator.h"
6#include "gender_table.h"
7#include "runtime_context.h"
8#include "simulation_module.h"
9
10#include <adevs/adevs.h>
11#include <vector>
12
13namespace hgps {
14
24class Simulation : public adevs::Model<int> {
25 public:
26 Simulation() = delete;
27
33 explicit Simulation(SimulationModuleFactory &factory,
34 std::shared_ptr<const EventAggregator> bus,
35 std::shared_ptr<const ModelInput> inputs,
36 std::unique_ptr<Scenario> scenario);
37
39 virtual ~Simulation() = default;
40
44 adevs::Time init(adevs::SimEnv<int> *env) override;
45
49 adevs::Time update(adevs::SimEnv<int> *env) override;
50
61 adevs::Time update(adevs::SimEnv<int> *env, std::vector<int> &x) override;
62
65 void fini(adevs::Time clock) override;
66
70 void setup_run(unsigned int run_number, unsigned int seed) noexcept;
71
74 ScenarioType type() noexcept { return context_.scenario().type(); }
75
78 std::string name() override { return context_.identifier(); }
79
80 private:
81 RuntimeContext context_;
82 std::shared_ptr<UpdatableModule> ses_;
83 std::shared_ptr<DemographicModule> demographic_;
84 std::shared_ptr<RiskFactorHostModule> risk_factor_;
85 std::shared_ptr<DiseaseModule> disease_;
86 std::shared_ptr<UpdatableModule> analysis_;
87 adevs::Time end_time_;
88
89 void initialise_population();
90 void update_population();
91 void print_initial_population_statistics();
92
93 void update_net_immigration();
94
95 hgps::IntegerAgeGenderTable get_current_expected_population() const;
96 hgps::IntegerAgeGenderTable get_current_simulated_population();
97 void apply_net_migration(int net_value, unsigned int age, const core::Gender &gender);
98 hgps::IntegerAgeGenderTable get_net_migration();
99 hgps::IntegerAgeGenderTable create_net_migration();
100 std::map<std::string, core::UnivariateSummary> create_input_data_summary() const;
101
102 static Person partial_clone_entity(const Person &source) noexcept;
103};
104
105} // namespace hgps
Defines the age and gender lookup table data type.
Definition gender_table.h:120
Defines the Simulation runtime context data type.
Definition runtime_context.h:22
const std::string & identifier() const noexcept
Gets the simulation identifier for outside world messages.
Definition runtime_context.cpp:43
Scenario & scenario() const noexcept
Gets a reference to the simulation scenario instance.
Definition runtime_context.cpp:27
virtual ScenarioType type() const noexcept=0
Gets the scenario type identifier.
Defines the SimulationModule factory data type.
Definition modulefactory.h:21
Defines the simulation engine data type class.
Definition simulation.h:24
virtual ~Simulation()=default
Destroys a simulation instance.
ScenarioType type() noexcept
Gets the simulation type.
Definition simulation.h:74
Simulation()=delete
std::string name() override
Gets the simulation name.
Definition simulation.h:78
void fini(adevs::Time clock) override
Called after the model has been removed from the simulation executive.
Definition simulation.cpp:126
adevs::Time init(adevs::SimEnv< int > *env) override
Called when the model is added to the simulation executive.
Definition simulation.cpp:50
void setup_run(unsigned int run_number, unsigned int seed) noexcept
Set up a new simulation run.
Definition simulation.cpp:45
Gender
Enumerates gender types.
Definition forward_type.h:18
Top-level namespace for Health-GPS Console host application.
Definition command_options.cpp:8
@ update
Simulation time has updated, time = time + 1.
ScenarioType
Health GPS policy scenario types enumeration.
Definition scenario.h:17
Defines a virtual population person data type.
Definition person.h:39