ACADO Toolkit
1.2.0beta
Toolkit for Automatic Control and Dynamic Optimization
|
Generates pseudo-random Gaussian noise for simulating the Process. More...
#include <gaussian_noise.hpp>
Public Member Functions | |
GaussianNoise () | |
Default constructor. | |
GaussianNoise (const Vector &_mean, const Vector &_variance) | |
Constructor which takes mean value and variance of the random variable. | |
GaussianNoise (uint _dim, double _mean, double _variance) | |
Constructor which takes the dimension of the random variable as well as as common values for the mean value and variance of the random variable. | |
GaussianNoise (const GaussianNoise &rhs) | |
Copy constructor (deep copy). | |
virtual | ~GaussianNoise () |
Destructor. | |
GaussianNoise & | operator= (const GaussianNoise &rhs) |
Assignment Operator (deep copy) | |
virtual GaussianNoise * | clone () const |
Clone constructor (deep copy). | |
virtual GaussianNoise * | clone (uint idx) const |
Clone constructor for a given noise component (deep copy). | |
returnValue | setMeans (const Vector &_mean) |
Assigns new mean values to the random variable. | |
returnValue | setMeans (double _mean) |
Assigns new mean values to the random variable. | |
returnValue | setMean (uint idx, double _mean) |
Assigns new mean value on the component of the random variable with given index. | |
returnValue | setVariances (const Vector &_variance) |
Assigns new variances to the random variable. | |
returnValue | setVariances (double _variance) |
Assigns new variances to the random variable. | |
returnValue | setVariance (uint idx, double _variance) |
Assigns new variance on the component of the random variable with given index. | |
virtual returnValue | init (uint seed=0) |
Initializes noise generation and performs a couple of consistency checks. | |
virtual returnValue | step (Vector &_w) |
Generates a single noise vector based on current internal settings. | |
virtual returnValue | step (VariablesGrid &_w) |
Generates a noise vector sequence based on current internal settings. | |
const Vector & | getMean () const |
Returns mean values of the random variable. | |
const Vector & | getVariance () const |
Returns variances of the random variable. | |
uint | getDim () const |
Returns dimension of noise vector. | |
BooleanType | isEmpty () const |
Returns whether noise vector is empty (i.e. | |
BlockStatus | getStatus () const |
Returns current status of noise block, see documentation of BlockStatus for details. | |
Protected Member Functions | |
double | getGaussianRandomNumber (double _mean, double _variance) const |
Returns a pseudo-random number based on a Gaussian distribution with given mean and variance. | |
returnValue | setStatus (BlockStatus _status) |
Assigns new status to noise block. | |
double | getUniformRandomNumber (double _lowerLimit, double _upperLimit) const |
Returns a pseudo-random number based on a uniform distribution with given lower and upper limits. | |
Protected Attributes | |
Vector | mean |
Mean value for each component. | |
Vector | variance |
Variance for each component. | |
BlockStatus | status |
Current status of the noise. | |
VariablesGrid | w |
Sequence of most recently generated noise. |
The class GaussiaNoise generates pseudo-random Gaussian noise for simulating the Process within the SimulationEnvironment.
Referenced by clone().
GaussianNoise::GaussianNoise | ( | const Vector & | _mean, |
const Vector & | _variance | ||
) |
The dimension of these limit vector determine the dimension of the random variable.
[in] | _mean | Mean value for each component. |
[in] | _variance | Variance for each component. |
References ACADOERROR, VectorspaceElement::getDim(), VariablesGrid::init(), mean, RET_INVALID_NOISE_SETTINGS, variance, and Noise::w.
GaussianNoise::GaussianNoise | ( | uint | _dim, |
double | _mean, | ||
double | _variance | ||
) |
[in] | _dim | Dimension of random variable. |
[in] | _mean | Mean value for each component. |
[in] | _variance | Variance for each component. |
References VectorspaceElement::init(), VariablesGrid::init(), mean, uint, variance, and Noise::w.
GaussianNoise::GaussianNoise | ( | const GaussianNoise & | rhs | ) |
GaussianNoise::~GaussianNoise | ( | ) | [virtual] |
GaussianNoise * GaussianNoise::clone | ( | ) | const [virtual] |
GaussianNoise * GaussianNoise::clone | ( | uint | idx | ) | const [virtual] |
[in] | idx | Right-hand side object. |
Implements Noise.
References GaussianNoise(), Noise::getDim(), VariablesGrid::init(), mean, variance, and Noise::w.
BEGIN_NAMESPACE_ACADO uint Noise::getDim | ( | ) | const [inline, inherited] |
References MatrixVariablesGrid::getNumValues(), and Noise::w.
Referenced by ColoredNoise::clone(), clone(), UniformNoise::clone(), Noise::isEmpty(), Actuator::setControlNoise(), UniformNoise::setLimit(), UniformNoise::setLimits(), setMean(), setMeans(), Sensor::setOutputNoise(), Actuator::setParameterNoise(), setVariance(), setVariances(), UniformNoise::step(), and step().
double GaussianNoise::getGaussianRandomNumber | ( | double | _mean, |
double | _variance | ||
) | const [protected] |
[in] | _mean | Mean value of Gaussian distribution. |
[in] | _variance | Variance of Gaussian distribution. |
References Noise::getUniformRandomNumber(), log(), norm(), and sqrt().
Referenced by step().
const Vector & GaussianNoise::getMean | ( | ) | const [inline] |
References mean.
BlockStatus Noise::getStatus | ( | ) | const [inline, inherited] |
References Noise::status.
Referenced by UniformNoise::step(), and step().
double Noise::getUniformRandomNumber | ( | double | _lowerLimit, |
double | _upperLimit | ||
) | const [inline, protected, inherited] |
[in] | _lowerLimit | Lower limit of random variable. |
[in] | _upperLimit | Lower limit of random variable. |
Referenced by getGaussianRandomNumber(), and UniformNoise::step().
const Vector & GaussianNoise::getVariance | ( | ) | const [inline] |
References variance.
returnValue GaussianNoise::init | ( | uint | seed = 0 | ) | [virtual] |
Initialization of the pseudo-random number generator can be based on a seed in order to allow exact reproduction of generated noise. If seed is not specified (i.e. 0), a seed is obtain from the system clock.
[in] | seed | Seed for pseudo-random number generator. |
Implements Noise.
References ACADOERROR, BS_READY, VectorspaceElement::getDim(), mean, RET_INVALID_NOISE_SETTINGS, RET_NO_NOISE_SETTINGS, Noise::setStatus(), SUCCESSFUL_RETURN, and variance.
BooleanType Noise::isEmpty | ( | ) | const [inline, inherited] |
has dimension zero).
References BT_FALSE, BT_TRUE, and Noise::getDim().
GaussianNoise & GaussianNoise::operator= | ( | const GaussianNoise & | rhs | ) |
returnValue GaussianNoise::setMean | ( | uint | idx, |
double | _mean | ||
) | [inline] |
[in] | idx | Index of component. |
[in] | _mean | New mean value. |
References ACADOERROR, Noise::getDim(), mean, RET_INDEX_OUT_OF_BOUNDS, and SUCCESSFUL_RETURN.
BEGIN_NAMESPACE_ACADO returnValue GaussianNoise::setMeans | ( | const Vector & | _mean | ) | [inline] |
[in] | _mean | New mean value for each component. |
References ACADOERROR, VectorspaceElement::getDim(), mean, RET_VECTOR_DIMENSION_MISMATCH, and SUCCESSFUL_RETURN.
returnValue GaussianNoise::setMeans | ( | double | _mean | ) | [inline] |
[in] | _mean | New common mean value for all components. |
References Noise::getDim(), mean, SUCCESSFUL_RETURN, and uint.
returnValue Noise::setStatus | ( | BlockStatus | _status | ) | [inline, protected, inherited] |
[in] | _status | New status. |
References Noise::status, and SUCCESSFUL_RETURN.
Referenced by ColoredNoise::init(), UniformNoise::init(), and init().
returnValue GaussianNoise::setVariance | ( | uint | idx, |
double | _variance | ||
) | [inline] |
[in] | idx | Index of component. |
[in] | _variance | New variance. |
References ACADOERROR, Noise::getDim(), RET_INDEX_OUT_OF_BOUNDS, SUCCESSFUL_RETURN, and variance.
returnValue GaussianNoise::setVariances | ( | const Vector & | _variance | ) | [inline] |
[in] | _variance | New variances for each component. |
References ACADOERROR, ASSERT, VectorspaceElement::getDim(), VectorspaceElement::isGreaterThan(), RET_VECTOR_DIMENSION_MISMATCH, SUCCESSFUL_RETURN, and variance.
returnValue GaussianNoise::setVariances | ( | double | _variance | ) | [inline] |
[in] | _variance | New common variance for all components. |
References Noise::getDim(), SUCCESSFUL_RETURN, uint, and variance.
returnValue GaussianNoise::step | ( | Vector & | _w | ) | [virtual] |
[out] | _w | Generated noise vector. |
Implements Noise.
References ACADOERROR, BS_READY, Noise::getDim(), VectorspaceElement::getDim(), getGaussianRandomNumber(), Grid::getNumPoints(), Noise::getStatus(), VariablesGrid::getVector(), VariablesGrid::init(), mean, RET_BLOCK_NOT_READY, RET_VECTOR_DIMENSION_MISMATCH, SUCCESSFUL_RETURN, uint, variance, and Noise::w.
returnValue GaussianNoise::step | ( | VariablesGrid & | _w | ) | [virtual] |
Noise is generated for each grid point of the VariablesGrid passed.
[in,out] | _w | Generated noise vector sequence. |
Implements Noise.
References ACADOERROR, BS_READY, Noise::getDim(), getGaussianRandomNumber(), Grid::getNumPoints(), MatrixVariablesGrid::getNumValues(), Noise::getStatus(), VariablesGrid::init(), mean, RET_BLOCK_NOT_READY, RET_VECTOR_DIMENSION_MISMATCH, SUCCESSFUL_RETURN, uint, variance, and Noise::w.
Vector GaussianNoise::mean [protected] |
Referenced by clone(), GaussianNoise(), getMean(), init(), operator=(), setMean(), setMeans(), and step().
BlockStatus Noise::status [protected, inherited] |
Referenced by Noise::getStatus(), and Noise::setStatus().
Vector GaussianNoise::variance [protected] |
Referenced by clone(), GaussianNoise(), getVariance(), init(), operator=(), setVariance(), setVariances(), and step().
VariablesGrid Noise::w [protected, inherited] |