![]() |
SUMO - Simulation of Urban MObility
|
Utility functions for using a global, resetable random number generator. More...
#include <RandHelper.h>
Static Public Member Functions | |
template<class T > | |
static const T & | getRandomFrom (const std::vector< T > &v, std::mt19937 *rng=0) |
Returns a random element from the given vector. More... | |
static void | initRand (std::mt19937 *which=0, const bool random=false, const int seed=23423) |
Initialises the random number generator with hardware randomness or seed. More... | |
static void | initRandGlobal (std::mt19937 *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 double | rand (std::mt19937 *rng=0) |
Returns a random real number in [0, 1) More... | |
static double | rand (double maxV, std::mt19937 *rng=0) |
Returns a random real number in [0, maxV) More... | |
static double | rand (double minV, double maxV, std::mt19937 *rng=0) |
Returns a random real number in [minV, maxV) More... | |
static int | rand (int maxV, std::mt19937 *rng=0) |
Returns a random integer in [0, maxV-1]. More... | |
static int | rand (int minV, int maxV, std::mt19937 *rng=0) |
Returns a random integer in [minV, maxV-1]. More... | |
static long long int | rand (long long int maxV, std::mt19937 *rng=0) |
Returns a random 64 bit integer in [0, maxV-1]. More... | |
static long long int | rand (long long int minV, long long int maxV, std::mt19937 *rng=0) |
Returns a random 64 bit integer in [minV, maxV-1]. More... | |
static double | randNorm (double mean, double variance, std::mt19937 *rng=0) |
Access to a random number from a normal distribution. More... | |
Static Protected Attributes | |
static std::mt19937 | myRandomNumberGenerator |
the random number generator to use More... | |
Utility functions for using a global, resetable random number generator.
Definition at line 52 of file RandHelper.h.
|
inlinestatic |
Returns a random element from the given vector.
Definition at line 150 of file RandHelper.h.
References rand().
Referenced by MSEdge::getDepartLane(), MSSOTLTrafficLightLogic::getPhaseIndexWithMaxCTS(), AGCity::getRandomStreet(), and AGAdult::randomFreeWorkPosition().
|
static |
Initialises the random number generator with hardware randomness or seed.
Definition at line 63 of file RandHelper.cpp.
References myRandomNumberGenerator.
Referenced by initRandGlobal().
|
static |
Reads the given random number options and initialises the random number generator in accordance.
Definition at line 76 of file RandHelper.cpp.
References OptionsCont::getBool(), OptionsCont::getInt(), OptionsCont::getOptions(), and initRand().
Referenced by NLBuilder::init(), main(), GNELoadThread::run(), and GUILoadThread::run().
|
static |
Initialises the given options container with random number options.
Definition at line 47 of file RandHelper.cpp.
References OptionsCont::addDescription(), OptionsCont::addOptionSubTopic(), OptionsCont::addSynonyme(), OptionsCont::doRegister(), and OptionsCont::getOptions().
Referenced by RODFFrame::fillOptions(), AGFrame::fillOptions(), ROJTRFrame::fillOptions(), RODUAFrame::fillOptions(), ROMAFrame::fillOptions(), fillOptions(), MSFrame::fillOptions(), and GNELoadThread::fillOptions().
|
inlinestatic |
Returns a random real number in [0, 1)
Definition at line 64 of file RandHelper.h.
References myRandomNumberGenerator.
Referenced by RORouteDef::addAlternative(), RONet::addFlow(), MSRouteHandler::addPersonTrip(), MSRouteHandler::addWalk(), MSLink::blockedAtTime(), MSBaseVehicle::calculateArrivalParams(), RONet::checkFlows(), MSVehicle::checkRewindLinkLanes(), MSSwarmTrafficLightLogic::choosePolicy(), ODMatrix::computeDeparts(), MSVehicleControl::computeRandomDepartOffset(), NGRandomNetBuilder::createNet(), NGRandomNetBuilder::createNewNode(), MSCFModel_Kerner::createVehicleVariables(), MSCFModel_Daniel1::dawdle(), MSCFModel_SmartSK::dawdle(), MSCFModel_KraussOrig1::dawdle(), MSCFModel_Krauss::dawdle2(), MSCFModel_KraussX::dawdleX(), GLHelper::debugVertices(), AGPerson::decide(), MSSwarmTrafficLightLogic::decidePolicy(), AGFreeTime::decideTypeOfTrip(), MSInsertionControl::determineCandidates(), MSDevice::equippedByDefaultAssignmentOptions(), MSCFModel_PWag2009::followSpeed(), AGHousehold::generateCars(), AGWorkPosition::generateClosingTime(), AGWorkPosition::generateOpeningTime(), AGCity::generatePopulation(), AGActivities::generateRandomTraffic(), RandomDistributor< MSVehicleType *>::get(), MSLane::getDepartPosLat(), MSLane::getDepartSpeed(), MSDevice_Routing::getEffort(), AGDataAndStatistics::getInverseExpRandomValue(), AGDataAndStatistics::getPoissonsNumberOfChildren(), AGDataAndStatistics::getRandom(), AGDataAndStatistics::getRandomCityGateByIncoming(), AGDataAndStatistics::getRandomCityGateByOutgoing(), getRandomFrom(), AGDataAndStatistics::getRandomPopDistributed(), MSDevice_BTreceiver::inquiryDelaySlots(), MSLane::insertVehicle(), MSEdge::insertVehicle(), MSSOTLTrafficLightLogic::isThresholdPassed(), MSCFModel_Kerner::moveHelper(), MSTriggeredRerouter::notifyEnter(), MESegment::overtake(), SUMOVehicleParserHelper::parseWalkPos(), rand(), randNorm(), AGPosition::randomPositionInStreet(), AGActivity::randomTimeBetween(), MELoop::setApproaching(), SigmoidLogic::sigmoidLogic(), NGNet::toNB(), MSCFModel_SmartSK::updateMyHeadway(), MSPModel_Striping::PState::walk(), and RODFDetector::writeEmitterDefinition().
|
inlinestatic |
Returns a random real number in [0, maxV)
Definition at line 72 of file RandHelper.h.
References rand().
|
inlinestatic |
Returns a random real number in [minV, maxV)
Definition at line 77 of file RandHelper.h.
References rand().
|
inlinestatic |
Returns a random integer in [0, maxV-1].
Definition at line 82 of file RandHelper.h.
References myRandomNumberGenerator.
|
inlinestatic |
Returns a random integer in [minV, maxV-1].
Definition at line 102 of file RandHelper.h.
References rand().
|
inlinestatic |
Returns a random 64 bit integer in [0, maxV-1].
Definition at line 107 of file RandHelper.h.
References myRandomNumberGenerator, and rand().
|
inlinestatic |
Returns a random 64 bit integer in [minV, maxV-1].
Definition at line 131 of file RandHelper.h.
References rand().
|
inlinestatic |
Access to a random number from a normal distribution.
Definition at line 136 of file RandHelper.h.
References rand().
Referenced by MSCFModel_Wiedemann::_v(), Distribution_Parameterized::sample(), and AGActivityGen::varDepTime().
|
staticprotected |
the random number generator to use
Definition at line 158 of file RandHelper.h.
Referenced by initRand(), and rand().