SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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. More...
 
static void initRandGlobal (MTRand *which=0)
 Reads the given random number options and initialises the random number generator in accordance. More...
 
static void insertRandOptions ()
 Initialises the given options container with random number options. More...
 
static SUMOReal rand ()
 Returns a random real number in [0, 1) More...
 
static SUMOReal rand (SUMOReal maxV)
 Returns a random real number in [0, maxV) More...
 
static SUMOReal rand (SUMOReal minV, SUMOReal maxV)
 Returns a random real number in [minV, maxV) More...
 
static size_t rand (size_t maxV)
 Returns a random integer in [0, maxV-1]. More...
 
static int rand (int maxV)
 Returns a random integer in [0, maxV-1]. More...
 
static int rand (int minV, int maxV)
 Returns a random integer in [minV, maxV-1]. More...
 
static SUMOReal randNorm (SUMOReal mean, SUMOReal variance, MTRand &rng=myRandomNumberGenerator)
 Access to a random number from a normal distribution. More...
 

Static Protected Attributes

static MTRand myRandomNumberGenerator
 the random number generator to use More...
 

Detailed Description

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

Definition at line 52 of file RandHelper.h.

Member Function Documentation

template<class T >
static T RandHelper::getRandomFrom ( const std::vector< T > &  v)
inlinestatic

Returns a random element from the given vector.

Definition at line 98 of file RandHelper.h.

References rand().

Referenced by MSEdge::getDepartLane().

void RandHelper::initRandGlobal ( MTRand which = 0)
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(), MTRand::hash(), myRandomNumberGenerator, and MTRand::seed().

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

void RandHelper::insertRandOptions ( )
static
static SUMOReal RandHelper::rand ( )
inlinestatic

Returns a random real number in [0, 1)

Definition at line 61 of file RandHelper.h.

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

Referenced by MSCFModel_Kerner::_v(), RORouteDef::addAlternative(), RONet::addFlow(), MSDevice_HBEFA::buildVehicleDevices(), MSDevice_Routing::buildVehicleDevices(), MSBaseVehicle::calculateArrivalPos(), ODMatrix::computeDeparts(), NGRandomNetBuilder::createNet(), NGRandomNetBuilder::createNewNode(), MSCFModel_Krauss::dawdle(), MSCFModel_Daniel1::dawdle(), MSCFModel_SmartSK::dawdle(), MSCFModel_KraussOrig1::dawdle(), AGPerson::decide(), AGFreeTime::decideTypeOfTrip(), MSCFModel_PWag2009::followSpeed(), AGHousehold::generateCars(), AGWorkPosition::generateClosingTime(), AGWorkPosition::generateOpeningTime(), AGCity::generatePopulation(), AGActivities::generateRandomTraffic(), RandomDistributor< std::const std::string >::get(), AGDataAndStatistics::getInverseExpRandomValue(), AGDataAndStatistics::getPoissonsNumberOfChildren(), AGDataAndStatistics::getRandom(), AGDataAndStatistics::getRandomCityGateByIncoming(), AGDataAndStatistics::getRandomCityGateByOutgoing(), getRandomFrom(), AGDataAndStatistics::getRandomPopDistributed(), AGCity::getRandomStreet(), MSLane::insertVehicle(), MSEdge::insertVehicle(), MSTriggeredRerouter::notifyEnter(), TNeighbourDistribution::num(), rand(), AGAdult::randomFreeWorkPosition(), AGPosition::randomPositionInStreet(), AGActivity::randomTimeBetween(), NGNet::toNB(), and MSCFModel_SmartSK::updateMyHeadway().

static SUMOReal RandHelper::rand ( SUMOReal  maxV)
inlinestatic

Returns a random real number in [0, maxV)

Definition at line 66 of file RandHelper.h.

References rand().

static SUMOReal RandHelper::rand ( SUMOReal  minV,
SUMOReal  maxV 
)
inlinestatic

Returns a random real number in [minV, maxV)

Definition at line 71 of file RandHelper.h.

References rand().

static size_t RandHelper::rand ( size_t  maxV)
inlinestatic

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

Definition at line 76 of file RandHelper.h.

References myRandomNumberGenerator, and MTRand::randInt().

static int RandHelper::rand ( int  maxV)
inlinestatic

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

Definition at line 81 of file RandHelper.h.

References myRandomNumberGenerator, and MTRand::randInt().

static int RandHelper::rand ( int  minV,
int  maxV 
)
inlinestatic

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

Definition at line 86 of file RandHelper.h.

References rand().

static SUMOReal RandHelper::randNorm ( SUMOReal  mean,
SUMOReal  variance,
MTRand rng = myRandomNumberGenerator 
)
inlinestatic

Access to a random number from a normal distribution.

Definition at line 91 of file RandHelper.h.

References SUMOReal.

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

Field Documentation

MTRand RandHelper::myRandomNumberGenerator
staticprotected

the random number generator to use

Definition at line 106 of file RandHelper.h.

Referenced by initRandGlobal(), and rand().


The documentation for this class was generated from the following files: