Health-GPS  1.2.2.0
Global Health Policy Simulation model (Health-GPS)
host Namespace Reference

Top-level namespace for Health-GPS Console host application. More...

Namespaces

 detail
 Internal details namespace for private data types and functions.
 
 poco
 Plain old class object (POCO) types for loading configuration file.
 

Classes

class  EventMonitor
 Defined the event monitor class used for processing Health-GPS event messages. More...
 
struct  ExperimentInfo
 Simulation experiment run-time information for reproducibility. More...
 
struct  CommandOptions
 Defines the Command Line Interface (CLI) arguments options. More...
 
struct  Configuration
 Defines the application configuration data structure. More...
 
class  ResultFileWriter
 Defines the results message file stream writer class. More...
 
class  ResultWriter
 Defines the Health-GPS results message writer interface. More...
 

Functions

std::string get_time_now_str ()
 Get a string representation of current system time. More...
 
cxxopts::Options create_options ()
 Creates the command-line interface (CLI) options. More...
 
void print_app_title ()
 Prints application start-up messages. More...
 
CommandOptions parse_arguments (cxxopts::Options &options, int &argc, char *argv[])
 Parses the command-line interface (CLI) arguments. More...
 
Configuration load_configuration (CommandOptions &options)
 Loads the input configuration file, *.json, information. More...
 
bool create_output_folder (std::filesystem::path folder_path, unsigned int num_retries=3)
 Creates the configuration output folder for result files. More...
 
std::vector< core::DiseaseInfoget_diseases_info (hgps::core::Datastore &data_api, Configuration &config)
 Gets the collection of diseases that matches the selected input list. More...
 
ModelInput create_model_input (core::DataTable &input_table, core::Country country, Configuration &config, std::vector< core::DiseaseInfo > diseases)
 
std::string create_output_file_name (const poco::OutputInfo &info, int job_id)
 Creates the full output file name from user input configuration. More...
 
ResultFileWriter create_results_file_logger (const Configuration &config, const hgps::ModelInput &input)
 Creates the simulation results file logger instance. More...
 
std::unique_ptr< hgps::Scenariocreate_baseline_scenario (hgps::SyncChannel &channel)
 Creates the baseline scenario instance. More...
 
hgps::HealthGPS create_baseline_simulation (hgps::SyncChannel &channel, hgps::SimulationModuleFactory &factory, hgps::EventAggregator &event_bus, hgps::ModelInput &input)
 Creates the baseline simulation engine instance. More...
 
hgps::HealthGPS create_intervention_simulation (hgps::SyncChannel &channel, hgps::SimulationModuleFactory &factory, hgps::EventAggregator &event_bus, hgps::ModelInput &input, const poco::PolicyScenarioInfo &info)
 Creates the intervention simulation engine instance. More...
 
std::unique_ptr< hgps::InterventionScenariocreate_intervention_scenario (hgps::SyncChannel &channel, const poco::PolicyScenarioInfo &info)
 Creates the intervention scenario instance. More...
 
std::string expand_environment_variables (const std::string &path)
 Expand environment variables in path to respective values. More...
 
std::optional< unsigned int > create_job_seed (int job_id, std::optional< unsigned int > user_seed)
 Creates the experiment random number generator seed. More...
 
hgps::ModelInput create_model_input (hgps::core::DataTable &input_table, hgps::core::Country country, Configuration &config, std::vector< hgps::core::DiseaseInfo > diseases)
 Creates Health-GPS inputs instance from configuration. More...
 
bool load_datatable_from_csv (hc::DataTable &out_table, std::string full_filename, std::map< std::string, std::string > columns, std::string delimiter=",")
 Populates a datatable with the input data file contents. More...
 
std::map< hc::Identifier, std::vector< double > > load_baseline_from_csv (const std::string &full_filename, const std::string delimiter=",")
 Loads the contents of baseline adjustments file into a table. More...
 
hgps::BaselineAdjustment load_baseline_adjustments (const poco::BaselineInfo &info)
 Loads baseline adjustments information from a file. More...
 
std::unique_ptr< hgps::RiskFactorModelDefinitionload_static_risk_model_definition (const std::string &model_name, const poco::json &opt)
 Loads the full hierarchical linear regression model definition from a JSON file. More...
 
std::unique_ptr< hgps::RiskFactorModelDefinitionload_dynamic_risk_model_definition (const std::string &model_name, const poco::json &opt, const poco::SettingsInfo &settings)
 Loads a dynamic model from a JSON file. More...
 
std::unique_ptr< hgps::LiteHierarchicalModelDefinitionload_ebhlm_risk_model_definition (const poco::json &opt)
 Loads the old energy balance model definition from a JSON file. More...
 
std::unique_ptr< hgps::EnergyBalanceModelDefinitionload_newebm_risk_model_definition (const poco::json &opt, const poco::SettingsInfo &settings)
 Loads the new energy balance model definition from a JSON file. More...
 
std::pair< hgps::HierarchicalModelType, std::unique_ptr< hgps::RiskFactorModelDefinition > > load_risk_model_definition (const std::string &model_type, const poco::json &opt, const poco::SettingsInfo &settings)
 Loads a risk model definition from a JSON file. More...
 
poco::json load_json (const std::string &model_filename)
 Load and parse the model file. More...
 
void register_risk_factor_model_definitions (hgps::CachedRepository &repository, const poco::ModellingInfo &info, const poco::SettingsInfo &settings)
 Registers a risk factor model definition with the repository. More...
 

Detailed Description

Top-level namespace for Health-GPS Console host application.

Function Documentation

◆ create_baseline_scenario()

