SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RONet Class Reference

The router's network representation. More...

#include <RONet.h>

Inheritance diagram for RONet:
RODFNet

Public Member Functions

void closeOutput ()
 closes the file output for computed routes More...
 
const std::map< std::string,
ROEdge * > & 
getEdgeMap () const
 
unsigned int getEdgeNo () const
 Returns the number of edges thenetwork contains. More...
 
ROEdgegetRandomDestination ()
 Returns a random edge which may be used as an ending point. More...
 
const ROEdgegetRandomDestination () const
 Returns a random edge which may be used as an ending point. More...
 
ROEdgegetRandomSource ()
 Returns a random edge which may be used as a starting point. More...
 
const ROEdgegetRandomSource () const
 Returns a random edge which may be used as a starting point. More...
 
bool hasRestrictions () const
 
void openOutput (const std::string &filename, bool useAlternatives, const std::string &typefilename)
 Opens the output for computed routes. More...
 
 RONet ()
 Constructor. More...
 
void setRestrictionFound ()
 
virtual ~RONet ()
 Destructor. More...
 
Insertion and retrieval of graph parts
virtual bool addEdge (ROEdge *edge)
 
ROEdgegetEdge (const std::string &name) const
 Retrieves an edge from the network. More...
 
void addNode (RONode *node)
 
RONodegetNode (const std::string &id) const
 Retrieves an node from the network. More...
 
Insertion and retrieval of vehicle types, vehicles, routes, and route definitions
bool checkVType (const std::string &id)
 Checks whether the vehicle type (distribution) may be added. More...
 
virtual bool addVehicleType (SUMOVTypeParameter *type)
 Adds a read vehicle type definition to the network. More...
 
