|
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 52 of file RandomDistributor.h.
| RandomDistributor< T >::RandomDistributor | ( | ) | [inline] |
Constructor for an empty distribution.
Definition at line 55 of file RandomDistributor.h.
| RandomDistributor< T >::~RandomDistributor | ( | ) | [inline] |
Destructor.
Definition at line 58 of file RandomDistributor.h.
| void RandomDistributor< T >::add | ( | SUMOReal | prob, |
| T | val, | ||
| bool | checkDuplicates = true |
||
| ) | [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 70 of file RandomDistributor.h.
Referenced by ROJTREdge::chooseNext(), MSRouteHandler::closeRoute(), MSRouteHandler::openRouteDistribution(), and MSRouteHandler::openVehicleTypeDistribution().
| void RandomDistributor< T >::clear | ( | ) | [inline] |
Clears the distribution.
Definition at line 116 of file RandomDistributor.h.
Referenced by MSTriggeredRerouter::myEndElement().
| T RandomDistributor< T >::get | ( | ) | const [inline] |
Draw a sample of the distribution.
A random sample is drawn according to the assigned probabilities.
Definition at line 91 of file RandomDistributor.h.
Referenced by ROJTREdge::chooseNext(), ODDistrict::getRandomSink(), ODDistrict::getRandomSource(), MSTriggeredRerouter::notifyEnter(), and RODFDetector::writeEmitterDefinition().
| SUMOReal RandomDistributor< T >::getOverallProb | ( | ) | const [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 111 of file RandomDistributor.h.
Referenced by ROJTREdge::chooseNext(), MSRouteHandler::closeRouteDistribution(), MSRouteHandler::closeVehicleTypeDistribution(), MSTriggeredRerouter::notifyEnter(), and RODFDetector::writeEmitterDefinition().
| const std::vector<SUMOReal>& RandomDistributor< T >::getProbs | ( | ) | const [inline] |
Returns the probabilities assigned to the members of the distribution.
See getVals for the corresponding members.
Definition at line 140 of file RandomDistributor.h.
Referenced by MSRouteHandler::openRoute().
| const std::vector<T>& RandomDistributor< T >::getVals | ( | ) | const [inline] |
Returns the members of the distribution.
See getProbs for the corresponding probabilities.
Definition at line 129 of file RandomDistributor.h.
Referenced by MSInsertionControl::add(), ODDistrict::sinkNumber(), and ODDistrict::sourceNumber().
SUMOReal RandomDistributor< T >::myProb [private] |
the total probability
Definition at line 146 of file RandomDistributor.h.
Referenced by RandomDistributor< MSVehicleType * >::add(), RandomDistributor< MSVehicleType * >::clear(), RandomDistributor< MSVehicleType * >::get(), and RandomDistributor< MSVehicleType * >::getOverallProb().
std::vector<SUMOReal> RandomDistributor< T >::myProbs [private] |
the corresponding probabilities
Definition at line 150 of file RandomDistributor.h.
Referenced by RandomDistributor< MSVehicleType * >::add(), RandomDistributor< MSVehicleType * >::clear(), RandomDistributor< MSVehicleType * >::get(), and RandomDistributor< MSVehicleType * >::getProbs().
std::vector<T> RandomDistributor< T >::myVals [private] |
the members
Definition at line 148 of file RandomDistributor.h.
Referenced by RandomDistributor< MSVehicleType * >::add(), RandomDistributor< MSVehicleType * >::clear(), RandomDistributor< MSVehicleType * >::get(), and RandomDistributor< MSVehicleType * >::getVals().