|
WSF
|
#include <WsfRandomVariable.hpp>
Inherits UtScriptAccessible.

Public Types | |
| enum | Distribution { cCONSTANT , cEXPONENTIAL , cLOG_NORMAL , cNORMAL , cUNIFORM } |
| The distribution of the resulting values. More... | |
| enum | Constraints { cNO_CONSTRAINT , cPOSITIVE , cNON_NEGATIVE } |
| The constraints on the resulting values. More... | |
Public Member Functions | |
| WsfRandomVariable () | |
| Construct a default random variable with a uniform distribution in the range (0..1). | |
| WsfRandomVariable (Constraints aConstraints) | |
| Construct a default random variable with a uniform distribution in the range (0..1). | |
| WsfRandomVariable (double aConstant, Constraints aConstraints) | |
| WsfRandomVariable (double aMinimum, double aMaximum, Constraints aConstraints) | |
| WsfRandomVariable (Distribution aDistribution, double aParameter1, double aParameter2, Constraints aConstraints) | |
| WsfRandomVariable (Distribution aDistribution, const WsfVariable< double > &aParameter1, const WsfVariable< double > &aParameter2, Constraints aConstraints) | |
| bool | Initialize (const std::string &aName, WsfComponent *aObjectPtr, WsfScriptContext *aContextPtr, WsfSimulation &aSimulation) |
| void | ProcessInput (UtInput &aInput, UtInput::ValueType aValueType) |
| void | DefineDistribution (Distribution aDistribution, const WsfVariable< double > &aParameter1, const WsfVariable< double > &aParameter2, Constraints aConstraints) |
| double | Draw () |
| Draw the next random value from the distribution. | |
| double | LastDraw () const |
| Return the last drawn value. | |
Conversion operators. | |
| ut::Random * | mRandomPtr |
| A pointer to the currently used generator. | |
| ut::Random | mRandom |
| A random number generator instance, for script usage. | |
| Distribution | mDistribution |
| The type of distribution. | |
| Constraints | mConstraints |
| Constraints on the resulting values. | |
| double | mValue |
| The current (last drawn) value. | |
| WsfVariable< double > | mParameter1 |
| WsfVariable< double > | mParameter2 |
| operator double () const | |
| Returns the last drawn value. | |
| const char * | GetScriptClassName () const override |
| void | SetGenerator (WsfSimulation &aSim) |
| Set the random pointer for usage outside ProcessInput(). | |
| void | SetDefaultValues () |
| Helper method to set initial values when 'Draw' is not called first. | |
WsfRandomVariable Accessors | |
| double | GetParameterFirst () const |
| double | GetParameterSecond () const |
| Constraints | GetConstraints () const |
| Distribution | GetDistribution () const |
Relational operators. | |
We're using the default assignment operator. WsfRandomVariable& operator=(const WsfRandomVariable& aRhs) | |
| double | operator== (double aRhs) const |
| Is the last drawn value equal to the specified value? | |
| double | operator!= (double aRhs) const |
| Is the last drawn value not equal to the specified value. | |
| double | operator< (double aRhs) const |
| Is the last draw value less than the specified value. | |
A class that defines a continuous random variable. This class defines a continuous random variable whose distribution can be defined from an input stream.
The distribution of the resulting values.
| WsfRandomVariable::WsfRandomVariable | ( | ) |
Construct a default random variable with a uniform distribution in the range (0..1).
References cPOSITIVE, cUNIFORM, DefineDistribution(), and mRandomPtr.
| WsfRandomVariable::WsfRandomVariable | ( | Constraints | aConstraints | ) |
Construct a default random variable with a uniform distribution in the range (0..1).
References cUNIFORM, DefineDistribution(), and mRandomPtr.
| WsfRandomVariable::WsfRandomVariable | ( | double | aConstant, |
| Constraints | aConstraints ) |
Construct a random variable with a constant value.
| aConstant | The constant value. |
| aConstraints | Additional constraints on the resulting values. |
References cCONSTANT, DefineDistribution(), and mRandomPtr.
| WsfRandomVariable::WsfRandomVariable | ( | double | aMinimum, |
| double | aMaximum, | ||
| Constraints | aConstraints ) |
Construct a random variable with a uniform distribution of (minimum, maximum).
| aMinimum | The minimum value of the distribution. |
| aMaximum | The maximum value of the distribution. |
| aConstraints | Additional constraints on the resulting values. |
References cUNIFORM, DefineDistribution(), and mRandomPtr.
| WsfRandomVariable::WsfRandomVariable | ( | Distribution | aDistribution, |
| double | aParameter1, | ||
| double | aParameter2, | ||
| Constraints | aConstraints ) |
Construct a random variable with a specific distribution.
| aDistribution | The type of distribution. |
| aParameter1 | The first parameter for the distribution.
|
| aParameter2 | The second parameter for the distribution.
|
| aConstraints | Additional constraints on the resulting values. |
References DefineDistribution(), and mRandomPtr.
| WsfRandomVariable::WsfRandomVariable | ( | Distribution | aDistribution, |
| const WsfVariable< double > & | aParameter1, | ||
| const WsfVariable< double > & | aParameter2, | ||
| Constraints | aConstraints ) |
Construct a random variable with a specific distribution.
| aDistribution | The type of distribution. |
| aParameter1 | The first parameter for the distribution.
|
| aParameter2 | The second parameter for the distribution.
|
| aConstraints | Additional constraints on the resulting values. |
References DefineDistribution(), and mRandomPtr.
| void WsfRandomVariable::DefineDistribution | ( | Distribution | aDistribution, |
| const WsfVariable< double > & | aParameter1, | ||
| const WsfVariable< double > & | aParameter2, | ||
| Constraints | aConstraints ) |
Set the defining parameters of the distribution.
| aDistribution | The type of distribution. |
| aParameter1 | The first parameter for the distribution.
|
| aParameter2 | The second parameter for the distribution.
|
| aConstraints | Additional constraints on the resulting values. |
References mConstraints, mDistribution, mParameter1, mParameter2, and SetDefaultValues().
Referenced by ProcessInput(), WsfRandomVariable(), WsfRandomVariable(), WsfRandomVariable(), WsfRandomVariable(), WsfRandomVariable(), and WsfRandomVariable().
| double WsfRandomVariable::Draw | ( | ) |
Draw the next random value from the distribution.
References cCONSTANT, cEXPONENTIAL, cLOG_NORMAL, cNON_NEGATIVE, cNORMAL, cPOSITIVE, cUNIFORM, mConstraints, mDistribution, mParameter1, mParameter2, mRandomPtr, and mValue.
Referenced by WsfMessageProcessor::ReceiveMessage().
|
inline |
References mConstraints.
|
inline |
References mDistribution.
|
inline |
References mParameter1.
|
inline |
References mParameter2.
|
inlineoverride |
| bool WsfRandomVariable::Initialize | ( | const std::string & | aName, |
| WsfComponent * | aObjectPtr, | ||
| WsfScriptContext * | aContextPtr, | ||
| WsfSimulation & | aSimulation ) |
|
inline |
Return the last drawn value.
References mValue.
Referenced by wsf::comm::medium::ModeUnguided::CalculateTransferRate().
|
inline |
Returns the last drawn value.
References mValue.
|
inline |
Is the last drawn value not equal to the specified value.
References mValue.
|
inline |
Is the last draw value less than the specified value.
References mValue.
|
inline |
Is the last drawn value equal to the specified value?
References mValue.
| void WsfRandomVariable::ProcessInput | ( | UtInput & | aInput, |
| UtInput::ValueType | aValueType ) |
Define a distribution from an input stream. This method reads a distribution definition from the input stream. The input can be of the form:
| aInput | The input stream. |
| aValueType | The units of the values. |
References cCONSTANT, cEXPONENTIAL, cLOG_NORMAL, cNON_NEGATIVE, cNORMAL, cPOSITIVE, cUNIFORM, DefineDistribution(), mConstraints, WsfVariable< T >::ReadValueOfType(), WsfVariable< T >::ValueGreater(), and WsfVariable< T >::ValueGreaterOrEqual().
Referenced by wsf::comm::NetworkAdHoc::ProcessAddressRate(), wsf::cyber::Attack::ProcessFrequencyInput(), wsf::comm::PhysicalLayer::ProcessInput(), wsf::comm::ProtocolIGMP::ProcessInput(), wsf::comm::router::ProtocolOSPF::ProcessInput(), WsfLaserWeapon::ProcessInput(), WsfRF_Jammer::ProcessInput(), WsfTrackStateController::ProcessInput(), and wsf::comm::NetworkAdHoc::ProcessNamedRate().
|
protected |
Helper method to set initial values when 'Draw' is not called first.
References cCONSTANT, cEXPONENTIAL, cLOG_NORMAL, cNORMAL, cUNIFORM, mDistribution, mParameter1, mParameter2, and mValue.
Referenced by DefineDistribution(), and Initialize().
| void WsfRandomVariable::SetGenerator | ( | WsfSimulation & | aSim | ) |
Set the random pointer for usage outside ProcessInput().
References WsfSimulation::GetRandom(), mRandom, and mRandomPtr.
Referenced by wsf::comm::NetworkAdHoc::ChangeRate(), and UT_DEFINE_SCRIPT_METHOD().
|
protected |
Constraints on the resulting values.
Referenced by DefineDistribution(), Draw(), GetConstraints(), and ProcessInput().
|
protected |
The type of distribution.
Referenced by DefineDistribution(), Draw(), GetDistribution(), Initialize(), and SetDefaultValues().
|
protected |
The first parameter of the distribution.
Referenced by DefineDistribution(), Draw(), GetParameterFirst(), Initialize(), and SetDefaultValues().
|
protected |
The second parameter of the distribution.
Referenced by DefineDistribution(), Draw(), GetParameterSecond(), Initialize(), and SetDefaultValues().
|
protected |
A random number generator instance, for script usage.
Referenced by SetGenerator().
|
protected |
A pointer to the currently used generator.
Referenced by Draw(), Initialize(), SetGenerator(), WsfRandomVariable(), WsfRandomVariable(), WsfRandomVariable(), WsfRandomVariable(), WsfRandomVariable(), and WsfRandomVariable().
|
protected |
The current (last drawn) value.
Referenced by Draw(), LastDraw(), operator double(), operator!=(), operator<(), operator==(), and SetDefaultValues().