Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
hgps::input Namespace Reference

Data structures containing model parameters and configuration options. More...

Classes

struct  Array2Info
 
struct  BaselineInfo
 Baseline adjustment information. More...
 
struct  CoefficientInfo
 
struct  Configuration
 Defines the application configuration data structure. More...
 
class  ConfigurationError
 Represents an error that occurred with the format of a config file. More...
 
class  DataManager
 Implements Health-GPS back-end data store interface using a file-based storage. More...
 
class  DataSource
 Represents a data source, either a file/directory path or a URL. More...
 
struct  FactorDynamicEquationInfo
 
struct  FileInfo
 Information about a data file to be loaded. More...
 
struct  HierarchicalLevelInfo
 
struct  HierarchicalModelInfo
 
struct  IncomeStratumFactorsMeanConfig
 
struct  IncomeStratumFactorsMeanStratumEntry
 
struct  IndividualIdTrackingConfig
 
struct  LinearModelInfo
 
struct  LiteHierarchicalModelInfo
 
struct  ModellingInfo
 User-defined model and parameter information. More...
 
struct  OutputInfo
 Experiment output folder and file information. More...
 
class  PIFData
 PIF data container for multiple scenarios. More...
 
struct  PIFDataItem
 PIF data item for a specific age, gender, and time. More...
 
struct  PIFInfo
 Population Impact Fraction (PIF) configuration. More...
 
class  PIFTable
 PIF data table for a specific disease-risk factor-scenario combination. More...
 
struct  PolicyAdjustmentInfo
 Extra adjustments made to a policy. More...
 
struct  PolicyImpactInfo
 Information about policy impacts. More...
 
struct  PolicyPeriodInfo
 Information about the period over which a policy is applied. More...
 
struct  PolicyScenarioInfo
 Information about an active policy intervention. More...
 
struct  ProjectRequirements
 
struct  RiskFactorInfo
 Information about a health risk factor. More...
 
struct  SESInfo
 Socio-economic status (SES) model inputs. More...
 
struct  SettingsInfo
 Experiment's population settings. More...
 
class  ValidatedDataSource
 A data source which is validated with a checksum. More...
 
struct  VariableInfo
 

Typedefs

using json = nlohmann::json
 JSON parser namespace alias.
 

Functions

Configuration get_configuration (const std::string &config_source, const std::optional< std::string > &output_folder, int job_id, bool verbose)
 Loads the input configuration file, *.json, information.
 
std::vector< core::DiseaseInfoget_diseases_info (hgps::core::Datastore &data_api, Configuration &config)
 Gets the collection of diseases that matches the selected input list.
 
ModelInput create_model_input (core::DataTable &input_table, core::Country country, const Configuration &config, std::vector< core::DiseaseInfo > diseases)
 
std::string create_output_file_name (const OutputInfo &info, int job_id)
 Creates the full output file name from user input configuration.
 
std::unique_ptr< hgps::Scenariocreate_baseline_scenario (hgps::SyncChannel &channel)
 Creates the baseline scenario instance.
 
hgps::Simulation create_baseline_simulation (hgps::SyncChannel &channel, hgps::SimulationModuleFactory &factory, std::shared_ptr< const hgps::EventAggregator > event_bus, std::shared_ptr< const hgps::ModelInput > input)
 Creates the baseline simulation engine instance.
 
std::unique_ptr< hgps::Scenariocreate_intervention_scenario (hgps::SyncChannel &channel, const PolicyScenarioInfo &info)
 Creates the intervention scenario instance.
 
hgps::Simulation create_intervention_simulation (hgps::SyncChannel &channel, hgps::SimulationModuleFactory &factory, std::shared_ptr< const hgps::EventAggregator > event_bus, std::shared_ptr< const hgps::ModelInput > input, const PolicyScenarioInfo &info)
 Creates the intervention simulation engine instance.
 
std::string expand_environment_variables (const std::string &path)
 Expand environment variables in path to respective values.
 
std::optional< unsigned int > create_job_seed (int job_id, std::optional< unsigned int > user_seed)
 Creates the experiment random number generator seed.
 
