Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
lms_definition.h
Go to the documentation of this file.
1#pragma once
3#include "weight_category.h"
4
5#include <map>
6#include <stdexcept>
7
8namespace hgps {
9
11struct LmsRecord {
13 double lambda{};
14
16 double mu{};
17
19 double sigma{};
20};
21
23using LmsDataset = std::map<unsigned int, std::map<core::Gender, LmsRecord>>;
24
27 public:
29 LmsDefinition() = default;
30
34 LmsDefinition(LmsDataset &&dataset) : table_{std::move(dataset)} {
35
36 if (table_.empty()) {
37 throw std::invalid_argument("The LMS definition must not be empty.");
38 }
39 }
40
43 bool empty() const noexcept { return table_.empty(); }
44
47 std::size_t size() const noexcept { return table_.size(); }
48
51 unsigned int min_age() const noexcept { return table_.cbegin()->first; }
52
55 unsigned int max_age() const noexcept { return table_.rbegin()->first; }
56
61 bool contains(unsigned int age, core::Gender gender) const noexcept {
62 if (table_.contains(age)) {
63 return table_.at(age).contains(gender);
64 }
65
66 return false;
67 }
68
74 const LmsRecord &at(unsigned int age, core::Gender gender) const {
75 return table_.at(age).at(gender);
76 }
77
78 private:
79 LmsDataset table_{};
80};
81} // namespace hgps
LMS (lambda-mu-sigma) model definition data type.
Definition lms_definition.h:26
unsigned int max_age() const noexcept
Gets the definition maximum age.
Definition lms_definition.h:55
LmsDefinition()=default
Initialises a new instance of the LmsDefinition class.
LmsDefinition(LmsDataset &&dataset)
Initialises a new instance of the LmsDefinition class.
Definition lms_definition.h:34
bool empty() const noexcept
Determine whether the MLS definition is empty.
Definition lms_definition.h:43
bool contains(unsigned int age, core::Gender gender) const noexcept
Determine whether the definition contains a given age by gender.
Definition lms_definition.h:61
std::size_t size() const noexcept
Gets the size of the MLS definition dataset.
Definition lms_definition.h:47
unsigned int min_age() const noexcept
Gets the definition minimum age.
Definition lms_definition.h:51
const LmsRecord & at(unsigned int age, core::Gender gender) const
Gets the model parameters for a given age and gender.
Definition lms_definition.h:74
Gender
Enumerates gender types.
Definition forward_type.h:18
Top-level namespace for Health-GPS Console host application.
Definition command_options.cpp:8
std::map< unsigned int, std::map< core::Gender, LmsRecord > > LmsDataset
Defines the LMS (lambda-mu-sigma) model dataset.
Definition lms_definition.h:23
Global namespace.
Definition column_iterator.h:123
Defines the LMS (lambda-mu-sigma) parameters record data type.
Definition lms_definition.h:11
double lambda
Lambda parameter value.
Definition lms_definition.h:13
double sigma
Sigma parameter value.
Definition lms_definition.h:19
double mu
Mu parameter value.
Definition lms_definition.h:16