Utopia 2
Framework for studying models of complex & adaptive systems.
|
A class to use at the top level of the model hierarchy as a mock parent. More...
#include <model.hh>
Public Member Functions | |
PseudoParent (const std::string cfg_path) | |
Constructor that only requires path to a config file. | |
PseudoParent (const std::string cfg_path, const std::string output_path, const int seed=42, const std::string output_file_mode="w", const double emit_interval=5.) | |
Constructor that allows granular control over config parameters. | |
Level | get_level () const |
Return the hierarchical level within the model hierarchy. | |
std::string | get_full_name () const |
Return the full name of the PseudoParent: an empty string. | |
Config | get_cfg () const |
Return the config node of the Pseudo model, i.e. the root node. | |
std::shared_ptr< HDFFile > | get_hdffile () const |
Return a pointer to the HDF data file. | |
std::shared_ptr< HDFGroup > | get_hdfgrp () const |
Return a pointer to the HDF group, which is the base group of the file. | |
Time | get_write_start () const |
Return the parameter that controls when write_data is called first. | |
Time | get_write_every () const |
Return the parameter that controls how often write_data is called. | |
std::shared_ptr< RNG > | get_rng () const |
Return a pointer to the RNG. | |
std::shared_ptr< spdlog::logger > | get_logger () const |
Return a pointer to the logger of this model. | |
Time | get_time_max () const |
The maximum time value as it can be found in the config. | |
std::shared_ptr< MonitorManager > | get_monitor_manager () const |
Return the monitor manager of this model. | |
const Monitor & | get_monitor () const |
Return the monitor of this model. | |
Protected Types | |
using | Config = Utopia::DataIO::Config |
using | HDFFile = Utopia::DataIO::HDFFile |
using | HDFGroup = Utopia::DataIO::HDFGroup |
using | MonitorManager = Utopia::DataIO::MonitorManager |
using | Monitor = Utopia::DataIO::Monitor |
using | Time = std::size_t |
using | Level = std::size_t |
Protected Attributes | |
const Level | _level |
The hierarchical level. | |
const Config | _cfg |
The config node. | |
const std::shared_ptr< HDFFile > | _hdffile |
Pointer to the HDF5 file where data is written to. | |
const std::shared_ptr< RNG > | _rng |
Pointer to a RNG that can be shared between models. | |
const std::shared_ptr< spdlog::logger > | _log |
Pointer to the logger of this (pseudo) model. | |
const std::shared_ptr< MonitorManager > | _monitor_mgr |
The monitor manager. | |
Monitor | _monitor |
The monitor instance of this root model. | |
Private Member Functions | |
void | setup_loggers () const |
Set up the global loggers with levels specified in the config file. | |
void | set_log_level () const |
Set the log level for the pseudo parent from the base_cfg. | |
A class to use at the top level of the model hierarchy as a mock parent.
It is especially useful when initializing a top-level model as the the model constructor that expects a Model-class-like object can be used. This class also takes care to load and hold a configuration file, to create a HDFFile for output, and to initialize a shared RNG. A template parameter exists that allows customization of the RNG class.
RNG | The RNG type to use |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
inline |
Constructor that only requires path to a config file.
From the config file, all necessary information is extracted, i.e.: the path to the output file ('output_path') and the seed of the shared RNG ('seed'). These keys have to be located at the top level of the configuration file.
cfg_path | The path to the YAML-formatted configuration file |
|
inline |
Constructor that allows granular control over config parameters.
cfg_path | The path to the YAML-formatted configuration file |
output_path | Where the HDF5 file is to be located |
seed | The seed the RNG is initialized with (default: 42) |
output_file_mode | The access mode of the HDF5 file (default: w) |
emit_interval | The monitor emit interval (in seconds) |
|
inline |
Return the config node of the Pseudo model, i.e. the root node.
|
inline |
Return the full name of the PseudoParent: an empty string.
|
inline |
Return a pointer to the HDF data file.
|
inline |
Return a pointer to the HDF group, which is the base group of the file.
|
inline |
Return the hierarchical level within the model hierarchy.
|
inline |
Return a pointer to the logger of this model.
|
inline |
Return the monitor of this model.
|
inline |
Return the monitor manager of this model.
|
inline |
Return a pointer to the RNG.
|
inline |
The maximum time value as it can be found in the config.
Currently, this reads the num_steps
key, but this might be changed in the future to allow continuous time steps.
|
inline |
Return the parameter that controls how often write_data is called.
|
inline |
Return the parameter that controls when write_data is called first.
|
inlineprivate |
Set the log level for the pseudo parent from the base_cfg.
|
inlineprivate |
Set up the global loggers with levels specified in the config file.
Extract the following keys from the _cfg
member:
- ``log_levels.core``: the Core module log level; required - ``log_levels.data_io``: the DataIO module log level; required - ``log_levels.data_mngr``: the DataIO::DataManager log level; optional, defaults to ``warn`` - ``log_pattern``: the global log pattern
|
protected |
The config node.
|
protected |
Pointer to the HDF5 file where data is written to.
|
protected |
The hierarchical level.
|
protected |
Pointer to the logger of this (pseudo) model.
Required for passing on the logging level if unspecified for the respective model
|
protected |
The monitor instance of this root model.
|
protected |
The monitor manager.
|
protected |
Pointer to a RNG that can be shared between models.