hgps::ModelInput create_model_input (hgps::core::DataTable &input_table, hgps::core::Country country, const Configuration &config, std::vector< hgps::core::DiseaseInfo > diseases)
 Creates Health-GPS inputs instance from configuration.
 
nlohmann::json get (const nlohmann::json &j, const std::string &key)
 Load value from JSON, printing an error message if it fails.
 
void rebase_valid_path (std::filesystem::path &path, const std::filesystem::path &base_dir)
 Rebase path on base_dir.
 
bool rebase_valid_path_to (const nlohmann::json &j, const std::string &key, std::filesystem::path &out, const std::filesystem::path &base_dir) noexcept
 Get a valid path from a JSON object.
 
void rebase_valid_path_to (const nlohmann::json &j, const std::string &key, std::filesystem::path &out, const std::filesystem::path &base_dir, bool &success) noexcept
 Get a valid path from a JSON object.
 
FileInfo get_file_info (const nlohmann::json &node, const std::filesystem::path &base_dir)
 Load FileInfo from JSON.
 
SettingsInfo get_settings (const nlohmann::json &j)
 Load settings section of JSON.
 
BaselineInfo get_baseline_info (const nlohmann::json &j, const std::filesystem::path &base_dir)
 Load BaselineInfo from JSON.
 
void load_interventions (const nlohmann::json &running, Configuration &config)
 Load interventions from running section.
 
void check_version (const nlohmann::json &j)
 Check the schema version and throw if invalid.
 
void load_input_info (const nlohmann::json &j, Configuration &config)
 Load input dataset.
 
void load_modelling_info (const nlohmann::json &j, Configuration &config)
 Load ModellingInfo from JSON.
 
void load_running_info (const nlohmann::json &j, Configuration &config)
 Load running section of JSON object.
 
void load_output_info (const nlohmann::json &j, Configuration &config, const std::optional< std::string > &output_folder)
 Load output section of JSON object.
 
template<class T >
bool get_to (const nlohmann::json &j, const std::string &key, T &out) noexcept
 Get value from JSON object and store in out.
 
template<class T >
bool get_to (const nlohmann::json &j, const std::string &key, T &out, bool &success) noexcept
 Get value from JSON object and store in out, setting success flag.
 
void reject_deprecated_root_config_fields (const nlohmann::json &opt)
 Reject deprecated root-level fields when project_requirements is the source of truth.
 
void validate_legacy_trend_type_string (const std::string &trend_type)
 
void apply_legacy_root_config_fields (const nlohmann::json &opt, ProjectRequirements &req)
 Map legacy root-level trend_type / income_categories into project_requirements.
 
void parse_project_requirements_block (const nlohmann::json &pr, ProjectRequirements &req)
 Parse project_requirements block from config.json.
 
hgps::core::DataTable load_datatable_from_csv (const FileInfo &file_info)
 Populates a datatable with the input data file contents.
 
std::unordered_map< hgps::core::Identifier, std::vector< double > > load_baseline_from_csv (const std::string &filename, const std::string &delimiter=",")
 Loads the contents of baseline adjustments file into a table.
 
void download_file (const std::string &url, const std::filesystem::path &download_path)
 Download the file at the specified URL.
 
std::filesystem::path download_file_to_temporary (const std::string &url, const std::string &file_extension)
 Download the file at the specified URL to a temporary folder.
 
void to_json (json &j, const FileInfo &p)
 
void to_json (json &j, const CoefficientInfo &p)
 
void from_json (const json &j, CoefficientInfo &p)
 
void to_json (json &j, const LinearModelInfo &p)
 
void from_json (const json &j, LinearModelInfo &p)
 
void to_json (json &j, const Array2Info &p)
 
void from_json (const json &j, Array2Info &p)
 
void to_json (json &j, const HierarchicalLevelInfo &p)
 
void from_json (const json &j, HierarchicalLevelInfo &p)
 
void to_json (json &j, const SettingsInfo &p)
 
void from_json (const json &j, SettingsInfo &p)
 
void to_json (json &j, const RiskFactorInfo &p)
 
void from_json (const json &j, RiskFactorInfo &p)
 