std::unique_ptr< hgps::Scenario > host::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::HealthGPS host::create_baseline_simulation ( hgps::SyncChannel channel,
hgps::SimulationModuleFactory factory,
hgps::EventAggregator event_bus,
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:
Here is the caller graph for this function:

◆ create_intervention_scenario()

std::unique_ptr< hgps::InterventionScenario > host::create_intervention_scenario ( hgps::SyncChannel channel,
const poco::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::HealthGPS host::create_intervention_simulation ( hgps::SyncChannel channel,
hgps::SimulationModuleFactory factory,
hgps::EventAggregator event_bus,
hgps::ModelInput input,
const poco::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:
Here is the caller graph for this function:

◆ create_job_seed()

std::optional< unsigned int > host::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 host::create_model_input ( core::DataTable input_table,
core::Country  country,
Configuration config,
std::vector< core::DiseaseInfo diseases 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_model_input() [2/2]

hgps::ModelInput host::create_model_input ( hgps::core::DataTable input_table,
hgps::core::Country  country,
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_options()

cxxopts::Options host::create_options ( )

Creates the command-line interface (CLI) options.

Returns
Health-GPS CLI options
Here is the caller graph for this function:

◆ create_output_file_name()

std::string host::create_output_file_name ( const poco::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:
Here is the caller graph for this function:

◆ create_output_folder()

bool host::create_output_folder ( std::filesystem::path  folder_path,
unsigned int  num_retries = 3 
)

Creates the configuration output folder for result files.

Parameters
folder_pathFull path to output folder
num_retriesNumber of attempts before giving up
Returns
true for successful creation, otherwise false
Here is the caller graph for this function:

◆ create_results_file_logger()

ResultFileWriter host::create_results_file_logger ( const Configuration config,
const hgps::ModelInput input 
)

Creates the simulation results file logger instance.

Parameters
configUser input configuration information
inputModel input instance
Returns
The respective file writer instance
Here is the call graph for this function:
Here is the caller graph for this function:

◆ expand_environment_variables()

std::string host::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 caller graph for this function:

◆ get_diseases_info()

std::vector< hgps::core::DiseaseInfo > host::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:
Here is the caller graph for this function:

◆ get_time_now_str()

std::string host::get_time_now_str ( )

Get a string representation of current system time.

Returns
The system time as string
Here is the caller graph for this function:

◆ load_baseline_adjustments()

hgps::BaselineAdjustment host::load_baseline_adjustments ( const poco::BaselineInfo info)

Loads baseline adjustments information from a file.

Parameters
infoBaseline file information
Returns
An instance of the hgps::BaselineAdjustment type
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_baseline_from_csv()

std::map< hc::Identifier, std::vector< double > > host::load_baseline_from_csv ( const std::string &  full_filename,
const std::string  delimiter = "," 
)

Loads the contents of baseline adjustments file into a table.

Parameters
full_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:
Here is the caller graph for this function:

◆ load_configuration()

Configuration host::load_configuration ( CommandOptions options)

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

Parameters
optionsUser command-line options
Returns
The configuration file information
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_datatable_from_csv()

bool host::load_datatable_from_csv ( hc::DataTable out_table,
std::string  full_filename,
std::map< std::string, std::string >  columns,
std::string  delimiter = "," 
)

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
[out]out_tableThe datatable to be populated with the inputs data
full_filenameThe input data file full path
columnsThe data file columns data type
delimiterThe data file's columns delimiter character
Returns
true for success, otherwise false.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_dynamic_risk_model_definition()

std::unique_ptr< hgps::RiskFactorModelDefinition > host::load_dynamic_risk_model_definition ( const std::string &  model_name,
const poco::json opt,
const poco::SettingsInfo settings 
)

Loads a dynamic model from a JSON file.

Parameters
model_nameThe name of the model to use
optThe parsed model definition JSON file
settingsThe main model settings
Returns
An instance of the hgps::RiskFactorModelDefinition type
Exceptions
std::invalid_argumentif dynamic model is unrecognised
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_ebhlm_risk_model_definition()

std::unique_ptr< hgps::LiteHierarchicalModelDefinition > host::load_ebhlm_risk_model_definition ( const poco::json opt)

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

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

◆ load_json()

poco::json host::load_json ( const std::string &  model_filename)

Load and parse the model file.

Parameters
model_filenameThe path to the model
Returns
The parsed JSON
Exceptions
std::invalid_argumentif file is missing
Here is the caller graph for this function:

◆ load_newebm_risk_model_definition()

std::unique_ptr< hgps::EnergyBalanceModelDefinition > host::load_newebm_risk_model_definition ( const poco::json opt,
const poco::SettingsInfo settings 
)

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

Parameters
optThe parsed model definition JSON file
settingsThe main model settings
Returns
An instance of the hgps::EnergyBalanceModelDefinition type
Here is the caller graph for this function:

◆ load_risk_model_definition()

std::pair< hgps::HierarchicalModelType, std::unique_ptr< hgps::RiskFactorModelDefinition > > host::load_risk_model_definition ( const std::string &  model_type,
const poco::json opt,
const poco::SettingsInfo settings 
)

Loads a risk model definition from a JSON file.

Parameters
model_typeThe type of model ("dynamic"/"static") to load
optThe parsed model definition JSON file
settingsThe main model settings
Returns
A std::pair containing the model type and model definition
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_static_risk_model_definition()

std::unique_ptr< hgps::RiskFactorModelDefinition > host::load_static_risk_model_definition ( const std::string &  model_name,
const poco::json opt 
)

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

Parameters
model_nameThe name of the model to use
optThe parsed model definition JSON file
Returns
An instance of the hgps::HierarchicalLinearModelDefinition type
Exceptions
std::invalid_argumentif static model is unrecognised
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_arguments()

CommandOptions host::parse_arguments ( cxxopts::Options &  options,
int &  argc,
char *  argv[] 
)

Parses the command-line interface (CLI) arguments.

Parameters
optionsThe valid CLI options
argcNumber of input arguments
argvList of input arguments
Returns
User command-line options
Here is the caller graph for this function:

◆ print_app_title()

void host::print_app_title ( )

Prints application start-up messages.

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

◆ register_risk_factor_model_definitions()

void host::register_risk_factor_model_definitions ( hgps::CachedRepository repository,
const poco::ModellingInfo info,
const poco::SettingsInfo settings 
)

Registers a risk factor model definition with the repository.

Parameters
repositoryThe repository instance to register
infoThe model definition information
settingsThe associated experiment settings
Here is the call graph for this function:
Here is the caller graph for this function: