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 (SUMOReal maxV)
 Returns a random real number in [0, maxV)
static int rand (int maxV)
 Returns a random integer in [0, maxV-1].
static size_t rand (size_t maxV)
 Returns a random integer in [0, maxV-1].
static SUMOReal rand (SUMOReal minV, SUMOReal maxV)
 Returns a random real number in [minV, maxV)
static int rand (int minV, int maxV)
 Returns a random integer in [minV, maxV-1].
static SUMOReal rand ()
 Returns a random real number in [0, 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 49 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 95 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 66 of file RandHelper.cpp.

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

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

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

Returns a random real number in [0, maxV)

Definition at line 63 of file RandHelper.h.

References rand().

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

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

Definition at line 78 of file RandHelper.h.

References myRandomNumberGenerator, and MTRand::randInt().

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

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

Definition at line 73 of file RandHelper.h.

References myRandomNumberGenerator, and MTRand::randInt().

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

Returns a random real number in [minV, maxV)

Definition at line 68 of file RandHelper.h.

References rand().

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

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

Definition at line 83 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 88 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 101 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