void to_json (json &j, const SESInfo &p)
 
void from_json (const json &j, SESInfo &p)
 
void to_json (json &j, const VariableInfo &p)
 
void from_json (const json &j, VariableInfo &p)
 
void to_json (json &j, const FactorDynamicEquationInfo &p)
 
void from_json (const json &j, FactorDynamicEquationInfo &p)
 
void to_json (json &j, const IncomeStratumFactorsMeanStratumEntry &p)
 
void to_json (json &j, const IncomeStratumFactorsMeanConfig &p)
 
void to_json (json &j, const BaselineInfo &p)
 
void to_json (json &j, const PolicyPeriodInfo &p)
 
void from_json (const json &j, PolicyPeriodInfo &p)
 
void to_json (json &j, const PolicyImpactInfo &p)
 
void from_json (const json &j, PolicyImpactInfo &p)
 
void to_json (json &j, const PolicyAdjustmentInfo &p)
 
void from_json (const json &j, PolicyAdjustmentInfo &p)
 
void to_json (json &j, const PolicyScenarioInfo &p)
 
void from_json (const json &j, PolicyScenarioInfo &p)
 
void to_json (json &j, const IndividualIdTrackingConfig &p)
 
void from_json (const json &j, IndividualIdTrackingConfig &p)
 
void to_json (json &j, const OutputInfo &p)
 
void from_json (const json &j, OutputInfo &p)
 
nlohmann::json load_json (const std::filesystem::path &filepath)
 Load and parse a JSON model file.
 
std::unique_ptr< hgps::RiskFactorSexAgeTableload_risk_factor_expected (const Configuration &config)
 Loads risk factor expected values from a file.
 
std::unique_ptr< hgps::DummyModelDefinitionload_dummy_risk_model_definition (hgps::RiskFactorModelType type, const nlohmann::json &opt)
 Loads either a static or dynamic dummy risk factor model from a JSON file.
 
std::unique_ptr< hgps::StaticHierarchicalLinearModelDefinitionload_hlm_risk_model_definition (const nlohmann::json &opt)
 Loads the full hierarchical linear regression model definition from a JSON file.
 
std::unique_ptr< hgps::StaticLinearModelDefinitionload_staticlinear_risk_model_definition (const nlohmann::json &opt, const Configuration &config)
 Loads the static linear regression model definition from a JSON file.
 
std::unique_ptr< hgps::DynamicHierarchicalLinearModelDefinitionload_ebhlm_risk_model_definition (const nlohmann::json &opt, const Configuration &config)
 Loads the old energy balance model definition from a JSON file.
 
std::unique_ptr< hgps::KevinHallModelDefinitionload_kevinhall_risk_model_definition (const nlohmann::json &opt, const Configuration &config)
 Loads the Kevin Hall energy balance model definition from a JSON file.
 
std::unique_ptr< hgps::RiskFactorModelDefinitionload_risk_model_definition (hgps::RiskFactorModelType model_type, const std::filesystem::path &model_path, const Configuration &config)
 Loads a risk model definition from a JSON file.
 
void register_risk_factor_model_definitions (hgps::CachedRepository &repository, const Configuration &config)
 Registers a risk factor model definition with the repository.
 
void validate_json (std::istream &is, const std::string &schema_file_name, int schema_version)
 Validate a JSON stream against the specified schema.
 
nlohmann::json load_and_validate_json (const std::filesystem::path &file_path, const std::string &schema_file_name, int schema_version, bool require_schema_property=true)
 Load a JSON file and validate against the specified schema.
 
std::filesystem::path get_zip_cache_directory (const std::string &file_hash)
 Get cache directory for extracting a file into.
 
void extract_zip_file (const std::filesystem::path &file_path, const std::filesystem::path &output_directory)
 Extract a zip file to the specified location.
 

Detailed Description

Data structures containing model parameters and configuration options.

POCO stands for "plain old class object". These structs represent data structures which are contained in JSON-formatted configuration files.

Typedef Documentation

◆ json

typedef nlohmann::json hgps::input::json

JSON parser namespace alias.

Function Documentation