bool addVTypeDistribution (const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
 Adds a vehicle type distribution. More...
 
SUMOVTypeParametergetVehicleTypeSecure (const std::string &id)
 Retrieves the named vehicle type. More...
 
bool addRouteDef (RORouteDef *def)
 
RORouteDefgetRouteDef (const std::string &name) const
 Returns the named route definition. More...
 
virtual bool addVehicle (const std::string &id, ROVehicle *veh)
 
Processing stored vehicle definitions
SUMOTime saveAndRemoveRoutesUntil (OptionsCont &options, SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime time)
 Computes routes described by their definitions and saves them. More...
 
virtual bool furtherStored ()
 Returns the information whether further vehicles are stored. More...
 

Protected Types

typedef std::map< std::string,
RandomDistributor
< SUMOVTypeParameter * > * > 
VTypeDistDictType
 Vehicle type distribution dictionary type. More...
 

Protected Member Functions

void checkSourceAndDestinations () const
 Initialises the lists of source and destination edges. More...
 
bool computeRoute (OptionsCont &options, SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const veh)
 
ROVehicleContgetVehicles ()
 return vehicles for use by RouteAggregator More...
 

Protected Attributes

bool myDefaultVTypeMayBeDeleted
 Whether no vehicle type was loaded. More...
 
std::vector< ROEdge * > myDestinationEdges
 List of destination edges. More...
 
unsigned int myDiscardedRouteNo
 The number of discarded routes. More...
 
NamedObjectCont< ROEdge * > myEdges
 Known edges. More...
 
bool myHaveRestrictions
 Whether the network contains edges which not all vehicles may pass. More...
 
NamedObjectCont< RONode * > myNodes
 Known nodes. More...
 
unsigned int myReadRouteNo
 The number of read routes. More...
 
OutputDevicemyRouteAlternativesOutput
 The file to write the computed route alternatives into. More...
 
NamedObjectCont< RORouteDef * > myRoutes
 Known routes. More...
 
OutputDevicemyRoutesOutput
 The file to write the computed routes into. More...
 
std::vector< ROEdge * > mySourceEdges
 List of source edges. More...
 
OutputDevicemyTypesOutput
 The file to write the vehicle types into. More...
 
ROVehicleCont myVehicles
 Known vehicles. More...
 
NamedObjectCont
< SUMOVTypeParameter * > 
myVehicleTypes
 Known vehicle types. More...
 
std::set< std::string > myVehIDs
 Known vehicle ids. More...
 
VTypeDistDictType myVTypeDistDict
 A distribution of vehicle types (probability->vehicle type) More...
 
unsigned int myWrittenRouteNo
 The number of written routes. More...
 

Private Member Functions

RONetoperator= (const RONet &src)
 Invalidated assignment operator. More...
 
 RONet (const RONet &src)
 Invalidated copy constructor. More...
 

Friends

class RouteAggregator
 

Detailed Description

The router's network representation.

A router network is responsible for watching loaded edges, nodes,!!!

Todo:
Vehicle ids are not tracked; it may happen that the same id is added twice...

Definition at line 69 of file RONet.h.

Member Typedef Documentation

typedef std::map< std::string, RandomDistributor<SUMOVTypeParameter*>* > RONet::VTypeDistDictType
protected

Vehicle type distribution dictionary type.

Definition at line 349 of file RONet.h.

Constructor & Destructor Documentation

RONet::RONet ( )
RONet::~RONet ( )
virtual

Destructor.

Definition at line 74 of file RONet.cpp.

References ROVehicleCont::clear(), NamedObjectCont< T >::clear(), myEdges, myNodes, myRoutes, myVehicles, and myVehicleTypes.

RONet::RONet ( const RONet src)
private

Invalidated copy constructor.

Member Function Documentation

bool RONet::addEdge ( ROEdge edge)
virtual
void RONet::addNode ( RONode node)
bool RONet::addVehicleType ( SUMOVTypeParameter type)
virtual

Adds a read vehicle type definition to the network.

If the vehicle type definition is already known (another one with the same id exists), false is returned, and the vehicle type is deleted.

Parameters
[in]defThe vehicle type to add
Returns
Whether the vehicle type could be added

Definition at line 202 of file RONet.cpp.

References NamedObjectCont< T >::add(), checkVType(), SUMOVTypeParameter::id, myVehicleTypes, and WRITE_ERROR.

Referenced by getVehicleTypeSecure(), RORDLoader_TripDefs::myEndElement(), RORouteHandler::myEndElement(), and RORDLoader_SUMOBase::myEndElement().

bool RONet::addVTypeDistribution ( const std::string &  id,
RandomDistributor< SUMOVTypeParameter * > *  vehTypeDistribution 
)

Adds a vehicle type distribution.

If another vehicle type (or distribution) with the same id exists, false is returned. Otherwise, the vehicle type distribution is added to the internal vehicle type distribution container "myVTypeDistDict".

This control get responsible for deletion of the added vehicle type distribution.

Parameters
[in]idThe id of the distribution to add
[in]vehTypeDistributionThe vehicle type distribution to add
Returns
Whether the vehicle type could be added

Definition at line 215 of file RONet.cpp.

References checkVType(), and myVTypeDistDict.

Referenced by RORouteHandler::closeVehicleTypeDistribution().

void RONet::checkSourceAndDestinations ( ) const
protected

Initialises the lists of source and destination edges.

Definition at line 376 of file RONet.cpp.

References ROEdge::ET_SINK, ROEdge::ET_SOURCE, NamedObjectCont< T >::getMyMap(), ROEdge::getType(), myDestinationEdges, myEdges, and mySourceEdges.

Referenced by getRandomDestination(), and getRandomSource().

bool RONet::checkVType ( const std::string &  id)

Checks whether the vehicle type (distribution) may be added.

This method checks also whether the default type may still be replaced

Parameters
[in]idThe id of the vehicle type (distribution) to add
Returns
Whether the type (distribution) may be added

Definition at line 184 of file RONet.cpp.

References DEFAULT_VTYPE_ID, NamedObjectCont< T >::get(), myDefaultVTypeMayBeDeleted, myVehicleTypes, myVTypeDistDict, and NamedObjectCont< T >::remove().

Referenced by addVehicleType(), and addVTypeDistribution().

void RONet::closeOutput ( )

closes the file output for computed routes

Definition at line 136 of file RONet.cpp.

References OutputDevice::close(), myRouteAlternativesOutput, myRoutesOutput, and myTypesOutput.

Referenced by computeRoutes().

bool RONet::furtherStored ( )
virtual

Returns the information whether further vehicles are stored.

Definition at line 321 of file RONet.cpp.

References myVehicles, and NamedObjectCont< T >::size().

Referenced by ROLoader::processRoutesStepWise().

ROEdge* RONet::getEdge ( const std::string &  name) const
inline
const std::map< std::string, ROEdge * > & RONet::getEdgeMap ( ) const
unsigned int RONet::getEdgeNo ( ) const

Returns the number of edges thenetwork contains.

Definition at line 396 of file RONet.cpp.

References myEdges, and NamedObjectCont< T >::size().

Referenced by computeRoutes(), and main().

RONode* RONet::getNode ( const std::string &  id) const
inline

Retrieves an node from the network.

Parameters
[in]nameThe name of the node to retrieve
Returns
The named node if known, otherwise 0
Todo:
Check whether a const pointer may be returned

Definition at line 127 of file RONet.h.

References NamedObjectCont< T >::get(), and myNodes.

Referenced by RONetHandler::parseEdge(), and RONetHandler::parseJunction().

ROEdge * RONet::getRandomDestination ( )

Returns a random edge which may be used as an ending point.

If the list of possible destinations (roads with no successor, "myDestinationEdges") is empty, it is tried to be built, first.

Returns
A random edge from the list of edges with no successor

Definition at line 352 of file RONet.cpp.

References checkSourceAndDestinations(), RandHelper::getRandomFrom(), and myDestinationEdges.

const ROEdge * RONet::getRandomDestination ( ) const

Returns a random edge which may be used as an ending point.

If the list of possible destinations (roads with no successor, "myDestinationEdges") is empty, it is tried to be built, first.

Returns
A random edge from the list of edges with no successor

Definition at line 364 of file RONet.cpp.

References checkSourceAndDestinations(), RandHelper::getRandomFrom(), and myDestinationEdges.

ROEdge * RONet::getRandomSource ( )

Returns a random edge which may be used as a starting point.

If the list of possible source (roads with no predecessor, "mySourceEdges") is empty, it is tried to be built, first.

Returns
A random edge from the list of edges with no predecessor

Definition at line 327 of file RONet.cpp.

References checkSourceAndDestinations(), RandHelper::getRandomFrom(), and mySourceEdges.

const ROEdge * RONet::getRandomSource ( ) const

Returns a random edge which may be used as a starting point.

If the list of possible sources (roads with no predecessor, "mySourceEdges") is empty, it is tried to be built, first.

Returns
A random edge from the list of edges with no predecessor

Definition at line 339 of file RONet.cpp.

References checkSourceAndDestinations(), RandHelper::getRandomFrom(), and mySourceEdges.

RORouteDef* RONet::getRouteDef ( const std::string &  name) const
inline

Returns the named route definition.

Parameters
[in]nameThe name of the route definition to retrieve
Returns
The named route definition if known, otherwise 0
Todo:

Check whether a const pointer may be returned

Rename myRoutes to myRouteDefinitions

Definition at line 209 of file RONet.h.

References NamedObjectCont< T >::get(), and myRoutes.

Referenced by RORouteHandler::closeRoute(), RORDLoader_SUMOBase::closeVehicle(), RORouteHandler::closeVehicle(), RORouteHandler::openRoute(), and RORouteHandler::openRouteDistribution().

ROVehicleCont& RONet::getVehicles ( )
inlineprotected

return vehicles for use by RouteAggregator

Definition at line 330 of file RONet.h.

References myVehicles.

SUMOVTypeParameter * RONet::getVehicleTypeSecure ( const std::string &  id)

Retrieves the named vehicle type.

If the named vehicle type was not added to the net before, a default vehicle type which consists of the id only is generated, added to the net and returned.

Only if the name is "", 0 is returned.

Parameters
[in]idThe id of the vehicle type to return
Returns
The named vehicle type
Todo:
Check whether a const pointer may be returned

Definition at line 154 of file RONet.cpp.

References addVehicleType(), DEFAULT_VTYPE_ID, NamedObjectCont< T >::get(), SUMOVTypeParameter::id, myDefaultVTypeMayBeDeleted, myVehicleTypes, myVTypeDistDict, and SUMOVTypeParameter::onlyReferenced.

Referenced by RORDLoader_SUMOBase::closeVehicle(), RORouteHandler::closeVehicle(), computeRoutes(), RORDLoader_TripDefs::myEndElement(), RORDGenerator_ODAmounts::myEndFlowAmountDef(), and RORouteHandler::openVehicleTypeDistribution().

bool RONet::hasRestrictions ( ) const

Definition at line 408 of file RONet.cpp.

References myHaveRestrictions.

Referenced by computeRoutes().

void RONet::openOutput ( const std::string &  filename,
bool  useAlternatives,
const std::string &  typefilename 
)

Opens the output for computed routes.

If the second parameter is true, a second file for route alternatives will be opened. The route alternatives files is simply the given name with ".alt" appended (before the ".xml"-suffix). If one of the file outputs can not be build, an IOError is thrown

Parameters
[in]filenameThe (base) name of the file(s) to create
[in]useAlternativesWhether a file for writing alternatives shall be created
[in]filenameThe name of the vtype file to create, "" means no separate types

Definition at line 110 of file RONet.cpp.

References OutputDevice::getDevice(), myRouteAlternativesOutput, myRoutesOutput, myTypesOutput, SUMO_TAG_ROUTES, OutputDevice::writeHeader(), and OutputDevice::writeXMLHeader().

Referenced by computeRoutes().

RONet& RONet::operator= ( const RONet src)
private

Invalidated assignment operator.

SUMOTime RONet::saveAndRemoveRoutesUntil ( OptionsCont options,
SUMOAbstractRouter< ROEdge, ROVehicle > &  router,
SUMOTime  time 
)

Computes routes described by their definitions and saves them.

As long a vehicle with a departure time not larger than the given exists, its route is computed and it is written and removed from the internal container.

Parameters
[in]optionsThe options used during this process
[in]routerThe router to use for routes computation
[in]optionsThe time until which route definitions shall be processed
Returns
The last seen departure time>=time

Definition at line 278 of file RONet.cpp.

References computeRoute(), ROVehicleCont::erase(), NamedObjectCont< T >::erase(), OptionsCont::getBool(), ROVehicle::getDepartureTime(), Named::getID(), ROVehicle::getID(), OptionsCont::getInt(), ROVehicle::getRouteDefinition(), ROVehicleCont::getTopVehicle(), myDiscardedRouteNo, myReadRouteNo, myRouteAlternativesOutput, myRoutes, myRoutesOutput, myTypesOutput, myVehicles, myWrittenRouteNo, ROVehicle::saveAllAsXML(), NamedObjectCont< T >::size(), toString(), and WRITE_MESSAGE.

Referenced by ROLoader::makeSingleStep(), and ROLoader::processAllRoutes().

void RONet::setRestrictionFound ( )

Definition at line 414 of file RONet.cpp.

References myHaveRestrictions.

Referenced by RONetHandler::parseLane().

Friends And Related Function Documentation

friend class RouteAggregator
friend

Definition at line 70 of file RONet.h.

Field Documentation

bool RONet::myDefaultVTypeMayBeDeleted
protected

Whether no vehicle type was loaded.

Definition at line 354 of file RONet.h.

Referenced by checkVType(), and getVehicleTypeSecure().

std::vector<ROEdge*> RONet::myDestinationEdges
mutableprotected

List of destination edges.

Definition at line 366 of file RONet.h.

Referenced by checkSourceAndDestinations(), and getRandomDestination().

unsigned int RONet::myDiscardedRouteNo
protected

The number of discarded routes.

Definition at line 381 of file RONet.h.

Referenced by saveAndRemoveRoutesUntil().

NamedObjectCont<ROEdge*> RONet::myEdges
protected

Known edges.

Definition at line 343 of file RONet.h.

Referenced by addEdge(), checkSourceAndDestinations(), getEdge(), getEdgeMap(), getEdgeNo(), and ~RONet().

bool RONet::myHaveRestrictions
protected

Whether the network contains edges which not all vehicles may pass.

Definition at line 387 of file RONet.h.

Referenced by hasRestrictions(), and setRestrictionFound().

NamedObjectCont<RONode*> RONet::myNodes
protected

Known nodes.

Definition at line 340 of file RONet.h.

Referenced by addNode(), getNode(), and ~RONet().

unsigned int RONet::myReadRouteNo
protected

The number of read routes.

Definition at line 378 of file RONet.h.

Referenced by addVehicle(), and saveAndRemoveRoutesUntil().

OutputDevice* RONet::myRouteAlternativesOutput
protected

The file to write the computed route alternatives into.

Definition at line 372 of file RONet.h.

Referenced by closeOutput(), openOutput(), and saveAndRemoveRoutesUntil().

NamedObjectCont<RORouteDef*> RONet::myRoutes
protected

Known routes.

Definition at line 357 of file RONet.h.

Referenced by addRouteDef(), getRouteDef(), saveAndRemoveRoutesUntil(), and ~RONet().

OutputDevice* RONet::myRoutesOutput
protected

The file to write the computed routes into.

Definition at line 369 of file RONet.h.

Referenced by closeOutput(), openOutput(), and saveAndRemoveRoutesUntil().

std::vector<ROEdge*> RONet::mySourceEdges
mutableprotected

List of source edges.

Definition at line 363 of file RONet.h.

Referenced by checkSourceAndDestinations(), and getRandomSource().

OutputDevice* RONet::myTypesOutput
protected

The file to write the vehicle types into.

Definition at line 375 of file RONet.h.

Referenced by closeOutput(), openOutput(), and saveAndRemoveRoutesUntil().

ROVehicleCont RONet::myVehicles
protected

Known vehicles.

Definition at line 360 of file RONet.h.

Referenced by addVehicle(), furtherStored(), getVehicles(), saveAndRemoveRoutesUntil(), and ~RONet().

NamedObjectCont<SUMOVTypeParameter*> RONet::myVehicleTypes
protected

Known vehicle types.

Definition at line 346 of file RONet.h.

Referenced by addVehicleType(), checkVType(), getVehicleTypeSecure(), RONet(), and ~RONet().

std::set<std::string> RONet::myVehIDs
protected

Known vehicle ids.

Definition at line 337 of file RONet.h.

Referenced by addVehicle().

VTypeDistDictType RONet::myVTypeDistDict
protected

A distribution of vehicle types (probability->vehicle type)

Definition at line 351 of file RONet.h.

Referenced by addVTypeDistribution(), checkVType(), and getVehicleTypeSecure().

unsigned int RONet::myWrittenRouteNo
protected

The number of written routes.

Definition at line 384 of file RONet.h.

Referenced by saveAndRemoveRoutesUntil().


The documentation for this class was generated from the following files: