66 throw ProcessError(
"A network was not yet constructed.");
79 throw ProcessError(
"A network was already constructed.");
93 for (RoutablesMap::iterator routables =
myRoutables.begin(); routables !=
myRoutables.end(); ++routables) {
94 for (std::deque<RORoutable*>::iterator r = routables->second.begin(); r != routables->second.end(); ++r) {
105 for (std::map<std::string, SUMOVehicleParameter::Stop*>::iterator it =
myBusStops.begin(); it !=
myBusStops.end(); ++it) {
125 const std::map<SUMOVehicleClass, double>*
127 std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i =
myRestrictions.find(
id);
152 WRITE_ERROR(
"The TAZ '" +
id +
"' occurs at least twice.");
161 myDistricts[id] = std::make_pair(std::vector<std::string>(), std::vector<std::string>());
169 WRITE_ERROR(
"The TAZ '" + tazID +
"' is unknown.");
174 WRITE_ERROR(
"The edge '" + edgeID +
"' for TAZ '" + tazID +
"' is unknown.");
199 std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it =
myBusStops.find(
id);
201 WRITE_ERROR(
"The bus stop '" +
id +
"' occurs at least twice.");
210 std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it =
myContainerStops.find(
id);
212 WRITE_ERROR(
"The container stop '" +
id +
"' occurs at least twice.");
221 std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it =
myParkingAreas.find(
id);
223 WRITE_ERROR(
"The parking area '" +
id +
"' occurs at least twice.");
238 if (options.
isSet(
"output-file") && options.
getString(
"output-file") !=
"") {
241 myRoutesOutput->
writeAttr(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").
writeAttr(
"xsi:noNamespaceSchemaLocation",
"http://sumo.dlr.de/xsd/routes_file.xsd");
243 if (altFilename !=
"") {
248 if (options.
isSet(
"vtype-output") && options.
getString(
"vtype-output") !=
"") {
251 myTypesOutput->
writeAttr(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").
writeAttr(
"xsi:noNamespaceSchemaLocation",
"http://sumo.dlr.de/xsd/routes_file.xsd");
272 if (myThreadPool.size() > 0) {
273 myThreadPool.clear();
295 return it2->second->get();
337 WRITE_ERROR(
"The vehicle type '" + type->
id +
"' occurs at least twice.");
363 WRITE_ERROR(
"Another vehicle with the id '" +
id +
"' exists.");
389 WRITE_ERROR(
"Another person with the id '" + person->
getID() +
"' exists.");
396 myContainers.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
402 std::vector<std::string> toRemove;
407 while (pars->
depart < time) {
409 toRemove.push_back(i->first);
417 for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->
stops.begin(); stop != newPars->
stops.end(); ++stop) {
418 if (stop->until >= 0) {
419 stop->until += pars->
depart - origDepart;
445 if (depart >= time +
DELTA_T) {
454 for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->
stops.begin(); stop != newPars->
stops.end(); ++stop) {
455 if (stop->until >= 0) {
456 stop->until += depart - pars->
depart;
475 toRemove.push_back(i->first);
479 for (std::vector<std::string>::const_iterator i = toRemove.begin(); i != toRemove.end(); ++i) {
487 std::map<const int, std::vector<RORoutable*> > bulkVehs;
489 if (i->first >= time) {
492 for (std::deque<RORoutable*>::const_iterator r = i->second.begin(); r != i->second.end(); ++r) {
498 WRITE_WARNING(
"Bulking different maximum speeds ('" + first->
getID() +
"' and '" + routable->
getID() +
"') may lead to suboptimal routes.");
501 WRITE_WARNING(
"Bulking different vehicle classes ('" + first->
getID() +
"' and '" + routable->
getID() +
"') may lead to invalid routes.");
506 for (std::map<
const int, std::vector<RORoutable*> >::const_iterator i = bulkVehs.begin(); i != bulkVehs.end(); ++i) {
508 if (myThreadPool.size() > 0) {
510 myThreadPool.add(
new RoutingTask(first, removeLoops,
myErrorHandler), workerIndex);
511 myThreadPool.add(
new BulkmodeTask(
true), workerIndex);
512 for (std::vector<RORoutable*>::const_iterator j = i->second.begin() + 1; j != i->second.end(); ++j) {
513 myThreadPool.add(
new RoutingTask(*j, removeLoops,
myErrorHandler), workerIndex);
515 myThreadPool.add(
new BulkmodeTask(
false), workerIndex);
517 if (workerIndex == (
int)myThreadPool.size()) {
523 for (std::vector<RORoutable*>::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
539 const bool removeLoops = options.
getBool(
"remove-loops");
540 const int maxNumThreads = options.
getInt(
"routing-threads");
542 if (options.
getBool(
"bulk-routing")) {
544 while ((
int)myThreadPool.size() < maxNumThreads) {
545 new WorkerThread(myThreadPool, provider);
551 if (i->first >= time) {
554 for (std::deque<RORoutable*>::const_iterator r = i->second.begin(); r != i->second.end(); ++r) {
558 if (maxNumThreads > 0) {
559 const int numThreads = (int)myThreadPool.size();
560 if (numThreads == 0) {
564 new WorkerThread(myThreadPool, provider);
567 if (numThreads < maxNumThreads && myThreadPool.isFull()) {
568 new WorkerThread(myThreadPool, provider);
570 myThreadPool.add(
new RoutingTask(routable, removeLoops,
myErrorHandler));
580 myThreadPool.waitAll();
586 RoutablesMap::iterator routables =
myRoutables.begin();
588 ContainerMap::iterator container =
myContainers.begin();
591 if (routableTime >= time && containerTime >= time) {
592 lastTime =
MIN2(routableTime, containerTime);
595 const SUMOTime minTime =
MIN2(routableTime, containerTime);
596 if (routableTime == minTime) {
597 const RORoutable*
const r = routables->second.front();
599 if (lastTime != routableTime && lastTime != -1) {
601 if (options.
getInt(
"stats-period") >= 0 && ((int) routableTime % options.
getInt(
"stats-period")) == 0) {
605 lastTime = routableTime;
622 routables->second.pop_front();
623 if (routables->second.empty()) {
628 if (containerTime == minTime) {
658 const std::map<std::string, ROEdge*>&
669 for (std::multimap<std::string, double>::const_iterator a = i->second->accessPos.begin(); a != i->second->accessPos.end(); ++a) {
675 if (i->second->line !=
"") {
677 const std::vector<SUMOVehicleParameter::Stop>* addStops = 0;
685 for (std::deque<RORoutable*>::const_iterator r = i->second.begin(); r != i->second.end(); ++r) {
714 myRoutable->computeRoute(*static_cast<WorkerThread*>(context), myRemoveLoops,
myErrorHandler);
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
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)
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
void close()
Closes the device and removes it from the dictionary.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
SUMOVehicleClass getVClass() const
int getNumericalID() const
Returns the index (numeric id) of the edge.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
ROEdge * getEdgeForLaneID(const std::string &laneID) const
Retrieves an edge from the network when the lane id is given.
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
virtual const ROEdge * getDepartEdge() const =0
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.
Represents a generic random distribution.
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.
int getEdgeNo() const
Returns the total number of edges the network contains including internal edges.
double getMaxSpeed() const
Returns the vehicle's maximum speed.
int size() const
Returns the number of items within the container.
Structure representing possible vehicle parameter.
static void adaptIntermodalRouter(ROIntermodalRouter &router)
void addNode(RONode *node)
const RORoute * getFirstRoute() const
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).
T get(const std::string &id) const
Retrieves an item.
double repetitionProbability
The probability for emitting a vehicle per second.
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed ...
int repetitionsDone
The number of times the vehicle was already inserted.
void checkFlows(SUMOTime time, MsgHandler *errorHandler)
NamedObjectCont< ROEdge * > myEdges
Known edges.
const std::map< SUMOVehicleClass, double > * getRestrictions(const std::string &id) const
Returns the restrictions for an edge type If no restrictions are present, 0 is returned.
bool hasPermissions() const
An internal edge which models vehicles driving across a junction. This is currently not used for rout...
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void setFunc(EdgeFunc func)
Sets the function of the edge.
const std::string & getID() const
Returns the id.
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
void addAccess(const std::string &stopId, const E *stopEdge, const double pos)
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
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)
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)
void clear()
Removes all items from the container (deletes them, too)
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
bool writeHeader(const SumoXMLTag &rootElement)
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter *> *vehTypeDistribution)
Adds a vehicle type distribution.
std::set< std::string > myPersonIDs
Known person ids.
A routable thing such as a vehicle or person.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
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 addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=0)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
std::string routeid
The vehicle's route id.
OutputDevice * myRoutesOutput
The file to write the computed routes into.
EdgeFunc getFunc() const
Returns the function of the edge.
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.
const IDMap & getMyMap() const
bool getRoutingSuccess() const
RoutablesMap myRoutables
Known routables.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the list of stops this route contains.
SUMOTime depart
The vehicle's departure time.
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.
static double rand()
Returns a random real number in [0, 1)
A person as used by router.
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle parameter.
static RONet * myInstance
Unique instance of RONet.
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)
const std::string & getID() const
Returns the id of the vehicle.
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) ...
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
std::string line
The vehicle's line (mainly for public transport)
virtual void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)=0
SUMOAbstractRouter< E, V > & getVehicleRouter() const
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.
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
const std::string DEFAULT_PEDTYPE_ID
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
Definition of vehicle stop (position and duration)
A storage for options typed value containers)
const std::map< std::string, ROEdge * > & getEdgeMap() const
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.
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.
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
An edge representing a whole district.
#define WRITE_MESSAGE(msg)
const int VTYPEPARS_VEHICLECLASS_SET
void addContainerStop(const std::string &id, SUMOVehicleParameter::Stop *stop)
bool addPerson(ROPerson *person)
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.
std::string id
The vehicle's id.
bool myDefaultPedTypeMayBeDeleted
Whether no pedestrian type has been loaded yet.
void setPermissionsFound()