◆ apply_legacy_root_config_fields()

void hgps::input::apply_legacy_root_config_fields ( const nlohmann::json &  opt,
ProjectRequirements req 
)
inline

Map legacy root-level trend_type / income_categories into project_requirements.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_version()

void hgps::input::check_version ( const nlohmann::json &  j)

Check the schema version and throw if invalid.

Parameters
jThe root JSON object
Exceptions
ConfigurationErrorIf version attribute is not present or invalid
Here is the call graph for this function:

◆ create_baseline_scenario()

std::unique_ptr< hgps::Scenario > hgps::input::create_baseline_scenario ( hgps::SyncChannel channel)

Creates the baseline scenario instance.

Parameters
channelSynchronization channel instance for data exchange
Returns
The baseline scenario instance
Here is the caller graph for this function:

◆ create_baseline_simulation()

hgps::Simulation hgps::input::create_baseline_simulation ( hgps::SyncChannel channel,
hgps::SimulationModuleFactory factory,
std::shared_ptr< const hgps::EventAggregator event_bus,
std::shared_ptr< const hgps::ModelInput input 
)

Creates the baseline simulation engine instance.

Parameters
channelSynchronization channel for data exchange instance
factorySimulation module factory instance
event_busShared event bus instance for streaming messages
inputModel inputs instance
Returns
The respective simulation engine instance
Here is the call graph for this function:

◆ create_intervention_scenario()

std::unique_ptr< hgps::Scenario > hgps::input::create_intervention_scenario ( hgps::SyncChannel channel,
const PolicyScenarioInfo info 
)

Creates the intervention scenario instance.

Parameters
channelSynchronization channel instance for data exchange
infoIntervention configuration information
Returns
The respective intervention scenario instance
Exceptions
std::invalid_argumentThrown if intervention identifier is unknown.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_intervention_simulation()

hgps::Simulation hgps::input::create_intervention_simulation ( hgps::SyncChannel channel,
hgps::SimulationModuleFactory factory,
std::shared_ptr< const hgps::EventAggregator event_bus,
std::shared_ptr< const hgps::ModelInput input,
const PolicyScenarioInfo info 
)

Creates the intervention simulation engine instance.

Parameters
channelSynchronization channel for data exchange instance
factorySimulation module factory instance
event_busShared event bus instance for streaming messages
inputModel inputs instance
infoIntervention policy definition
Returns
The respective simulation engine instance
Here is the call graph for this function:

◆ create_job_seed()

std::optional< unsigned int > hgps::input::create_job_seed ( int  job_id,
std::optional< unsigned int >  user_seed 
)

Creates the experiment random number generator seed.

Parameters
job_idOptional batch job identifier
user_seedUser input custom seed for experiment
Returns
The experiment seed, if user provide a seed
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_model_input() [1/2]

ModelInput hgps::input::create_model_input ( core::DataTable input_table,
core::Country  country,
const Configuration config,
std::vector< core::DiseaseInfo diseases 
)
Here is the call graph for this function:

◆ create_model_input() [2/2]

hgps::ModelInput hgps::input::create_model_input ( hgps::core::DataTable input_table,
hgps::core::Country  country,
const Configuration config,
std::vector< hgps::core::DiseaseInfo diseases 
)

Creates Health-GPS inputs instance from configuration.

Parameters
input_tableThe input dataset instance
countryTarget country information
configUser input configuration instance
diseasesSelected diseases for experiment
Returns
The respective model input instance

◆ create_output_file_name()

std::string hgps::input::create_output_file_name ( const OutputInfo info,
int  job_id 
)

Creates the full output file name from user input configuration.

Parameters
infoUser output information, may contain relative path and environment variables
job_idSimulation job identifier
Returns
Output file full name
Here is the call graph for this function:

◆ download_file()

void hgps::input::download_file ( const std::string &  url,
const std::filesystem::path &  download_path 
)

Download the file at the specified URL.

Parameters
urlURL to download from
download_pathDestination for downloaded files, including filename
Here is the caller graph for this function:

◆ download_file_to_temporary()

std::filesystem::path hgps::input::download_file_to_temporary ( const std::string &  url,
const std::string &  file_extension 
)

Download the file at the specified URL to a temporary folder.

Parameters
urlURL to download from
file_extensionFile extension (including dot) for downloaded file
Returns
Path to downloaded file
Here is the call graph for this function:

◆ expand_environment_variables()

std::string hgps::input::expand_environment_variables ( const std::string &  path)

Expand environment variables in path to respective values.

Parameters
pathThe source path to information
Returns
The resulting full path
Here is the call graph for this function:
Here is the caller graph for this function:

◆ extract_zip_file()

void hgps::input::extract_zip_file ( const std::filesystem::path &  file_path,
const std::filesystem::path &  output_directory 
)

Extract a zip file to the specified location.

Parameters
file_pathThe path to the zip file
output_directoryThe path to the output folder
Here is the caller graph for this function:

◆ from_json() [1/15]

void hgps::input::from_json ( const json j,
Array2Info p 
)

◆ from_json() [2/15]

void hgps::input::from_json ( const json j,
CoefficientInfo p 
)

◆ from_json() [3/15]

void hgps::input::from_json ( const json j,
FactorDynamicEquationInfo p 
)

◆ from_json() [4/15]

void hgps::input::from_json ( const json j,
HierarchicalLevelInfo p 
)

◆ from_json() [5/15]

void hgps::input::from_json ( const json j,
IndividualIdTrackingConfig p 
)

◆ from_json() [6/15]

void hgps::input::from_json ( const json j,
LinearModelInfo p 
)

◆ from_json() [7/15]

void hgps::input::from_json ( const json j,
OutputInfo p 
)
Here is the call graph for this function:

◆ from_json() [8/15]

void hgps::input::from_json ( const json j,
PolicyAdjustmentInfo p 
)

◆ from_json() [9/15]

void hgps::input::from_json ( const json j,
PolicyImpactInfo p 
)

◆ from_json() [10/15]

void hgps::input::from_json ( const json j,
PolicyPeriodInfo p 
)

◆ from_json() [11/15]

void hgps::input::from_json ( const json j,
PolicyScenarioInfo p 
)

◆ from_json() [12/15]

void hgps::input::from_json ( const json j,
RiskFactorInfo p 
)

◆ from_json() [13/15]

void hgps::input::from_json ( const json j,
SESInfo p 
)

◆ from_json() [14/15]

void hgps::input::from_json ( const json j,
SettingsInfo p 
)

◆ from_json() [15/15]

void hgps::input::from_json ( const json j,
VariableInfo p 
)

◆ get()

nlohmann::json hgps::input::get ( const nlohmann::json &  j,
const std::string &  key 
)

Load value from JSON, printing an error message if it fails.

Parameters
jJSON object
keyKey to value
Exceptions
ConfigurationErrorKey not found
Returns
Key value
Here is the caller graph for this function:

◆ get_baseline_info()

BaselineInfo hgps::input::get_baseline_info ( const nlohmann::json &  j,
const std::filesystem::path &  base_dir 
)

Load BaselineInfo from JSON.

Parameters
jInput JSON
base_dirBase folder
Returns
BaselineInfo
Exceptions
ConfigurationErrorOne or more files could not be found
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_configuration()

Configuration hgps::input::get_configuration ( const std::string &  config_source,
const std::optional< std::string > &  output_folder,
int  job_id,
bool  verbose 
)

Loads the input configuration file, *.json, information.

Parameters
config_sourcePath/URL for config source
output_folderPath to output folder, if provided via command-line argument
job_idJob ID (for HPC)
verboseSet log verbosity for simulation
Returns
The configuration file information
Here is the call graph for this function:

◆ get_diseases_info()

std::vector< hgps::core::DiseaseInfo > hgps::input::get_diseases_info ( hgps::core::Datastore data_api,
Configuration config 
)

Gets the collection of diseases that matches the selected input list.

Parameters
data_apiThe back-end data store instance to be used.
configUser configuration file instance
Returns
Collection of matching diseases information
Here is the call graph for this function:

◆ get_file_info()

FileInfo hgps::input::get_file_info ( const nlohmann::json &  node,
const std::filesystem::path &  base_dir 
)

