SUMO - Simulation of Urban MObility
RandHelper Class Reference

Utility functions for using a global, resetable random number generator. More...

#include <RandHelper.h>

Static Public Member Functions

template<class T >
static T getRandomFrom (const std::vector< T > &v)
 Returns a random element from the given vector.
static void initRandGlobal ()
 Reads the given random number options and initialises the random number generator in accordance.
static void insertRandOptions ()
 Initialises the given options container with random number options.
static SUMOReal rand ()
 Returns a random real number in [0, 1)
static SUMOReal rand (SUMOReal maxV)
 Returns a random real number in [0, maxV)
static SUMOReal rand (SUMOReal minV, SUMOReal maxV)
 Returns a random real number in [minV, maxV)
static size_t rand (size_t maxV)
 Returns a random integer in [0, maxV-1].
static int rand (int maxV)
 Returns a random integer in [0, maxV-1].
static int rand (int minV, int maxV)
 Returns a random integer in [minV, maxV-1].
static SUMOReal randNorm (SUMOReal mean, SUMOReal variance)
 Access to a random number from a normal distribution.

Static Protected Attributes

static MTRand myRandomNumberGenerator
 the random number generator to use

Detailed Description

Utility functions for using a global, resetable random number generator.

Definition at line 51 of file RandHelper.h.


Member Function Documentation

template<class T >
static T RandHelper::getRandomFrom ( const std::vector< T > &  v) [inline, static]

Returns a random element from the given vector.

Definition at line 97 of file RandHelper.h.

References rand().

Referenced by MSEdge::getDepartLane(), RONet::getRandomDestination(), and RONet::getRandomSource().

void RandHelper::initRandGlobal ( ) [static]

Reads the given random number options and initialises the random number generator in accordance.

Definition at line 68 of file RandHelper.cpp.

References OptionsCont::getBool(), OptionsCont::getInt(), OptionsCont::getOptions(), myRandomNumberGenerator, and MTRand::seed().

Referenced by main(), and GUILoadThread::run().

static SUMOReal RandHelper::rand ( SUMOReal  maxV) [inline, static]

Returns a random real number in [0, maxV)

Definition at line 65 of file RandHelper.h.

References rand().

static SUMOReal RandHelper::rand ( SUMOReal  minV,
SUMOReal  maxV 
) [inline, static]

Returns a random real number in [minV, maxV)

Definition at line 70 of file RandHelper.h.

References rand().

static size_t RandHelper::rand ( size_t  maxV) [inline, static]

Returns a random integer in [0, maxV-1].

Definition at line 75 of file RandHelper.h.

References myRandomNumberGenerator, and MTRand::randInt().

static int RandHelper::rand ( int  maxV) [inline, static]

Returns a random integer in [0, maxV-1].

Definition at line 80 of file RandHelper.h.

References myRandomNumberGenerator, and MTRand::randInt().

static int RandHelper::rand ( int  minV,
int  maxV 
) [inline, static]

Returns a random integer in [minV, maxV-1].

Definition at line 85 of file RandHelper.h.

References rand().

static SUMOReal RandHelper::randNorm ( SUMOReal  mean,
SUMOReal  variance 
) [inline, static]

Access to a random number from a normal distribution.

Definition at line 90 of file RandHelper.h.

References myRandomNumberGenerator, MTRand::randNorm(), and SUMOReal.

Referenced by MSCFModel_Wiedemann::_v(), MSVehicleType::getMaxSpeedWithDeviation(), and AGActivityGen::varDepTime().


Field Documentation

the random number generator to use

Definition at line 104 of file RandHelper.h.

Referenced by initRandGlobal(), rand(), and randNorm().


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines