SUMO - Simulation of Urban MObility
|
An O/D (origin/destination) matrix. More...
#include <ODMatrix.h>
Data Structures | |
class | cell_by_begin_sorter |
Used for sorting the cells by the begin time they describe. More... | |
class | descending_departure_comperator |
Used for sorting vehicles by their departure (latest first) More... | |
struct | ODVehicle |
An internal representation of a single vehicle. More... |
Public Member Functions | |
void | add (SUMOReal vehicleNumber, SUMOTime begin, SUMOTime end, const std::string &origin, const std::string &destination, const std::string &vehicleType) |
Builds a single cell from the given values, verifying them. | |
void | applyCurve (const Distribution_Points &ps) |
Splits the stored cells dividing them on the given time line. | |
SUMOReal | getNoDiscarded () const |
Returns the number of discarded vehicles. | |
SUMOReal | getNoLoaded () const |
Returns the number of loaded vehicles. | |
SUMOReal | getNoWritten () const |
Returns the number of written vehicles. | |
ODMatrix (const ODDistrictCont &dc) | |
Constructor. | |
void | write (SUMOTime begin, SUMOTime end, OutputDevice &dev, bool uniform, bool noVtype, const std::string &prefix, bool stepLog) |
Writes the vehicles stored in the matrix assigning the sources and sinks. | |
~ODMatrix () | |
Destructor. |
Protected Types | |
typedef std::vector< ODCell * > | CellVector |
Definition of a container for cells. |
Protected Member Functions | |
void | applyCurve (const Distribution_Points &ps, ODCell *cell, CellVector &newCells) |
Splits the given cell dividing it on the given time line and storing the results in the given container. | |
SUMOReal | computeDeparts (ODCell *cell, size_t &vehName, std::vector< ODVehicle > &into, bool uniform, const std::string &prefix) |
Computes the vehicle departs stored in the given cell and saves them in "into". |
Protected Attributes | |
CellVector | myContainer |
The loaded cells. | |
const ODDistrictCont & | myDistricts |
The districts to retrieve sources/sinks from. | |
SUMOReal | myNoDiscarded |
Number of discarded vehicles. | |
SUMOReal | myNoLoaded |
Number of loaded vehicles. | |
SUMOReal | myNoWritten |
Number of written vehicles. |
Private Member Functions | |
ODMatrix (const ODMatrix &s) | |
invalid copy constructor | |
ODMatrix & | operator= (const ODMatrix &s) |
invalid assignment operator |
An O/D (origin/destination) matrix.
This class is the internal representation of a loaded O/D-matrix. Beside being the storage for ODCells, the matrix also contains information about the numbers of loaded, discarded, and written vehicles.
The matrix has a reference to the container of districts stored. This allows to validate added cell descriptions in means that using existing origins/ destinations only is assured.
In addition of being a storage, the matrix is also responsible for writing the results and contains methods for splitting the entries over time.
Definition at line 72 of file ODMatrix.h.
|
protected |
Definition of a container for cells.
Definition at line 194 of file ODMatrix.h.
ODMatrix::ODMatrix | ( | const ODDistrictCont & | dc | ) |
Constructor.
[in] | dc | The district container to obtain referenced distrivts from |
Definition at line 53 of file ODMatrix.cpp.
ODMatrix::~ODMatrix | ( | ) |
|
private |
invalid copy constructor
void ODMatrix::add | ( | SUMOReal | vehicleNumber, |
SUMOTime | begin, | ||
SUMOTime | end, | ||
const std::string & | origin, | ||
const std::string & | destination, | ||
const std::string & | vehicleType | ||
) |
Builds a single cell from the given values, verifying them.
At first, the number of loaded vehicles (myNoLoaded) is incremented by vehicleNumber.
It is checked whether both the origin and the destination exist within the assigned district container (myDistricts). If one of them is missing, an error is generated, if both, a warning, because in the later case the described flow may lay completely beside the processed area. In both cases the given number of vehicles (vehicleNumber) is added to myNoDiscarded.
If the origin/destination districts are known, a cell is built using the given values. This cell is added to the list of known cells (myContainer).
[in] | vehicleNumber | The number of vehicles to store within the cell |
[in] | begin | The begin of the interval the cell is valid for |
[in] | end | The end of the interval the cell is valid for |
[in] | origin | The origin district to use for the cell's flows |
[in] | destination | The destination district to use for the cell's flows |
[in] | vehicleType | The vehicle type to use for the cell's flows |
Definition at line 66 of file ODMatrix.cpp.
References ODCell::begin, ODCell::destination, ODCell::end, NamedObjectCont< T >::get(), myContainer, myDistricts, myNoDiscarded, myNoLoaded, ODCell::origin, ODDistrict::sinkNumber(), ODDistrict::sourceNumber(), toString(), ODCell::vehicleNumber, ODCell::vehicleType, WRITE_ERROR, and WRITE_WARNING.
void ODMatrix::applyCurve | ( | const Distribution_Points & | ps | ) |
Splits the stored cells dividing them on the given time line.
Definition at line 255 of file ODMatrix.cpp.
References myContainer.
Referenced by main().
|
protected |
Splits the given cell dividing it on the given time line and storing the results in the given container.
For the given cell, a list of clones is generated. The number of these is equal to the number of "areas" within the given distribution description (time line in this case) and each clone's vehicleNumber is equal to the given cell's vehicle number multiplied with the area's probability. The clones are stored in the given cell vector.
[in] | ps | The time line to apply |
[in] | cell | The cell to split |
[out] | newCells | The storage to put generated cells into |
Definition at line 240 of file ODMatrix.cpp.
References ODCell::begin, ODCell::destination, ODCell::end, Distribution_Points::getAreaBegin(), Distribution_Points::getAreaEnd(), Distribution_Points::getAreaNo(), Distribution_Points::getAreaPerc(), ODCell::origin, ODCell::vehicleNumber, and ODCell::vehicleType.
|
protected |
Computes the vehicle departs stored in the given cell and saves them in "into".
At first, the number of vehicles to insert is computed using the integer value of the vehicleNumber information from the given cell. In the case vehicleNumber has a fraction, an additional vehicle may be added in the case a chosen random number is lower than this fraction.
If uniform is true, the departure times of the generated vehicles are spread uniformly, otherwise the departure time are chosen randomly from the interval.
The vehicle names are generated by putting the value of vehName after the given prefix. The value of vehName is incremented with each generated vehicle.
The number of left vehicles (the fraction if no additional vehicle was generated) is returned.
[in] | cell | The cell to use |
[in,out] | vehName | An incremented index of the generated vehicle |
[out] | into | The storage to put generated vehicles into |
[in] | uniform | Information whether departure times shallbe uniformly spread or random |
[in] | prefix | A prefix for the vehicle names |
Definition at line 100 of file ODMatrix.cpp.
References ODCell::begin, ODMatrix::ODVehicle::cell, ODMatrix::ODVehicle::depart, ODCell::destination, ODCell::end, ODMatrix::ODVehicle::from, ODDistrictCont::getRandomSinkFromDistrict(), ODDistrictCont::getRandomSourceFromDistrict(), ODMatrix::ODVehicle::id, myDistricts, ODCell::origin, RandHelper::rand(), SUMOReal, ODMatrix::ODVehicle::to, toString(), and ODCell::vehicleNumber.
Referenced by write().
SUMOReal ODMatrix::getNoDiscarded | ( | ) | const |
Returns the number of discarded vehicles.
Returns the value of myNoDiscarded
Definition at line 234 of file ODMatrix.cpp.
References myNoDiscarded.
Referenced by main().
SUMOReal ODMatrix::getNoLoaded | ( | ) | const |
Returns the number of loaded vehicles.
Returns the value of myNoLoaded
Definition at line 222 of file ODMatrix.cpp.
References myNoLoaded.
Referenced by main().
SUMOReal ODMatrix::getNoWritten | ( | ) | const |
Returns the number of written vehicles.
Returns the value of myNoWritten
Definition at line 228 of file ODMatrix.cpp.
References myNoWritten.
Referenced by main().
void ODMatrix::write | ( | SUMOTime | begin, |
SUMOTime | end, | ||
OutputDevice & | dev, | ||
bool | uniform, | ||
bool | noVtype, | ||
const std::string & | prefix, | ||
bool | stepLog | ||
) |
Writes the vehicles stored in the matrix assigning the sources and sinks.
The cells stored in myContainer are sorted, first. Then, for each time step to generate vehicles for, it is checked whether the topmost cell is valid for this time step. If so, vehicles are generated from this cell's description using "computeDeparts" and stored in an internal vector. The pointer is moved and the check is repeated until the current cell is not valid for the current time or no further cells exist.
Then, for the current time step, the internal list of vehicles is sorted and all vehicles that start within this time step are written.
The left fraction of vehicles to insert is saved for each O/D-dependency over time and the number of vehicles to generate is increased as soon as this value is larger than 1, decrementing it.
[in] | begin | The begin time to generate vehicles for |
[in] | end | The end time to generate vehicles for |
[out] | strm | The stream to write the generated vehicle trips to |
[in] | uniform | Information whether departure times shallbe uniformly spread or random |
[in] | noVtype | Whether vtype information shall not be written |
[in] | prefix | A prefix for the vehicle names |
[in] | stepLog | Whether processed time shall be written |
Definition at line 132 of file ODMatrix.cpp.
References OutputDevice::closeTag(), computeDeparts(), OptionsCont::getOptions(), OptionsCont::getString(), OptionsCont::isSet(), MAX2(), myContainer, myNoWritten, OutputDevice::openTag(), SUMOReal, and toString().
Referenced by main().
|
protected |
The loaded cells.
Definition at line 247 of file ODMatrix.h.
Referenced by add(), applyCurve(), write(), and ~ODMatrix().
|
protected |
The districts to retrieve sources/sinks from.
Definition at line 250 of file ODMatrix.h.
Referenced by add(), and computeDeparts().
|
protected |
Number of discarded vehicles.
Definition at line 259 of file ODMatrix.h.
Referenced by add(), and getNoDiscarded().
|
protected |
Number of loaded vehicles.
Definition at line 253 of file ODMatrix.h.
Referenced by add(), and getNoLoaded().
|
protected |
Number of written vehicles.
Definition at line 256 of file ODMatrix.h.
Referenced by getNoWritten(), and write().