Load FileInfo from JSON.

Parameters
nodeThe node of the JSON object containing the FileInfo
base_dirBase folder
Returns
FileInfo
Exceptions
ConfigurationErrorInvalid config file format
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_settings()

SettingsInfo hgps::input::get_settings ( const nlohmann::json &  j)

Load settings section of JSON.

Parameters
jInput JSON
Returns
SettingsInfo
Exceptions
ConfigurationErrorCould not load settings
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_to() [1/2]

template<class T >
bool hgps::input::get_to ( const nlohmann::json &  j,
const std::string &  key,
T &  out 
)
noexcept

Get value from JSON object and store in out.

Template Parameters
TType of output object
Parameters
jJSON object
keyKey to value
outOutput object
Returns
True if value was retrieved successfully, false otherwise
Here is the caller graph for this function:

◆ get_to() [2/2]

template<class T >
bool hgps::input::get_to ( const nlohmann::json &  j,
const std::string &  key,
T &  out,
bool &  success 
)
noexcept

Get value from JSON object and store in out, setting success flag.

Template Parameters
TType of output object
Parameters
jJSON object
keyKey to value
outOutput object
successSuccess flag, set to false in case of failure
Returns
True if value was retrieved successfully, false otherwise
Here is the call graph for this function:

◆ get_zip_cache_directory()

std::filesystem::path hgps::input::get_zip_cache_directory ( const std::string &  file_hash)

Get cache directory for extracting a file into.

Parameters
file_hashThe SHA256 hash of the file
Returns
The path to the directory
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_and_validate_json()

nlohmann::json hgps::input::load_and_validate_json ( const std::filesystem::path &  file_path,
const std::string &  schema_file_name,
int  schema_version,
bool  require_schema_property = true 
)

Load a JSON file and validate against the specified schema.

Parameters
file_pathThe path to the JSON file
schema_file_nameThe name of the JSON schema file
schema_versionThe version of the schema file
require_schema_propertyWhether to raise an exception if the $schema property is missing
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_baseline_from_csv()

std::unordered_map< hgps::core::Identifier, std::vector< double > > hgps::input::load_baseline_from_csv ( const std::string &  filename,
const std::string &  delimiter = "," 
)

Loads the contents of baseline adjustments file into a table.

Parameters
filenameThe baseline adjustment file full path
delimiterThe data file's columns delimiter character
Returns
The fully populated table
Here is the call graph for this function:

◆ load_datatable_from_csv()

hgps::core::DataTable hgps::input::load_datatable_from_csv ( const FileInfo file_info)

Populates a datatable with the input data file contents.

Remarks
The datatable is used for checking the initial virtual population against the input data only and is not used as part of the simulation algorithm. If an external test can be used, this table could be dropped from the inputs.
Parameters
file_infoThe input data file information object
Returns
The datatable to be populated with the inputs data
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_dummy_risk_model_definition()

std::unique_ptr< hgps::DummyModelDefinition > hgps::input::load_dummy_risk_model_definition ( hgps::RiskFactorModelType  type,
const nlohmann::json &  opt 
)

Loads either a static or dynamic dummy risk factor model from a JSON file.

Parameters
typeModel type (static or dynamic)
optThe parsed model definition JSON file
Returns
An instance of the hgps::DummyModelDefinition type
Exceptions
std::invalid_argumentif error parsing model configuration file
Here is the caller graph for this function:

◆ load_ebhlm_risk_model_definition()

std::unique_ptr< hgps::DynamicHierarchicalLinearModelDefinition > hgps::input::load_ebhlm_risk_model_definition ( const nlohmann::json &  opt,
const Configuration config 
)

Loads the old energy balance model definition from a JSON file.

Parameters
optThe parsed model definition JSON file
Returns
An instance of the hgps::DynamicHierarchicalLinearModelDefinition type
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_hlm_risk_model_definition()

std::unique_ptr< hgps::StaticHierarchicalLinearModelDefinition > hgps::input::load_hlm_risk_model_definition ( const nlohmann::json &  opt)

