Class RunPlanVec

Inheritance Relationships

Base Type

  • private std::vector< RunPlan >

Class Documentation

class RunPlanVec : private std::vector<RunPlan>

Vector of RunPlan Contains additional methods for generating collections of RunPlans and combining RunPlanVecs

Public Functions

explicit RunPlanVec(const ModelDescription &model, unsigned int initial_length)

Constructor, requires the model description to validate environment properties match up

Todo:

Unsure if this will require additional info, e.g. steps?

void setRandomSimulationSeed(const unsigned int &initial_seed, const unsigned int &step = 0)

Set the random simulation seed of each RunPlan currently within this vector

Note

A step of 0, will give the exact same seed to all RunPlans

Parameters
  • initial_seed – The random seed applied to the first item

  • step – The value added to the previous seed to calculate the next seed

void setSteps(const unsigned int &steps)

Set the steps of each RunPlan currently within this vector

Note

If 0 is provided, the model must have an exit condition

Parameters

steps – The number of steps to be executed

void setOutputSubdirectory(const std::string &subdir)

Set the the sub directory within the output directory for outputs of runplans in this vector

Note

Defaults to empty string, where no subdirectory is used

Parameters

subdir – The name of the subdirectory

template<typename T>
void setProperty(const std::string &name, const T &value)

Set named environment property to a specific value

Parameters
  • name – The name of the environment property to set

  • value – The value of the environment property to set

Template Parameters

T – The type of the environment property, this must match the ModelDescription

Throws
template<typename T, EnvironmentManager::size_type N>
void setProperty(const std::string &name, const std::array<T, N> &value)

Set named environment property array to a specific value This version should be used for array properties

Parameters
  • name – Environment property name

  • value – Environment property value (override)

Template Parameters
  • T – Type of the environment property

  • N – Length of the array to be returned

Throws
template<typename T>
void setProperty(const std::string &name, const EnvironmentManager::size_type &index, const T &value)

Array property element equivalent of setProperty()

See

setProperty(const std::string &name, const T &value)

Parameters
  • name – The name of the environment property array to affect

  • index – The index of the environment property array to set

  • value – The value of the environment property array to set

Template Parameters

T – The type of the environment property, this must match the ModelDescription

Throws
  • InvalidEnvProperty – If a property of the name does not exist

  • InvalidEnvPropertyType – If a property with the name has a type different to T

  • std::out_of_range – If index is not in range of the length of the property array

template<typename T>
void setPropertyUniformDistribution(const std::string &name, const T &min, const T &max)

Sweep named environment property over an inclusive uniform distribution value = min * (1.0 - a) + max * a, where a = index/(size()-1)

Parameters
  • name – The name of the environment property to set

  • min – The value to set the first environment property

  • max – The value to set the last environment property

Template Parameters

T – The type of the environment property, this must match the ModelDescription

Throws
  • InvalidEnvProperty – If a property of the name does not exist

  • InvalidEnvPropertyType – If a property with the name has a type different to T, or length > 1

  • std::out_of_range – If this vector has a length less than 2

template<typename T>
void setPropertyUniformDistribution(const std::string &name, const EnvironmentManager::size_type &index, const T &min, const T &max)

Array property element equivalent of setPropertyUniformDistribution() Sweep element of named environment property array over an inclusive uniform distribution value = min * (1.0 - a) + max * a, where a = index/(size()-1)

See

setPropertyUniformDistribution(const std::string &name, const T &min, const T &max)

Parameters
  • name – The name of the environment property to set

  • index – The index of the element within the environment property array to set

  • min – The value to set the first environment property array element

  • max – The value to set the last environment property array element

Template Parameters

T – The type of the environment property, this must match the ModelDescription

Throws
  • InvalidEnvProperty – If a property of the name does not exist

  • InvalidEnvPropertyType – If a property with the name has a type different to T

  • std::out_of_range – If index is greater than or equal to the length of the environment property array

  • std::out_of_range – If this vector has a length less than 2

void setRandomPropertySeed(const unsigned int &seed)

Seed the internal random generator used for random property distributions This will only affect subsequent calls to setPropertyRandom()

Parameters

seed – The random seed to be used

template<typename T>
void setPropertyUniformRandom(const std::string &name, const T &min, const T &max)

Sweep named environment property over a uniform random distribution Integer types have a range [min, max] Floating point types have a range [min, max)

Convenience random implementations

Parameters
  • name – The name of the environment property to set

  • min – The value of the range to set the first environment property

  • max – The value of the range to set the last environment property

Template Parameters

T – The type of the environment property, this must match the ModelDescription

Throws
  • InvalidEnvProperty – If a property of the name does not exist

  • InvalidEnvPropertyType – If a property with the name has a type different to T, or length > 1

  • std::out_of_range – If this vector has a length less than 2

template<typename T>
void setPropertyUniformRandom(const std::string &name, const EnvironmentManager::size_type &index, const T &min, const T &max)

Array property element equivalent of setPropertyUniformRandom() Sweep named environment property over a uniform random distribution Integer types have a range [min, max] Floating point types have a range [min, max)

See

setPropertyUniformRandom(const std::string &name, const T &min, const T &max)

Parameters
  • name – The name of the environment property to set

  • min – The value of the range to set the first environment property

  • max – The value of the range to set the last environment property

Template Parameters

T – The type of the environment property, this must match the ModelDescription

Throws
  • InvalidEnvProperty – If a property of the name does not exist

  • InvalidEnvPropertyType – If a property with the name has a type different to T

  • std::out_of_range – If index is greater than or equal to the length of the environment property array

  • std::out_of_range – If this vector has a length less than 2

template<typename T>
void setPropertyNormalRandom(const std::string &name, const T &mean, const T &stddev)

Sweep named environment property over a normal random distribution Only floating point types are supported

Parameters
  • name – The name of the environment property to set

  • mean – Mean of the distribution (its expected value). Which coincides with the location of its peak.

  • stddev – Standard deviation: The square root of variance, representing the dispersion of values from the distribution mean.

Template Parameters

T – The type of the environment property, this must match the ModelDescription

Throws
  • InvalidEnvProperty – If a property of the name does not exist

  • InvalidEnvPropertyType – If a property with the name has a type different to T, or length > 1

  • std::out_of_range – If this vector has a length less than 2

template<typename T>
void setPropertyNormalRandom(const std::string &name, const EnvironmentManager::size_type &index, const T &mean, const T &stddev)

Array property element equivalent of setPropertyNormalRandom() Sweep named environment property over a normal random distribution Only floating point types are supported

See

setPropertyNormalRandom(const std::string &name, const T &mean, const T &stddev)

Parameters
  • name – The name of the environment property to set

  • mean – Mean of the distribution (its expected value). Which coincides with the location of its peak.

  • stddev – Standard deviation: The square root of variance, representing the dispersion of values from the distribution mean.

Template Parameters

T – The type of the environment property, this must match the ModelDescription

Throws
  • InvalidEnvProperty – If a property of the name does not exist

  • InvalidEnvPropertyType – If a property with the name has a type different to T

  • std::out_of_range – If index is greater than or equal to the length of the environment property array

  • std::out_of_range – If this vector has a length less than 2

template<typename T>
void setPropertyLogNormalRandom(const std::string &name, const T &mean, const T &stddev)

Sweep named environment property over a log normal random distribution Only floating point types are supported

Parameters
  • name – The name of the environment property to set

  • mean – Mean of the underlying normal distribution formed by the logarithm transformations of the possible values in this distribution.

  • stddev – Standard deviation of the underlying normal distribution formed by the logarithm transformations of the possible values in this distribution.

Template Parameters

T – The type of the environment property, this must match the ModelDescription

Throws
  • InvalidEnvProperty – If a property of the name does not exist

  • InvalidEnvPropertyType – If a property with the name has a type different to T, or length > 1

  • std::out_of_range – If this vector has a length less than 2

template<typename T>
void setPropertyLogNormalRandom(const std::string &name, const EnvironmentManager::size_type &index, const T &mean, const T &stddev)

