Eclipse SUMO - Simulation of Urban MObility
|
Represents a generic random distribution. More...
#include <RandomDistributor.h>
Public Member Functions | |
bool | add (T val, double prob, bool checkDuplicates=true) |
Adds a value with an assigned probability to the distribution. | |
void | clear () |
Clears the distribution. | |
T | get (SumoRNG *which=nullptr) const |
Draw a sample of the distribution. | |
double | getOverallProb () const |
Return the sum of the probabilites assigned to the members. | |
const std::vector< double > & | getProbs () const |
Returns the probabilities assigned to the members of the distribution. | |
const std::vector< T > & | getVals () const |
Returns the members of the distribution. | |
RandomDistributor () | |
Constructor for an empty distribution. | |
bool | remove (T val) |
Removes a value with an assigned probability from the distribution. | |
~RandomDistributor () | |
Destructor. | |
Private Attributes | |
double | myProb |
the total probability | |
std::vector< double > | myProbs |
the corresponding probabilities | |
std::vector< T > | myVals |
the members | |
Represents a generic random distribution.
This class allows to create random distributions by assigning arbitrary (non-negative) probabilities to its elements. The random number generator used is specified in RandHelper.
Definition at line 46 of file RandomDistributor.h.
|
inline |
Constructor for an empty distribution.
Definition at line 50 of file RandomDistributor.h.
|
inline |
Destructor.
Definition at line 55 of file RandomDistributor.h.
|
inline |
Adds a value with an assigned probability to the distribution.
If the value is already member of the distribution and checkDuplicates is true (the default) the given probability is added to the current. The probability has to be non-negative but values larger than one are allowed (and scaled accordingly when an element is drawn).
[in] | val | The value to add to the distribution |
[in] | prob | The probability assigned to the value |
Definition at line 68 of file RandomDistributor.h.
References RandomDistributor< T >::myProb, RandomDistributor< T >::myProbs, and RandomDistributor< T >::myVals.
Referenced by GUIEdge::addRerouter(), ODDistrict::addSink(), ODDistrict::addSource(), buildNetwork(), ROJTREdge::chooseNext(), MSRouteHandler::closeRoute(), MSRouteHandler::closeVType(), RORouteHandler::closeVType(), GUISettingsHandler::getEventDistribution(), NIImporter_Vissim::NIVissimXMLHandler_Geschwindigkeitsverteilungsdefinition::myEndElement(), MSTriggeredRerouter::myStartElement(), MSRouteProbe::notifyEnter(), MSRouteHandler::openRouteDistribution(), MSRouteHandler::openVehicleTypeDistribution(), RORouteHandler::openVehicleTypeDistribution(), NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition::parse(), NIVissimSingleTypeParser_Laengenverteilungsdefinition::parse(), NIVissimSingleTypeParser_Zeitenverteilungsdefinition::parse(), and ODMatrix::parseTimeLine().
|
inline |
Clears the distribution.
Definition at line 136 of file RandomDistributor.h.
References RandomDistributor< T >::myProb, RandomDistributor< T >::myProbs, and RandomDistributor< T >::myVals.
Referenced by MSRouteHandler::openRoute(), and RORouteHandler::openRoute().
|
inline |
Draw a sample of the distribution.
A random sample is drawn according to the assigned probabilities.
[in] | which | The random number generator to use; the static one will be used if 0 is passed |
Definition at line 111 of file RandomDistributor.h.
References RandomDistributor< T >::myProb, RandomDistributor< T >::myProbs, RandomDistributor< T >::myVals, and RandHelper::rand().
Referenced by GUIApplicationWindow::checkGamingEvents(), ROJTREdge::chooseNext(), NGRandomNetBuilder::createNewNode(), ODDistrict::getRandomSink(), ODDistrict::getRandomSource(), MSRouteProbe::sampleRoute(), MSTriggeredRerouter::triggerRouting(), and RODFDetector::writeEmitterDefinition().
|
inline |
Return the sum of the probabilites assigned to the members.
This should be zero if and only if the distribution is empty.
Definition at line 131 of file RandomDistributor.h.
References RandomDistributor< T >::myProb.
Referenced by ODMatrix::applyCurve(), GUIApplicationWindow::checkGamingEvents(), ROJTREdge::chooseNext(), MSRouteHandler::closeRouteDistribution(), MSRouteHandler::closeVehicleTypeDistribution(), RORouteHandler::closeVehicleTypeDistribution(), GUITriggeredRerouter::GUITriggeredRerouterEdge::drawGL(), GUISettingsHandler::getEventDistribution(), MSRouteHandler::openVehicleTypeDistribution(), RORouteHandler::openVehicleTypeDistribution(), MSRouteProbe::sampleRoute(), MSTriggeredRerouter::triggerRouting(), RODFDetector::writeEmitterDefinition(), and MSRouteProbe::writeXMLOutput().
|
inline |
Returns the probabilities assigned to the members of the distribution.
See getVals for the corresponding members.
Definition at line 160 of file RandomDistributor.h.
References RandomDistributor< T >::myProbs.
Referenced by ODMatrix::applyCurve(), GUITriggeredRerouter::GUITriggeredRerouterEdge::drawGL(), GUITriggeredRerouter::myEndElement(), MSRouteHandler::openRoute(), MSRouteHandler::openVehicleTypeDistribution(), RORouteHandler::openVehicleTypeDistribution(), MSTriggeredRerouter::rerouteParkingArea(), GUITriggeredRerouter::shiftProbs(), MSDevice_Vehroutes::writeOutput(), and MSRouteProbe::writeXMLOutput().
|
inline |
Returns the members of the distribution.
See getProbs for the corresponding probabilities.
Definition at line 149 of file RandomDistributor.h.
References RandomDistributor< T >::myVals.
Referenced by MSVehicleControl::addVTypeDistribution(), ODMatrix::applyCurve(), MSRouteHandler::closeVehicle(), MSIdling_TaxiStand::idle(), MSInsertionControl::initScale(), GUITriggeredRerouter::myEndElement(), MSTriggeredRerouter::myEndElement(), MSCalibrator::VehicleRemover::notifyEnter(), MSRouteHandler::openVehicleTypeDistribution(), RORouteHandler::openVehicleTypeDistribution(), MSTriggeredRerouter::rerouteParkingArea(), ODDistrict::sinkNumber(), ODDistrict::sourceNumber(), MSTriggeredRerouter::triggerRouting(), MSDevice_Vehroutes::writeOutput(), and MSRouteProbe::writeXMLOutput().
|
inline |
Removes a value with an assigned probability from the distribution.
[in] | val | The value to remove from the distribution |
Definition at line 92 of file RandomDistributor.h.
References RandomDistributor< T >::myProb, RandomDistributor< T >::myProbs, and RandomDistributor< T >::myVals.
Referenced by MSTriggeredRerouter::triggerRouting().
|
private |
the total probability
Definition at line 166 of file RandomDistributor.h.
Referenced by RandomDistributor< T >::add(), RandomDistributor< T >::clear(), RandomDistributor< T >::get(), RandomDistributor< T >::getOverallProb(), and RandomDistributor< T >::remove().
|
private |
the corresponding probabilities
Definition at line 170 of file RandomDistributor.h.
Referenced by RandomDistributor< T >::add(), RandomDistributor< T >::clear(), RandomDistributor< T >::get(), RandomDistributor< T >::getProbs(), and RandomDistributor< T >::remove().
|
private |
the members
Definition at line 168 of file RandomDistributor.h.
Referenced by RandomDistributor< T >::add(), RandomDistributor< T >::clear(), RandomDistributor< T >::get(), RandomDistributor< T >::getVals(), and RandomDistributor< T >::remove().