Loads the full hierarchical linear regression model definition from a JSON file.

Parameters
optThe parsed model definition JSON file
Returns
An instance of the hgps::StaticHierarchicalLinearModelDefinition type
Exceptions
std::invalid_argumentif static model is unrecognised
Here is the caller graph for this function:

◆ load_input_info()

void hgps::input::load_input_info ( const nlohmann::json &  j,
Configuration config 
)

Load input dataset.

Parameters
jThe root JSON object
configThe config object to update
Exceptions
ConfigurationErrorCould not load input dataset
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_interventions()

void hgps::input::load_interventions ( const nlohmann::json &  running,
Configuration config 
)

Load interventions from running section.

Parameters
runningRunning section of JSON object
configConfig object to update
Exceptions
ConfigurationErrorCould not load interventions
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_json()

nlohmann::json hgps::input::load_json ( const std::filesystem::path &  filepath)

Load and parse a JSON model file.

Parameters
model_pathThe path to the model file
Returns
The parsed JSON
Exceptions
std::invalid_argumentif file is missing

◆ load_kevinhall_risk_model_definition()

std::unique_ptr< hgps::KevinHallModelDefinition > hgps::input::load_kevinhall_risk_model_definition ( const nlohmann::json &  opt,
const Configuration config 
)

Loads the Kevin Hall energy balance model definition from a JSON file.

Parameters
optThe parsed model definition JSON file
configThe model configuration
Returns
An instance of the hgps::KevinHallModelDefinition type
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_modelling_info()

void hgps::input::load_modelling_info ( const nlohmann::json &  j,
Configuration config 
)

Load ModellingInfo from JSON.

Parameters
jThe root JSON object
configThe config object to update
Exceptions
ConfigurationErrorCould not load modelling info
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_output_info()

void hgps::input::load_output_info ( const nlohmann::json &  j,
Configuration config,
const std::optional< std::string > &  output_folder 
)

Load output section of JSON object.

Parameters
jThe root JSON object
configThe config object to update
output_folderOutput folder, if provided via command-line argument
Exceptions
ConfigurationErrorCould not load output info
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_risk_factor_expected()

std::unique_ptr< hgps::RiskFactorSexAgeTable > hgps::input::load_risk_factor_expected ( const Configuration config)

Loads risk factor expected values from a file.

Parameters
configThe model configuration
Returns
An instance of the hgps::RiskFactorSexAgeTable type
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_risk_model_definition()

std::unique_ptr< hgps::RiskFactorModelDefinition > hgps::input::load_risk_model_definition ( hgps::RiskFactorModelType  model_type,
const std::filesystem::path &  model_path,
const Configuration config 
)

Loads a risk model definition from a JSON file.

Parameters
model_typeThe type of model to load
model_pathThe path to the model configuration file
configThe model configuration
Returns
The model definition
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_running_info()

void hgps::input::load_running_info ( const nlohmann::json &  j,
Configuration config 
)

Load running section of JSON object.

Parameters
jThe root JSON object
configThe config object to update
Exceptions
ConfigurationErrorCould not load running section
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_staticlinear_risk_model_definition()

std::unique_ptr< hgps::StaticLinearModelDefinition > hgps::input::load_staticlinear_risk_model_definition ( const nlohmann::json &  opt,
const Configuration config 
)

Loads the static linear regression model definition from a JSON file.

Parameters
optThe parsed model definition JSON file
configThe model configuration
Returns
An instance of the hgps::StaticLinearModelDefinition type
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_project_requirements_block()

void hgps::input::parse_project_requirements_block ( const nlohmann::json &  pr,
ProjectRequirements req 
)
inline

Parse project_requirements block from config.json.

Here is the caller graph for this function:

◆ rebase_valid_path()

void hgps::input::rebase_valid_path ( std::filesystem::path &  path,
const std::filesystem::path &  base_dir 
)

Rebase path on base_dir.

Parameters
pathInitial path (relative or absolute)
base_dirNew base directory for relative path
Exceptions
ConfigurationErrorIf path does not exist
Here is the caller graph for this function:

◆ rebase_valid_path_to() [1/2]

