SUMO - Simulation of Urban MObility
|
Represents a generic random distribution. More...
#include <RandomDistributor.h>
Public Member Functions | |
bool | add (SUMOReal prob, T val, bool checkDuplicates=true) |
Adds a value with an assigned probability to the distribution. More... | |
void | clear () |
Clears the distribution. More... | |
T | get (MTRand *which=0) const |
Draw a sample of the distribution. More... | |
SUMOReal | getOverallProb () const |
Return the sum of the probabilites assigned to the members. More... | |
const std::vector< SUMOReal > & | getProbs () const |
Returns the probabilities assigned to the members of the distribution. More... | |
const std::vector< T > & | getVals () const |
Returns the members of the distribution. More... | |
RandomDistributor () | |
Constructor for an empty distribution. More... | |
~RandomDistributor () | |
Destructor. More... | |
Private Attributes | |
SUMOReal | myProb |
the total probability More... | |
std::vector< SUMOReal > | myProbs |
the corresponding probabilities (acts as a ring buffer if myMaximumSize is reached) More... | |
std::vector< T > | myVals |
the members (acts as a ring buffer if myMaximumSize is reached) More... | |
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 56 of file RandomDistributor.h.
|
inline |
Constructor for an empty distribution.
[in] | maximumSize | The maximum size to maintain older entrys will be removed when adding more than the maximumSize |
Definition at line 62 of file RandomDistributor.h.
|
inline |
Destructor.
Definition at line 67 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] | prob | The probability assigned to the value |
[in] | val | The value to add to the distribution |
Definition at line 80 of file RandomDistributor.h.
Referenced by ODDistrict::addSink(), ODDistrict::addSource(), ROJTREdge::chooseNext(), MSRouteHandler::closeRoute(), GUISettingsHandler::getEventDistribution(), MSRouteHandler::myEndElement(), RORouteHandler::myEndElement(), MSStateHandler::myStartElement(), MSTriggeredRerouter::myStartElement(), MSRouteHandler::openRouteDistribution(), MSRouteHandler::openVehicleTypeDistribution(), and RORouteHandler::openVehicleTypeDistribution().
|
inline |
Clears the distribution.
Definition at line 128 of file RandomDistributor.h.
Referenced by MSTriggeredRerouter::myEndElement().
|
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 103 of file RandomDistributor.h.
Referenced by GUIApplicationWindow::checkGamingEvents(), ROJTREdge::chooseNext(), ODDistrict::getRandomSink(), ODDistrict::getRandomSource(), MSTriggeredRerouter::notifyEnter(), 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 123 of file RandomDistributor.h.
Referenced by GUIApplicationWindow::checkGamingEvents(), ROJTREdge::chooseNext(), MSRouteHandler::closeRouteDistribution(), MSRouteHandler::closeVehicleTypeDistribution(), RORouteHandler::closeVehicleTypeDistribution(), GUISettingsHandler::getEventDistribution(), MSTriggeredRerouter::notifyEnter(), and RODFDetector::writeEmitterDefinition().
|
inline |
Returns the probabilities assigned to the members of the distribution.
See getVals for the corresponding members.
Definition at line 152 of file RandomDistributor.h.
Referenced by MSDevice_Vehroutes::generateOutput(), and MSRouteHandler::openRoute().
|
inline |
Returns the members of the distribution.
See getProbs for the corresponding probabilities.
Definition at line 141 of file RandomDistributor.h.
Referenced by MSInsertionControl::add(), MSDevice_Vehroutes::generateOutput(), ODDistrict::sinkNumber(), and ODDistrict::sourceNumber().
|
private |
the total probability
Definition at line 158 of file RandomDistributor.h.
Referenced by RandomDistributor< std::const std::string >::add(), RandomDistributor< std::const std::string >::clear(), RandomDistributor< std::const std::string >::get(), and RandomDistributor< std::const std::string >::getOverallProb().
|
private |
the corresponding probabilities (acts as a ring buffer if myMaximumSize is reached)
Definition at line 162 of file RandomDistributor.h.
Referenced by RandomDistributor< std::const std::string >::add(), RandomDistributor< std::const std::string >::clear(), RandomDistributor< std::const std::string >::get(), and RandomDistributor< std::const std::string >::getProbs().
|
private |
the members (acts as a ring buffer if myMaximumSize is reached)
Definition at line 160 of file RandomDistributor.h.
Referenced by RandomDistributor< std::const std::string >::add(), RandomDistributor< std::const std::string >::clear(), RandomDistributor< std::const std::string >::get(), and RandomDistributor< std::const std::string >::getVals().