Utopia 2
Framework for studying models of complex & adaptive systems.
Loading...
Searching...
No Matches
Typedefs | Functions
Utopia::Models::Environment::ParameterFunctionCollection Namespace Reference

Typedefs

using Config = DataIO::Config
 Configuration node type alias.
 

Functions

template<typename EnvModel , class DistType , class EnvParamFunc = typename EnvModel::EnvParamFunc>
EnvParamFunc build_rng_env_param_func (const EnvModel &model, DistType &&dist, const std::string &param_name, const ValMode &mode)
 Create a rule function that uses a random number distribution.
 
template<typename EnvModel , class EnvParamFunc = typename EnvModel::EnvParamFunc>
EnvParamFunc epf_increment (const EnvModel &model, const std::string param_name, const Config &cfg)
 Creates a rule function for incrementing parameter values.
 
template<typename EnvModel , class EnvParamFunc = typename EnvModel::EnvParamFunc>
EnvParamFunc epf_random (const EnvModel &model, const std::string &param_name, const Config &cfg)
 Creates a rule function for random parameter values.
 
template<typename EnvModel , class EnvParamFunc = typename EnvModel::EnvParamFunc>
EnvParamFunc epf_rectangular (const EnvModel &model, const Config &cfg)
 Creates a rule function for rectangular function like parameter values.
 
template<typename EnvModel , class EnvParamFunc = typename EnvModel::EnvParamFunc>
EnvParamFunc epf_set (const EnvModel &, const Config &cfg)
 Creates a rule function for setting a parameter value.
 
template<typename EnvModel , class EnvParamFunc = typename EnvModel::EnvParamFunc>
EnvParamFunc epf_sinusoidal (const EnvModel &model, const Config &cfg)
 Creates a rule function for sinusoidal parameter values.
 

Typedef Documentation

◆ Config

Configuration node type alias.

Function Documentation

◆ build_rng_env_param_func()

template<typename EnvModel , class DistType , class EnvParamFunc = typename EnvModel::EnvParamFunc>
EnvParamFunc Utopia::Models::Environment::ParameterFunctionCollection::build_rng_env_param_func ( const EnvModel model,
DistType &&  dist,
const std::string &  param_name,
const ValMode mode 
)

Create a rule function that uses a random number distribution.

This constructs a mutable EnvParamFunc lambda, moving the dist into the capture.

28{
29 // NOTE It is VITAL to move-construct the perfectly-forwarded dist into
30 // the lambda; otherwise it has to be stored outside, which is a
31 // real pita. Also, the lambda has to be declared mutable such
32 // that the captured object are allowed to be changed; again, this
33 // is only relevant for the distribution's internal state ...
34 return
35 [&model, param_name, mode, dist{std::move(dist)}] () mutable {
36 double current_value = 0.;
37 if (mode == ValMode::Add) {
38 current_value = model.get_parameter(param_name);
39 }
40 const double rn = dist(*model.get_rng());
41
42 return current_value + rn;
43 };
44}