Array property element equivalent of setPropertyLogNormalRandom() Sweep named environment property over a log normal random distribution Only floating point types are supported

See

setPropertyNormalRandom(const std::string &name, const T &mean, const T &stddev)

Parameters
  • name – The name of the environment property to set

  • mean – Mean of the underlying normal distribution formed by the logarithm transformations of the possible values in this distribution.

  • stddev – Standard deviation of the underlying normal distribution formed by the logarithm transformations of the possible values in this distribution.

Template Parameters

T – The type of the environment property, this must match the ModelDescription

Throws
  • InvalidEnvProperty – If a property of the name does not exist

  • InvalidEnvPropertyType – If a property with the name has a type different to T

  • std::out_of_range – If index is greater than or equal to the length of the environment property array

  • std::out_of_range – If this vector has a length less than 2

template<typename T, typename rand_dist>
void setPropertyRandom(const std::string &name, rand_dist &distribution)

Use a random distribution to generate parameters for the named environment property

Parameters
  • name – The name of the environment property to set

  • distribution – The random distribution to use for generating random property values

Template Parameters
  • T – The type of the environment property, this must match the ModelDescription

  • rand_dist – An object satisfying the requirements of RandomNumberDistribution e.g. std::uniform_real_distribution

Throws
  • InvalidEnvProperty – If a property of the name does not exist

  • InvalidEnvPropertyType – If a property with the name has a type different to T, or length to N

  • std::out_of_range – If this vector has a length less than 2

template<typename T, typename rand_dist>
void setPropertyRandom(const std::string &name, const EnvironmentManager::size_type &index, rand_dist &distribution)

Array property element equivalent of setPropertyRandom() Use a random distribution to generate parameters for the specified element of the named environment property array

Parameters
  • name – The name of the environment property to set

  • index – The index of the element within the environment property array to set

  • distribution – The random distribution to use for generating random property values

Template Parameters
  • T – The type of the environment property array, this must match the ModelDescription

  • rand_dist – An object satisfying the requirements of RandomNumberDistribution e.g. std::uniform_real_distribution

Throws
  • InvalidEnvProperty – If a property of the name does not exist

  • InvalidEnvPropertyType – If a property with the name has a type different to T, or length to N

  • std::out_of_range – If index is greater than or equal to the length of the environment property array

  • std::out_of_range – If this vector has a length less than 2

RunPlanVec operator+(const RunPlan &rhs) const

Operator methods for combining vectors

RunPlanVec operator+(const RunPlanVec &rhs) const
RunPlanVec &operator+=(const RunPlan &rhs)
RunPlanVec &operator+=(const RunPlanVec &rhs)
RunPlanVec &operator*=(const unsigned int &rhs)
RunPlanVec operator*(const unsigned int &rhs) const
template<>
inline void setPropertyUniformRandom(const std::string &name, const float &min, const float &max)

Special cases std::random doesn’t support char, emulate behaviour char != signed char (or unsigned char)

template<>
inline void setPropertyUniformRandom(const std::string &name, const EnvironmentManager::size_type &index, const float &min, const float &max)
template<>
inline void setPropertyUniformRandom(const std::string &name, const double &min, const double &max)
template<>
inline void setPropertyUniformRandom(const std::string &name, const EnvironmentManager::size_type &index, const double &min, const double &max)
template<>
inline void setPropertyUniformRandom(const std::string &name, const char &min, const char &max)
template<>
inline void setPropertyUniformRandom(const std::string &name, const EnvironmentManager::size_type &index, const char &min, const char &max)
template<>
inline void setPropertyUniformRandom(const std::string &name, const unsigned char &min, const unsigned char &max)
template<>
inline void setPropertyUniformRandom(const std::string &name, const EnvironmentManager::size_type &index, const unsigned char &min, const unsigned char &max)
template<>
inline void setPropertyUniformRandom(const std::string &name, const signed char &min, const signed char &max)
template<>
inline void setPropertyUniformRandom(const std::string &name, const EnvironmentManager::size_type &index, const signed char &min, const signed char &max)