Eclipse 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, SumoRNG *rng=nullptr) |
Returns a random element from the given vector. | |
static void | initRand (SumoRNG *which=nullptr, const bool random=false, const int seed=23423) |
Initialises the random number generator with hardware randomness or seed. | |
static void | initRandGlobal (SumoRNG *which=nullptr) |
Reads the given random number options and initialises the random number generator in accordance. | |
static void | insertRandOptions (OptionsCont &oc) |
Initialises the given options container with random number options. | |
static void | loadState (const std::string &state, SumoRNG *rng=nullptr) |
load rng state from string | |
static double | rand (double maxV, SumoRNG *rng=nullptr) |
Returns a random real number in [0, maxV) | |
static double | rand (double minV, double maxV, SumoRNG *rng=nullptr) |
Returns a random real number in [minV, maxV) | |
static int | rand (int maxV, SumoRNG *rng=nullptr) |
Returns a random integer in [0, maxV-1]. | |
static int | rand (int minV, int maxV, SumoRNG *rng=nullptr) |
Returns a random integer in [minV, maxV-1]. | |
static long long int | rand (long long int maxV, SumoRNG *rng=nullptr) |
Returns a random 64 bit integer in [0, maxV-1]. | |
static long long int | rand (long long int minV, long long int maxV, SumoRNG *rng=nullptr) |
Returns a random 64 bit integer in [minV, maxV-1]. | |
static double | rand (SumoRNG *rng=nullptr) |
Returns a random real number in [0, 1) | |
static double | randExp (double rate, SumoRNG *rng=nullptr) |
Access to a random number from an exponential distribution. | |
static double | randNorm (double mean, double variance, SumoRNG *rng=nullptr) |
Access to a random number from a normal distribution. | |
static std::string | saveState (SumoRNG *rng=nullptr) |
save rng state to string | |
template<class T > | |
static void | shuffle (std::vector< T > &v, SumoRNG *rng=nullptr) |
Static Protected Attributes | |
static SumoRNG | myRandomNumberGenerator |
the default random number generator to use | |
Utility functions for using a global, resetable random number generator.
Definition at line 116 of file RandHelper.h.
|
inlinestatic |
Returns a random element from the given vector.
Definition at line 206 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 74 of file RandHelper.cpp.
References myRandomNumberGenerator.
Referenced by initRandGlobal(), and MSLane::initRNGs().
|
static |
Reads the given random number options and initialises the random number generator in accordance.
Definition at line 87 of file RandHelper.cpp.
References OptionsCont::getBool(), OptionsCont::getInt(), OptionsCont::getOptions(), and initRand().
Referenced by NLBuilder::initRandomness(), main(), main(), MSInsertionControl::MSInsertionControl(), and GNELoadThread::run().
|
static |
Initialises the given options container with random number options.
Definition at line 59 of file RandHelper.cpp.
References OptionsCont::addDescription(), OptionsCont::addOptionSubTopic(), OptionsCont::addSynonyme(), OptionsCont::doRegister(), and TL.
Referenced by AGFrame::fillOptions(), RODFFrame::fillOptions(), RODUAFrame::fillOptions(), ROJTRFrame::fillOptions(), ROMAFrame::fillOptions(), MSFrame::fillOptions(), fillOptions(), and GNELoadThread::fillOptions().
|
inlinestatic |
load rng state from string
Definition at line 226 of file RandHelper.h.
References myRandomNumberGenerator.
Referenced by MSLane::loadRNGState(), and MSStateHandler::myStartElement().
|
inlinestatic |
Returns a random real number in [0, maxV)
Definition at line 132 of file RandHelper.h.
References rand().
|
inlinestatic |
Returns a random real number in [minV, maxV)
Definition at line 137 of file RandHelper.h.
References rand().
|
inlinestatic |
Returns a random integer in [0, maxV-1].
Definition at line 142 of file RandHelper.h.
References SumoRNG::count, and myRandomNumberGenerator.
|
inlinestatic |
Returns a random integer in [minV, maxV-1].
Definition at line 163 of file RandHelper.h.
References rand().
|
inlinestatic |
Returns a random 64 bit integer in [0, maxV-1].
Definition at line 168 of file RandHelper.h.
References SumoRNG::count, myRandomNumberGenerator, and rand().
|
inlinestatic |
Returns a random 64 bit integer in [minV, maxV-1].
Definition at line 193 of file RandHelper.h.
References rand().
|
static |
Returns a random real number in [0, 1)
Definition at line 94 of file RandHelper.cpp.
References SumoRNG::count, gDebugFlag1, OutputDevice::getDevice(), SumoRNG::id, and myRandomNumberGenerator.
Referenced by MSPModel_JuPedSim::add(), RORouteDef::addAlternative(), RONet::addFlow(), MSRouteHandler::addFlowTransportable(), MSRouteHandler::addPersonTrip(), MSRouteHandler::addWalk(), MSAbstractLaneChangeModel::avoidOvertakeRight(), MSVehicle::betterContinuation(), MSLink::blockedAtTime(), NGEdge::buildNBEdge(), MSBaseVehicle::calculateArrivalParams(), RONet::checkFlows(), MSVehicle::checkLinkLeader(), MSSwarmTrafficLightLogic::choosePolicy(), RORouteHandler::closePersonFlow(), MSRouteHandler::closeTransportableFlow(), ODMatrix::computeDeparts(), MSInsertionControl::computeRandomDepartOffset(), NGRandomNetBuilder::createNet(), NGRandomNetBuilder::createNewNode(), MSCFModel_Kerner::createVehicleVariables(), MSCFModel_Daniel1::dawdle(), MSCFModel_KraussOrig1::dawdle(), MSCFModel_SmartSK::dawdle(), MSCFModel_Krauss::dawdle2(), MSCFModel_KraussX::dawdleX(), AGPerson::decide(), MSSwarmTrafficLightLogic::decidePolicy(), AGFreeTime::decideTypeOfTrip(), MSInsertionControl::determineCandidates(), MSDevice::equippedByDefaultAssignmentOptions(), MSPModel_JuPedSim::execute(), MSCFModel_Kerner::finalizeSpeed(), MSCFModel_PWag2009::followSpeed(), MSCFModel_W99::followSpeed(), AGHousehold::generateCars(), AGWorkPosition::generateClosingTime(), AGWorkPosition::generateOpeningTime(), AGCity::generatePopulation(), AGActivities::generateRandomTraffic(), RandomDistributor< T >::get(), MSStoppingPlace::getAccessPos(), MSLane::getDepartPosLat(), MSLane::getDepartSpeed(), MSRoutingEngine::getEffortExtra(), AGDataAndStatistics::getInverseExpRandomValue(), AGDataAndStatistics::getPoissonsNumberOfChildren(), AGDataAndStatistics::getRandom(), AGDataAndStatistics::getRandomCityGateByIncoming(), AGDataAndStatistics::getRandomCityGateByOutgoing(), getRandomFrom(), AGDataAndStatistics::getRandomPopDistributed(), IntermodalEdge< E, L, N, V >::getTravelTimeStaticRandomized(), ROEdge::getTravelTimeStaticRandomized(), MSIdling_RandomCircling::idle(), MSDevice_BTreceiver::inquiryDelaySlots(), MSLane::insertVehicle(), MSEdge::insertVehicle(), MSSOTLTrafficLightLogic::isThresholdPassed(), RouteCostCalculator< R, E, V >::keepRoute(), MSDevice_Bluelight::notifyMove(), MESegment::overtake(), RGBColor::parseColor(), SUMOVehicleParserHelper::parseWalkPos(), MSVehicle::planMoveInternal(), MSPModel_Striping::PState::PState(), rand(), rand(), rand(), rand(), rand(), randExp(), randNorm(), RGBColor::randomHue(), AGPosition::randomPositionInStreet(), AGActivity::randomTimeBetween(), MSStoppingPlaceRerouter::reroute(), MEVehicle::setApproaching(), MSVehicle::setApproachingForAllLinks(), MSStageDriving::setArrived(), MSStageTrip::setArrived(), MSBaseVehicle::setDepartAndArrivalEdge(), GUILane::setFunctionalColor(), shuffle(), SigmoidLogic::sigmoidLogic(), NGNet::toNB(), MSTriggeredRerouter::triggerRouting(), MSCFModel_SmartSK::updateMyHeadway(), MSPModel_Striping::PState::walk(), and RODFDetector::writeEmitterDefinition().
|
static |
Access to a random number from an exponential distribution.
Definition at line 150 of file RandHelper.cpp.
References rand().
Referenced by SUMOVehicleParameter::incrementFlow().
|
static |
Access to a random number from a normal distribution.
Definition at line 137 of file RandHelper.cpp.
References rand().
Referenced by MSCFModel_Wiedemann::_v(), MSCFModel_EIDM::finalizeSpeed(), MSDevice_Friction::notifyMove(), Distribution_Parameterized::sample(), MSDevice_ToC::sampleResponseTime(), OUProcess::step(), OUProcess::step(), and AGActivityGen::varDepTime().
|
inlinestatic |
save rng state to string
Definition at line 212 of file RandHelper.h.
References SumoRNG::count, and myRandomNumberGenerator.
Referenced by MSStateHandler::saveRNGs(), and MSLane::saveRNGStates().
|
inlinestatic |
Definition at line 240 of file RandHelper.h.
References rand(), and std::swap().
Referenced by MSTrainHelper::computeUnboardingPositions().
|
staticprotected |
the default random number generator to use
Definition at line 248 of file RandHelper.h.
Referenced by initRand(), loadState(), rand(), rand(), rand(), and saveState().