Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
jacardi_employment_static.h
Go to the documentation of this file.
1#pragma once
2
4#include "person.h"
5#include "random_algorithm.h"
6
7#include <array>
8#include <limits>
9#include <string>
10#include <unordered_map>
11#include <utility>
12#include <vector>
13
14namespace hgps {
15
27 public:
28 static constexpr double missing = std::numeric_limits<double>::quiet_NaN();
29 static constexpr unsigned int age_missing_max = 18U;
30 static constexpr unsigned int age_assign_min = 19U;
31 static constexpr int age_cap = 80;
32 static constexpr int category_count = 6;
33 static constexpr int category_min = 1;
34 static constexpr int category_max = 6;
35
36 struct FactorTerm {
37 std::string factor;
38 double coefficient{};
39 };
40
42 struct Assignment {
45 };
46
48 struct AgeFactors {
49 double age{};
50 std::array<double, 5> age_rcs{};
51 double school_fade{};
52 };
53
54 void set_coefficients(std::unordered_map<int, std::vector<FactorTerm>> by_category);
55 void set_recode(std::array<int, category_count + 1> detailed_to_cat4);
56
57 bool has_coefficients() const noexcept { return !coefficients_.empty(); }
58 bool has_recode() const noexcept { return recode_loaded_; }
59
61 std::array<double, category_count> score_probabilities(unsigned int age, core::Gender gender,
62 int education_id) const;
63
65 Assignment initialise(unsigned int age, core::Gender gender, int education_id,
66 Random &rng) const;
67
69 Assignment update(unsigned int age, core::Gender gender, int education_id,
70 const Assignment &current, Random &rng) const;
71
73 static Assignment hold(const Assignment &current) noexcept { return current; }
74
75 int recode(int employment_id) const;
76
77 static int gender_code(core::Gender gender);
78 static AgeFactors compute_age_factors(int age_capped);
79 static double factor_value(const std::string &factor, const AgeFactors &age_f, int gender,
80 int education_id);
81
82 private:
83 Assignment assign_draw(unsigned int age, core::Gender gender, int education_id,
84 Random &rng) const;
85 static int draw_category(const std::array<double, category_count> &probs, Random &rng);
86
87 std::unordered_map<int, std::vector<FactorTerm>> coefficients_;
88 // MAHIMA: index = employment_id 1..6; [0] unused.
89 std::array<int, category_count + 1> recode_{};
90 bool recode_loaded_{false};
91};
92
95bool person_has_employment(const Person &person);
96
97} // namespace hgps
Definition jacardi_employment_static.h:26
bool has_recode() const noexcept
Definition jacardi_employment_static.h:58
Assignment initialise(unsigned int age, core::Gender gender, int education_id, Random &rng) const
Part A — missing 0..18; else SCORE → DRAW → recode.
Definition jacardi_employment_static.cpp:232
static constexpr int age_cap
Definition jacardi_employment_static.h:31
static AgeFactors compute_age_factors(int age_capped)
Definition jacardi_employment_static.cpp:113
std::array< double, category_count > score_probabilities(unsigned int age, core::Gender gender, int education_id) const
Softmax probabilities p_1..p_6 for SCORE checks (indices 0..5 = categories 1..6).
Definition jacardi_employment_static.cpp:152
void set_coefficients(std::unordered_map< int, std::vector< FactorTerm > > by_category)
Definition jacardi_employment_static.cpp:93
static constexpr unsigned int age_missing_max
Definition jacardi_employment_static.h:29
static constexpr int category_max
Definition jacardi_employment_static.h:34
static double factor_value(const std::string &factor, const AgeFactors &age_f, int gender, int education_id)
Definition jacardi_employment_static.cpp:131
static constexpr unsigned int age_assign_min
Definition jacardi_employment_static.h:30
int recode(int employment_id) const
Definition jacardi_employment_static.cpp:211
static constexpr int category_min
Definition jacardi_employment_static.h:33
static constexpr int category_count
Definition jacardi_employment_static.h:32
static int gender_code(core::Gender gender)
Definition jacardi_employment_static.cpp:103
static constexpr double missing
Definition jacardi_employment_static.h:28
void set_recode(std::array< int, category_count+1 > detailed_to_cat4)
Definition jacardi_employment_static.cpp:98
Assignment update(unsigned int age, core::Gender gender, int education_id, const Assignment &current, Random &rng) const
Part B — missing under 19; first assign if still missing at 19+; else hold (temporary).
Definition jacardi_employment_static.cpp:244
bool has_coefficients() const noexcept
Definition jacardi_employment_static.h:57
static Assignment hold(const Assignment &current) noexcept
MAHIMA: Isolated hold — yearly package replaces this path only.
Definition jacardi_employment_static.h:73
General purpose Random number generator algorithms.
Definition random_algorithm.h:8
Gender
Enumerates gender types.
Definition forward_type.h:18
Top-level namespace for Health-GPS Console host application.
Definition command_options.cpp:9
bool person_has_employment(const Person &person)
Definition jacardi_employment_static.cpp:274
EmploymentStaticTables::Assignment get_person_employment(const Person &person)
Definition jacardi_employment_static.cpp:261
void set_person_employment(Person &person, const EmploymentStaticTables::Assignment &assignment)
Definition jacardi_employment_static.cpp:256
Age-only predictors (precomputed for 19..80).
Definition jacardi_employment_static.h:48
double school_fade
Definition jacardi_employment_static.h:51
std::array< double, 5 > age_rcs
Definition jacardi_employment_static.h:50
double age
Definition jacardi_employment_static.h:49
Drawn detailed id + recoded 4-cat id (both NaN when missing).
Definition jacardi_employment_static.h:42
double cat4_id
Definition jacardi_employment_static.h:44
double detailed_id
Definition jacardi_employment_static.h:43
Definition jacardi_employment_static.h:36
double coefficient
Definition jacardi_employment_static.h:38
std::string factor
Definition jacardi_employment_static.h:37
Defines a virtual population person data type.
Definition person.h:39