SUMO - Simulation of Urban MObility
|
Represents a generic random distribution. More...
#include <RandomDistributor.h>
Public Member Functions | |
void | add (SUMOReal prob, T val, bool checkDuplicates=true) |
Adds a value with an assigned probability to the distribution. | |
void | clear () |
Clears the distribution. | |
T | get () const |
Draw a sample of the distribution. | |
SUMOReal | getOverallProb () const |
Return the sum of the probabilites assigned to the members. | |
const std::vector< SUMOReal > & | 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. | |
~RandomDistributor () | |
Destructor. |
Private Attributes | |
SUMOReal | myProb |
the total probability | |
std::vector< SUMOReal > | 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 54 of file RandomDistributor.h.
|
inline |
Constructor for an empty distribution.
Definition at line 57 of file RandomDistributor.h.
|
inline |
Destructor.
Definition at line 60 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 72 of file RandomDistributor.h.
Referenced by ODDistrict::addSink(), ODDistrict::addSource(), ROJTREdge::chooseNext(), MSRouteHandler::closeRoute(), MSRouteHandler::myEndElement(), MSTriggeredRerouter::myStartElement(), MSRouteProbe::notifyEnter(), MSRouteHandler::openRouteDistribution(), and MSRouteHandler::openVehicleTypeDistribution().
|
inline |
Clears the distribution.
Definition at line 118 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.
Definition at line 93 of file RandomDistributor.h.
Referenced by 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 113 of file RandomDistributor.h.
Referenced by ROJTREdge::chooseNext(), MSRouteHandler::closeRouteDistribution(), MSRouteHandler::closeVehicleTypeDistribution(), MSTriggeredRerouter::notifyEnter(), 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 142 of file RandomDistributor.h.
Referenced by MSRouteHandler::openRoute(), and MSRouteProbe::writeXMLOutput().
|
inline |
Returns the members of the distribution.
See getProbs for the corresponding probabilities.
Definition at line 131 of file RandomDistributor.h.
Referenced by MSInsertionControl::add(), ODDistrict::sinkNumber(), ODDistrict::sourceNumber(), and MSRouteProbe::writeXMLOutput().
|
private |
the total probability
Definition at line 148 of file RandomDistributor.h.
Referenced by RandomDistributor< MSVehicleType * >::add(), RandomDistributor< MSVehicleType * >::clear(), RandomDistributor< MSVehicleType * >::get(), and RandomDistributor< MSVehicleType * >::getOverallProb().
|
private |
the corresponding probabilities
Definition at line 152 of file RandomDistributor.h.
Referenced by RandomDistributor< MSVehicleType * >::add(), RandomDistributor< MSVehicleType * >::clear(), RandomDistributor< MSVehicleType * >::get(), and RandomDistributor< MSVehicleType * >::getProbs().
|
private |
the members
Definition at line 150 of file RandomDistributor.h.
Referenced by RandomDistributor< MSVehicleType * >::add(), RandomDistributor< MSVehicleType * >::clear(), RandomDistributor< MSVehicleType * >::get(), and RandomDistributor< MSVehicleType * >::getVals().