51 #ifdef CHECK_MEMORY_LEAKS 53 #endif // CHECK_MEMORY_LEAKS 70 throw ProcessError(
"A network was not yet constructed.");
83 throw ProcessError(
"A network was already constructed.");
97 for (RoutablesMap::iterator routables =
myRoutables.begin(); routables !=
myRoutables.end(); ++routables) {
98 for (std::deque<RORoutable*>::iterator r = routables->second.begin(); r != routables->second.end(); ++r) {
109 for (std::map<std::string, SUMOVehicleParameter::Stop*>::iterator it =
myBusStops.begin(); it !=
myBusStops.end(); ++it) {
129 const std::map<SUMOVehicleClass, SUMOReal>*
131 std::map<std::string, std::map<SUMOVehicleClass, SUMOReal> >::const_iterator i =
myRestrictions.find(
id);
156 WRITE_ERROR(
"The TAZ '" +
id +
"' occurs at least twice.");
165 myDistricts[id] = std::make_pair(std::vector<std::string>(), std::vector<std::string>());
173 WRITE_ERROR(
"The TAZ '" + tazID +
"' is unknown.");
178 WRITE_ERROR(
"The edge '" + edgeID +
"' for TAZ '" + tazID +
"' is unknown.");
203 std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it =
myBusStops.find(
id);
205 WRITE_ERROR(
"The bus stop '" +
id +
"' occurs at least twice.");
214 std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it =
myContainerStops.find(
id);
216 WRITE_ERROR(
"The container stop '" +
id +
"' occurs at least twice.");
225 std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it =
myParkingAreas.find(
id);
227 WRITE_ERROR(
"The parking area '" +
id +
"' occurs at least twice.");
242 if (options.
isSet(
"output-file") && options.
getString(
"output-file") !=
"") {
245 myRoutesOutput->
writeAttr(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").
writeAttr(
"xsi:noNamespaceSchemaLocation",
"http://sumo.dlr.de/xsd/routes_file.xsd");
247 if (altFilename !=
"") {
252 if (options.
isSet(
"vtype-output") && options.
getString(
"vtype-output") !=
"") {
255 myTypesOutput->
writeAttr(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").
writeAttr(
"xsi:noNamespaceSchemaLocation",
"http://sumo.dlr.de/xsd/routes_file.xsd");
276 if (myThreadPool.size() > 0) {
277 myThreadPool.clear();
299 return it2->second->get();
341 WRITE_ERROR(
"The vehicle type '" + type->
id +
"' occurs at least twice.");
367 WRITE_ERROR(
"Another vehicle with the id '" +
id +
"' exists.");
393 WRITE_ERROR(
"Another person with the id '" + person->
getID() +
"' exists.");
400 myContainers.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
406 std::vector<std::string> toRemove;
411 while (pars->
depart < time) {
413 toRemove.push_back(i->first);
421 for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->
stops.begin(); stop != newPars->
stops.end(); ++stop) {
422 if (stop->until >= 0) {
423 stop->until += pars->
depart - origDepart;
449 if (depart >= time +
DELTA_T) {
458 for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->
stops.begin(); stop != newPars->
stops.end(); ++stop) {
459 if (stop->until >= 0) {
460 stop->until += depart - pars->
depart;
479 toRemove.push_back(i->first);
483 for (std::vector<std::string>::const_iterator i = toRemove.begin(); i != toRemove.end(); ++i) {
491 std::map<const int, std::vector<RORoutable*> > bulkVehs;
493 if (i->first >= time) {
496 for (std::deque<RORoutable*>::const_iterator r = i->second.begin(); r != i->second.end(); ++r) {
502 WRITE_WARNING(
"Bulking different maximum speeds ('" + first->
getID() +
"' and '" + routable->
getID() +
"') may lead to suboptimal routes.");
505 WRITE_WARNING(
"Bulking different vehicle classes ('" + first->
getID() +
"' and '" + routable->
getID() +
"') may lead to invalid routes.");
510 for (std::map<
const int, std::vector<RORoutable*> >::const_iterator i = bulkVehs.begin(); i != bulkVehs.end(); ++i) {
512 if (myThreadPool.size() > 0) {
514 myThreadPool.add(
new RoutingTask(first, removeLoops,
myErrorHandler), workerIndex);
515 myThreadPool.add(
new BulkmodeTask(
true), workerIndex);
516 for (std::vector<RORoutable*>::const_iterator j = i->second.begin() + 1; j != i->second.end(); ++j) {
517 myThreadPool.add(
new RoutingTask(*j, removeLoops,
myErrorHandler), workerIndex);
519 myThreadPool.add(
new BulkmodeTask(
false), workerIndex);
521 if (workerIndex == (
int)myThreadPool.size()) {
527 for (std::vector<RORoutable*>::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
543 const bool removeLoops = options.
getBool(
"remove-loops");
544 const int maxNumThreads = options.
getInt(
"routing-threads");
546 if (options.
getBool(
"bulk-routing")) {
548 while ((
int)myThreadPool.size() < maxNumThreads) {
549 new WorkerThread(myThreadPool, provider);
555 if (i->first >= time) {
558 for (std::deque<RORoutable*>::const_iterator r = i->second.begin(); r != i->second.end(); ++r) {
562 if (maxNumThreads > 0) {
563 const int numThreads = (int)myThreadPool.size();
564 if (numThreads == 0) {
568 new WorkerThread(myThreadPool, provider);
571 if (numThreads < maxNumThreads && myThreadPool.isFull()) {
572 new WorkerThread(myThreadPool, provider);
574 myThreadPool.add(
new RoutingTask(routable, removeLoops,
myErrorHandler));
584 myThreadPool.waitAll();
590 RoutablesMap::iterator routables =
myRoutables.begin();
592 ContainerMap::iterator container =
myContainers.begin();
595 if (routableTime >= time && containerTime >= time) {
596 lastTime =
MIN2(routableTime, containerTime);
599 const SUMOTime minTime =
MIN2(routableTime, containerTime);
600 if (routableTime == minTime) {
601 const RORoutable*
const r = routables->second.front();
603 if (lastTime != routableTime && lastTime != -1) {
605 if (options.
getInt(
"stats-period") >= 0 && ((int) routableTime % options.
getInt(
"stats-period")) == 0) {
609 lastTime = routableTime;
626 routables->second.pop_front();
627 if (routables->second.empty()) {
632 if (containerTime == minTime) {
662 const std::map<std::string, ROEdge*>&
673 for (std::multimap<std::string, SUMOReal>::const_iterator a = i->second->accessPos.begin(); a != i->second->accessPos.end(); ++a) {
679 if (i->second->line !=
"") {
681 const std::vector<SUMOVehicleParameter::Stop>* addStops = 0;
689 for (std::deque<RORoutable*>::const_iterator r = i->second.begin(); r != i->second.end(); ++r) {
718 myRoutable->computeRoute(*static_cast<WorkerThread*>(context), myRemoveLoops,
myErrorHandler);
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
bool addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource)
SUMOReal repetitionProbability
The probability for emitting a vehicle per second.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
bool hasPermissions() const
void close()
Closes the device and removes it from the dictionary.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const SUMOReal speed)
Adds a restriction for an edge type.
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > myDistricts
traffic assignment zones with sources and sinks
std::string vtypeid
The vehicle's type id.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
bool getRoutingSuccess() const
int myNumInternalEdges
The number of internal edges in the dictionary.
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
bool erase(const std::string &id)
Removes the named item from the container.
virtual bool add(const std::string &id, T item)
Adds an item.
Structure representing possible vehicle parameter.
static void adaptIntermodalRouter(ROIntermodalRouter &router)
void addNode(RONode *node)
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed ...
static SUMOReal rand()
Returns a random real number in [0, 1)
int repetitionsDone
The number of times the vehicle was already inserted.
void checkFlows(SUMOTime time, MsgHandler *errorHandler)
EdgeFunc getFunc() const
Returns the function of the edge.
NamedObjectCont< ROEdge * > myEdges
Known edges.
An internal edge which models vehicles driving across a junction. This is currently not used for rout...
void addAccess(const std::string &stopId, const E *stopEdge, const SUMOReal pos)
void setFunc(EdgeFunc func)
Sets the function of the edge.
int myDiscardedRouteNo
The number of discarded routes.
A map of named object pointers.
std::map< std::string, std::vector< SUMOTime > > myDepartures
Departure times for randomized flows.
OutputDevice * myTypesOutput
The file to write the vehicle types into.
const std::string DEFAULT_VTYPE_ID
int myWrittenRouteNo
The number of written routes.
#define WRITE_WARNING(msg)
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
const std::map< std::string, ROEdge * > & getEdgeMap() const
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
void openOutput(const OptionsCont &options, const std::string altFilename="")
Opens the output for computed routes.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
void addParkingArea(const std::string &id, SUMOVehicleParameter::Stop *stop)
T get(const std::string &id) const
Retrieves an item.
void clear()
Removes all items from the container (deletes them, too)
bool writeHeader(const SumoXMLTag &rootElement)
std::set< std::string > myPersonIDs
Known person ids.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
A routable thing such as a vehicle or person.
const std::string & getID() const
Returns the id.
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
SUMOReal getMaxSpeed() const
Returns the vehicle's maximum speed.
A vehicle as used by router.
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary ...
root element of a route file
bool addRouteDef(RORouteDef *def)
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=0)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
virtual const ROEdge * getDepartEdge() const =0
std::string routeid
The vehicle's route id.
OutputDevice * myRoutesOutput
The file to write the computed routes into.
void addContainer(const SUMOTime depart, const std::string desc)
std::map< std::string, SUMOVehicleParameter::Stop * > myContainerStops
Known container stops.
virtual bool remove(const std::string &id)
Removes an item.
RoutablesMap myRoutables
Known routables.
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
SUMOTime depart
The vehicle's departure time.
std::map< std::string, std::map< SUMOVehicleClass, SUMOReal > > myRestrictions
The vehicle class specific speed restrictions.
std::map< std::string, SUMOVehicleParameter::Stop * > myParkingAreas
Known parking areas.
ContainerMap myContainers
virtual bool furtherStored()
Returns the information whether further vehicles, persons or containers are stored.
A person as used by router.
static RONet * myInstance
Unique instance of RONet.
SUMOAbstractRouter< E, V > & getVehicleRouter() const
int getEdgeNo() const
Returns the total number of edges the network contains including internal edges.
bool myDefaultVTypeMayBeDeleted
Whether no vehicle type has been loaded yet.
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
void createBulkRouteRequests(const RORouterProvider &provider, const SUMOTime time, const bool removeLoops)
vehicle is a passenger car (a "normal" car)
A basic edge for routing applications.
bool onlyReferenced
Information whether this is a type-stub, being only referenced but not defined (needed by routers) ...
std::string line
The vehicle's line (mainly for public transport)
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
virtual void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)=0
const IDMap & getMyMap() const
ROEdge * getEdgeForLaneID(const std::string &laneID) const
Retrieves an edge from the network when the lane id is given.
int setParameter
Information for the router which parameter were set.
The router's network representation.
bool addDistrict(const std::string id, ROEdge *source, ROEdge *sink)
Structure representing possible vehicle parameter.
virtual void addSuccessor(ROEdge *s, std::string dir="")
Adds information about a connected edge.
int myReadRouteNo
The number of read routes.
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
const std::string DEFAULT_PEDTYPE_ID
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
const std::string & getID() const
Returns the id of the vehicle.
Definition of vehicle stop (position and duration)
A storage for options typed value containers)
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
Base class for a vehicle's route definition.
std::string id
The vehicle type's id.
void addBusStop(const std::string &id, SUMOVehicleParameter::Stop *stop)
virtual bool addEdge(ROEdge *edge)
std::set< std::string > myVehIDs
Known vehicle ids.
virtual ~RONet()
Destructor.
const RORoute * getFirstRoute() const
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
A thread repeatingly calculating incoming tasks.
MsgHandler * myErrorHandler
handler for ignorable error messages
Base class for nodes used by the router.
NamedObjectCont< RONode * > myNodes
Known nodes.
void write(OutputDevice &os, OutputDevice *const altos, OutputDevice *const typeos, OptionsCont &options) const
Saves the routable including the vehicle type (if it was not saved before).
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
An edge representing a whole district.
#define WRITE_MESSAGE(msg)
const int VTYPEPARS_VEHICLECLASS_SET
void addContainerStop(const std::string &id, SUMOVehicleParameter::Stop *stop)
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle parameter.
SUMOVehicleClass getVClass() const
bool addPerson(ROPerson *person)
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the list of stops this route contains.
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, const RORouterProvider &provider, SUMOTime time)
Computes routes described by their definitions and saves them.
std::map< std::string, SUMOVehicleParameter::Stop * > myBusStops
Known bus stops.
int getNumericalID() const
Returns the index (numeric id) of the edge.
std::string id
The vehicle's id.
bool myDefaultPedTypeMayBeDeleted
Whether no pedestrian type has been loaded yet.
void setPermissionsFound()
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
const std::map< SUMOVehicleClass, SUMOReal > * getRestrictions(const std::string &id) const
Returns the restrictions for an edge type If no restrictions are present, 0 is returned.
int size() const
Returns the number of items within the container.