90 std::shared_ptr<RiskFactorSexAgeTable> expected,
91 std::shared_ptr<std::unordered_map<core::Identifier, double>> expected_trend,
92 std::shared_ptr<std::unordered_map<core::Identifier, int>> trend_steps,
93 std::shared_ptr<std::unordered_map<core::Identifier, double>> expected_trend_boxcox,
94 const std::vector<core::Identifier> &names,
const std::vector<LinearModelParams> &models,
95 const std::vector<core::DoubleInterval> &ranges,
const std::vector<double> &lambda,
96 const std::vector<double> &stddev,
const Eigen::MatrixXd &cholesky,
97 const std::vector<LinearModelParams> &policy_models,
98 const std::vector<core::DoubleInterval> &policy_ranges,
99 const Eigen::MatrixXd &policy_cholesky,
100 std::shared_ptr<std::vector<LinearModelParams>> trend_models,
101 std::shared_ptr<std::vector<core::DoubleInterval>> trend_ranges,
102 std::shared_ptr<std::vector<double>> trend_lambda,
double info_speed,
103 const std::unordered_map<
core::Identifier, std::unordered_map<core::Gender, double>>
105 const std::unordered_map<core::Income, LinearModelParams> &income_models,
106 double physical_activity_stddev,
TrendType trend_type,
107 std::shared_ptr<std::unordered_map<core::Identifier, double>> expected_income_trend =
109 std::shared_ptr<std::unordered_map<core::Identifier, double>> expected_income_trend_boxcox =
111 std::shared_ptr<std::unordered_map<core::Identifier, int>> income_trend_steps =
nullptr,
112 std::shared_ptr<std::vector<LinearModelParams>> income_trend_models =
nullptr,
113 std::shared_ptr<std::vector<core::DoubleInterval>> income_trend_ranges =
nullptr,
114 std::shared_ptr<std::vector<double>> income_trend_lambda =
nullptr,
115 std::shared_ptr<std::unordered_map<core::Identifier, double>> income_trend_decay_factors =
122 const std::unordered_map<core::Identifier, PhysicalActivityModel>
123 &physical_activity_models = {},
126 const std::vector<IncomeStratumExpectedTableEntry> &income_stratum_expected_tables = {},
129 bool income_stratum_adjustment_enabled =
false,
131 std::size_t adjustment_income_stratum_count = 0u,
bool has_active_policies =
true,
134 const std::vector<LinearModelParams> &logistic_models = {},
139 std::string
name()
const noexcept override;
150 static double inverse_box_cox(
double factor,
double lambda);
191 bool intervene)
const;
195 void apply_policies(
Person &person,
bool intervene)
const;
198 const std::vector<LinearModelParams> &models)
const;
200 std::vector<double> compute_residuals(
Random &random,
const Eigen::MatrixXd &cholesky)
const;
206 double calculate_zero_probability(
Person &person,
size_t risk_factor_index)
const;
211 void initialise_sector(
Person &person,
Random &random)
const;
216 void update_sector(
Person &person,
Random &random)
const;
219 bool is_continuous_income_model_;
227 double calculate_continuous_income(
Person &person,
Random &random);
234 core::Income convert_income_continuous_to_category(
double continuous_income,
243 core::Income convert_income_to_category(
double continuous_income,
244 const std::vector<double> &quartile_thresholds)
const;
249 static std::vector<double> calculate_income_quartiles(
const Population &population);
254 static std::vector<double> calculate_income_tertiles(
const Population &population);
257 static std::vector<double> calculate_income_percentile_thresholds(
const Population &population,
258 std::size_t bucket_count);
263 void initialise_categorical_income(
Person &person,
Random &random);
284 std::pair<std::vector<core::Identifier>, std::vector<core::DoubleInterval>>
286 const std::vector<core::Identifier> &base_factors,
287 const std::vector<core::DoubleInterval> &base_ranges,
288 bool for_trended_adjustment =
false)
const;
312 std::shared_ptr<std::unordered_map<core::Identifier, double>> expected_trend_;
313 std::shared_ptr<std::unordered_map<core::Identifier, double>> expected_trend_boxcox_;
314 std::shared_ptr<std::vector<LinearModelParams>> trend_models_;
315 std::shared_ptr<std::vector<core::DoubleInterval>> trend_ranges_;
316 std::shared_ptr<std::vector<double>> trend_lambda_;
320 std::shared_ptr<std::unordered_map<core::Identifier, double>> expected_income_trend_;
321 std::shared_ptr<std::unordered_map<core::Identifier, double>> expected_income_trend_boxcox_;
322 std::shared_ptr<std::unordered_map<core::Identifier, int>> income_trend_steps_;
323 std::shared_ptr<std::vector<LinearModelParams>> income_trend_models_;
324 std::shared_ptr<std::vector<core::DoubleInterval>> income_trend_ranges_;
325 std::shared_ptr<std::vector<double>> income_trend_lambda_;
326 std::shared_ptr<std::unordered_map<core::Identifier, double>> income_trend_decay_factors_;
329 const std::vector<core::Identifier> &names_;
330 const std::vector<LinearModelParams> &models_;
331 const std::vector<core::DoubleInterval> &ranges_;
332 const std::vector<double> &lambda_;
333 const std::vector<double> &stddev_;
334 const Eigen::MatrixXd &cholesky_;
335 const std::vector<LinearModelParams> &policy_models_;
336 const std::vector<core::DoubleInterval> &policy_ranges_;
337 const Eigen::MatrixXd &policy_cholesky_;
338 const double info_speed_;
339 const std::unordered_map<core::Identifier, std::unordered_map<core::Gender, double>>
341 const std::unordered_map<core::Income, LinearModelParams> &income_models_;
342 const double physical_activity_stddev_;
345 std::unordered_map<core::Identifier, PhysicalActivityModel> physical_activity_models_;
346 bool has_physical_activity_models_ =
false;
348 std::vector<IncomeStratumExpectedTableEntry> income_stratum_expected_tables_;
349 bool income_stratum_adjustment_enabled_{
false};
350 std::size_t adjustment_income_stratum_count_{0};
352 bool has_active_policies_;
356 const std::vector<LinearModelParams> &logistic_models_;
401 std::unique_ptr<RiskFactorSexAgeTable> expected,
402 std::unique_ptr<std::unordered_map<core::Identifier, double>> expected_trend,
403 std::unique_ptr<std::unordered_map<core::Identifier, int>> trend_steps,
404 std::unique_ptr<std::unordered_map<core::Identifier, double>> expected_trend_boxcox,
405 std::vector<core::Identifier> names, std::vector<LinearModelParams> models,
406 std::vector<core::DoubleInterval> ranges, std::vector<double> lambda,
407 std::vector<double> stddev, Eigen::MatrixXd cholesky,
408 std::vector<LinearModelParams> policy_models,
409 std::vector<core::DoubleInterval> policy_ranges, Eigen::MatrixXd policy_cholesky,
410 std::unique_ptr<std::vector<LinearModelParams>> trend_models,
411 std::unique_ptr<std::vector<core::DoubleInterval>> trend_ranges,
412 std::unique_ptr<std::vector<double>> trend_lambda,
double info_speed,
413 std::unordered_map<
core::Identifier, std::unordered_map<core::Gender, double>>
415 std::unordered_map<core::Income, LinearModelParams> income_models,
417 std::unique_ptr<std::unordered_map<core::Identifier, double>> expected_income_trend =
419 std::unique_ptr<std::unordered_map<core::Identifier, double>> expected_income_trend_boxcox =
421 std::unique_ptr<std::unordered_map<core::Identifier, int>> income_trend_steps =
nullptr,
422 std::unique_ptr<std::vector<LinearModelParams>> income_trend_models =
nullptr,
423 std::unique_ptr<std::vector<core::DoubleInterval>> income_trend_ranges =
nullptr,
424 std::unique_ptr<std::vector<double>> income_trend_lambda =
nullptr,
425 std::unique_ptr<std::unordered_map<core::Identifier, double>> income_trend_decay_factors =
427 bool is_continuous_income_model =
false,
430 const std::unordered_map<core::Identifier, PhysicalActivityModel>
431 &physical_activity_models = {},
432 const std::vector<IncomeStratumExpectedTableEntry> &income_stratum_expected_tables = {},
433 bool income_stratum_adjustment_enabled =
false,
434 std::size_t adjustment_income_stratum_count = 0u,
bool has_active_policies =
true,
436 std::vector<LinearModelParams> logistic_models = {},
441 std::unique_ptr<RiskFactorModel>
create_model()
const override;
445 std::shared_ptr<std::unordered_map<core::Identifier, double>> expected_trend_;
446 std::shared_ptr<std::unordered_map<core::Identifier, double>> expected_trend_boxcox_;
447 std::shared_ptr<std::vector<LinearModelParams>> trend_models_;
448 std::shared_ptr<std::vector<core::DoubleInterval>> trend_ranges_;
449 std::shared_ptr<std::vector<double>> trend_lambda_;
453 std::shared_ptr<std::unordered_map<core::Identifier, double>> expected_income_trend_;
454 std::shared_ptr<std::unordered_map<core::Identifier, double>> expected_income_trend_boxcox_;
455 std::shared_ptr<std::unordered_map<core::Identifier, int>> income_trend_steps_;
456 std::shared_ptr<std::vector<LinearModelParams>> income_trend_models_;
457 std::shared_ptr<std::vector<core::DoubleInterval>> income_trend_ranges_;
458 std::shared_ptr<std::vector<double>> income_trend_lambda_;
459 std::shared_ptr<std::unordered_map<core::Identifier, double>> income_trend_decay_factors_;
462 std::vector<core::Identifier> names_;
463 std::vector<LinearModelParams> models_;
464 std::vector<core::DoubleInterval> ranges_;
465 std::vector<double> lambda_;
466 std::vector<double> stddev_;
467 Eigen::MatrixXd cholesky_;
468 std::vector<LinearModelParams> policy_models_;
469 std::vector<core::DoubleInterval> policy_ranges_;
470 Eigen::MatrixXd policy_cholesky_;
472 std::unordered_map<core::Identifier, std::unordered_map<core::Gender, double>>
474 std::unordered_map<core::Income, LinearModelParams> income_models_;
475 double physical_activity_stddev_;
478 std::unordered_map<core::Identifier, PhysicalActivityModel> physical_activity_models_;
479 bool has_physical_activity_models_ =
false;
481 std::vector<IncomeStratumExpectedTableEntry> income_stratum_expected_tables_;
482 bool income_stratum_adjustment_enabled_{
false};
483 std::size_t adjustment_income_stratum_count_{0};
486 std::vector<LinearModelParams> logistic_models_;
489 bool is_continuous_income_model_;
493 bool has_active_policies_;
Defines the Simulation runtime context data type.
Definition runtime_context.h:22