Health-GPS  1.2.2.0
Global Health Policy Simulation model (Health-GPS)
demographic.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "gender_table.h"
4 #include "gender_value.h"
5 #include "interfaces.h"
6 #include "life_table.h"
7 #include "modelinput.h"
8 #include "repository.h"
9 #include "runtime_context.h"
10 
11 namespace hgps {
12 
19  PopulationRecord(int pop_age, float num_males, float num_females)
20  : age{pop_age}, males{num_males}, females{num_females} {}
21 
23  int age{};
24 
26  float males{};
27 
29  float females{};
30 
33  float total() const noexcept { return males + females; }
34 };
35 
37 class PopulationModule final : public DemographicModule {
38  public:
39  PopulationModule() = delete;
40 
44  PopulationModule(std::map<int, std::map<int, PopulationRecord>> &&pop_data,
45  LifeTable &&life_table);
46 
47  SimulationModuleType type() const noexcept override;
48 
49  const std::string &name() const noexcept override;
50 
51  std::size_t get_total_population_size(int time_year) const noexcept override;
52 
53  const std::map<int, PopulationRecord> &
54  get_population_distribution(int time_year) const override;
55 
56  void initialise_population(RuntimeContext &context) override;
57 
58  void update_population(RuntimeContext &context, const DiseaseHostModule &disease_host) override;
59 
60  private:
61  std::map<int, std::map<int, PopulationRecord>> pop_data_;
62  LifeTable life_table_;
63  GenderTable<int, double> birth_rates_;
64  GenderTable<int, double> residual_death_rates_;
65  std::string name_{"Demographic"};
66 
67  void initialise_birth_rates();
68 
69  double get_total_deaths(int time_year) const noexcept;
70  std::map<int, DoubleGenderValue> get_age_gender_distribution(int time_year) const noexcept;
71  DoubleGenderValue get_birth_rate(int time_year) const noexcept;
72  double get_residual_death_rate(int age, core::Gender gender) const noexcept;
73 
74  GenderTable<int, double> create_death_rates_table(int time_year);
75  GenderTable<int, double> calculate_residual_mortality(RuntimeContext &context,
76  const DiseaseHostModule &disease_host);
77 
78  void update_residual_mortality(RuntimeContext &context, const DiseaseHostModule &disease_host);
79  double calculate_excess_mortality_product(const Person &entity,
80  const DiseaseHostModule &disease_host) const;
81  int update_age_and_death_events(RuntimeContext &context, const DiseaseHostModule &disease_host);
82 };
83 
88 std::unique_ptr<PopulationModule> build_population_module(Repository &repository,
89  const ModelInput &config);
90 } // namespace hgps
Demographic prospects module interface.
Definition: interfaces.h:116
Generic disease module interface to host multiple disease models.
Definition: interfaces.h:79
Defines the gender column lookup table data type.
Definition: gender_table.h:15
Defines the population life table data type.
Definition: life_table.h:29
Implements the population demographic module data type.
Definition: demographic.h:37
void initialise_population(RuntimeContext &context) override
Initialises the virtual population.
Definition: demographic.cpp:112
std::size_t get_total_population_size(int time_year) const noexcept override
Gets the total population at a specific point in time.
Definition: demographic.cpp:49
SimulationModuleType type() const noexcept override
Gets the module type identifier.
Definition: demographic.cpp:43
const std::map< int, PopulationRecord > & get_population_distribution(int time_year) const override
Gets the population age distribution at a specific point in time.
Definition: demographic.cpp:71
const std::string & name() const noexcept override
Gets the module name.
Definition: demographic.cpp:47
void update_population(RuntimeContext &context, const DiseaseHostModule &disease_host) override
Updates the virtual population status.
Definition: demographic.cpp:176
Defines the Simulation runtime context data type.
Definition: runtime_context.h:21
Gender
Enumerates gender types.
Definition: forward_type.h:18
Top-level namespace for Health-GPS C++ API.
Definition: analysis_definition.h:8
SimulationModuleType
Health GPS simulation modules types enumeration.
Definition: interfaces.h:11
std::unique_ptr< PopulationModule > build_population_module(Repository &repository, const ModelInput &config)
Builds a new instance of the PopulationModule using the given data infrastructure.
Definition: demographic.cpp:370
Global namespace.
Definition: jsonparser.h:88
Defines a virtual population person data type.
Definition: person.h:40
Define the population record data type for the demographic dataset.
Definition: demographic.h:14
int age
Age reference in years.
Definition: demographic.h:23
float total() const noexcept
Gets the total number at age.
Definition: demographic.h:33
float females
NUmber of females.
Definition: demographic.h:29
PopulationRecord(int pop_age, float num_males, float num_females)
Initialise a new instance of the PopulationRecord structure.
Definition: demographic.h:19
float males
Number of males.
Definition: demographic.h:26