bool hgps::input::rebase_valid_path_to ( const nlohmann::json &  j,
const std::string &  key,
std::filesystem::path &  out,
const std::filesystem::path &  base_dir 
)
noexcept

Get a valid path from a JSON object.

Parameters
jJSON object
keyKey to value
base_dirBase directory for relative path
outOutput variable
Returns
True if value was retrieved successfully and is valid path, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rebase_valid_path_to() [2/2]

void hgps::input::rebase_valid_path_to ( const nlohmann::json &  j,
const std::string &  key,
std::filesystem::path &  out,
const std::filesystem::path &  base_dir,
bool &  success 
)
noexcept

Get a valid path from a JSON object.

Parameters
jJSON object
keyKey to value
base_dirBase directory for relative path
outOutput variable
successSuccess flag, set to false in case of failure
Here is the call graph for this function:

◆ register_risk_factor_model_definitions()

void hgps::input::register_risk_factor_model_definitions ( hgps::CachedRepository repository,
const Configuration config 
)

Registers a risk factor model definition with the repository.

Parameters
repositoryThe repository instance to register
configThe model configuration
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reject_deprecated_root_config_fields()

void hgps::input::reject_deprecated_root_config_fields ( const nlohmann::json &  opt)
inline

Reject deprecated root-level fields when project_requirements is the source of truth.

Here is the caller graph for this function:

◆ to_json() [1/19]

void hgps::input::to_json ( json j,
const Array2Info p 
)

◆ to_json() [2/19]

void hgps::input::to_json ( json j,
const BaselineInfo p 
)

◆ to_json() [3/19]

void hgps::input::to_json ( json j,
const CoefficientInfo p 
)

◆ to_json() [4/19]

void hgps::input::to_json ( json j,
const FactorDynamicEquationInfo p 
)

◆ to_json() [5/19]

void hgps::input::to_json ( json j,
const FileInfo p 
)
Here is the caller graph for this function:

◆ to_json() [6/19]

void hgps::input::to_json ( json j,
const HierarchicalLevelInfo p 
)

◆ to_json() [7/19]

void hgps::input::to_json ( json j,
const IncomeStratumFactorsMeanConfig p 
)

◆ to_json() [8/19]

void hgps::input::to_json ( json j,
const IncomeStratumFactorsMeanStratumEntry p 
)

◆ to_json() [9/19]

void hgps::input::to_json ( json j,
const IndividualIdTrackingConfig p 
)

◆ to_json() [10/19]

void hgps::input::to_json ( json j,
const LinearModelInfo p 
)

◆ to_json() [11/19]

void hgps::input::to_json ( json j,
const OutputInfo p 
)
Here is the call graph for this function:

◆ to_json() [12/19]

void hgps::input::to_json ( json j,
const PolicyAdjustmentInfo p 
)

◆ to_json() [13/19]

void hgps::input::to_json ( json j,
const PolicyImpactInfo p 
)
Here is the call graph for this function:

◆ to_json() [14/19]

void hgps::input::to_json ( json j,
const PolicyPeriodInfo p 
)
Here is the call graph for this function:

◆ to_json() [15/19]

void hgps::input::to_json ( json j,
const PolicyScenarioInfo p 
)
Here is the call graph for this function:

◆ to_json() [16/19]

void hgps::input::to_json ( json j,
const RiskFactorInfo p 
)

◆ to_json() [17/19]

void hgps::input::to_json ( json j,
const SESInfo p 
)

◆ to_json() [18/19]

void hgps::input::to_json ( json j,
const SettingsInfo p 
)

◆ to_json() [19/19]

void hgps::input::to_json ( json j,
const VariableInfo p 
)

◆ validate_json()

void hgps::input::validate_json ( std::istream &  is,
const std::string &  schema_file_name,
int  schema_version 
)

Validate a JSON stream against the specified schema.

Parameters
isThe input stream for the JSON file
schema_file_nameThe name of the JSON schema file
schema_versionThe version of the schema file
Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_legacy_trend_type_string()

void hgps::input::validate_legacy_trend_type_string ( const std::string &  trend_type)
inline
Here is the caller graph for this function: