65 throw ProcessError(
"A network was not yet constructed.");
78 &&
OptionsCont::getOptions().getBool(
"keep-vtype-distributions")) {
80 throw ProcessError(
"A network was already constructed.");
94 for (RoutablesMap::iterator routables =
myRoutables.begin(); routables !=
myRoutables.end(); ++routables) {
95 for (
RORoutable*
const r : routables->second) {
126 const std::map<SUMOVehicleClass, double>*
128 std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i =
myRestrictions.find(
id);
153 WRITE_ERROR(
"The TAZ '" +
id +
"' occurs at least twice.");
162 myDistricts[id] = std::make_pair(std::vector<std::string>(), std::vector<std::string>());
170 WRITE_ERROR(
"The TAZ '" + tazID +
"' is unknown.");
175 WRITE_ERROR(
"The edge '" + edgeID +
"' for TAZ '" + tazID +
"' is unknown.");
215 if (options.
isSet(
"output-file") && options.
getString(
"output-file") !=
"") {
218 myRoutesOutput->
writeAttr(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").
writeAttr(
"xsi:noNamespaceSchemaLocation",
"http://sumo.dlr.de/xsd/routes_file.xsd");
220 if (options.
exists(
"alternatives-output") && options.
isSet(
"alternatives-output")) {
225 if (options.
isSet(
"vtype-output")) {
228 myTypesOutput->
writeAttr(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").
writeAttr(
"xsi:noNamespaceSchemaLocation",
"http://sumo.dlr.de/xsd/routes_file.xsd");
235 if (options.
exists(
"intermodal-network-output") && options.
isSet(
"intermodal-network-output")) {
239 if (options.
exists(
"intermodal-weight-output") && options.
isSet(
"intermodal-weight-output")) {
268 if (myThreadPool.size() > 0) {
269 myThreadPool.clear();
291 return it2->second->get();
333 WRITE_ERROR(
"The vehicle type '" + type->
id +
"' occurs at least twice.");
366 WRITE_ERROR(
"Another vehicle with the id '" +
id +
"' exists.");
392 WRITE_ERROR(
"Another person with the id '" + person->
getID() +
"' exists.");
399 myContainers.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
405 std::vector<std::string> toRemove;
406 for (
const auto& i :
myFlows) {
410 while (pars->
depart < time) {
412 toRemove.push_back(i.first);
420 for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->
stops.begin(); stop != newPars->
stops.end(); ++stop) {
421 if (stop->until >= 0) {
422 stop->until += pars->
depart - origDepart;
446 if (depart >= time +
DELTA_T) {
455 for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->
stops.begin(); stop != newPars->
stops.end(); ++stop) {
456 if (stop->until >= 0) {
457 stop->until += depart - pars->
depart;
476 toRemove.push_back(i.first);
480 for (std::vector<std::string>::const_iterator i = toRemove.begin(); i != toRemove.end(); ++i) {
488 std::map<const int, std::vector<RORoutable*> > bulkVehs;
490 if (i->first >= time) {
493 for (
RORoutable*
const routable : i->second) {
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 (
RORoutable*
const routable : i->second) {
557 if (maxNumThreads > 0) {
558 const int numThreads = (int)myThreadPool.size();
559 if (numThreads == 0) {
563 new WorkerThread(myThreadPool, provider);
566 if (numThreads < maxNumThreads && myThreadPool.isFull()) {
567 new WorkerThread(myThreadPool, provider);
569 myThreadPool.add(
new RoutingTask(routable, removeLoops,
myErrorHandler));
579 myThreadPool.waitAll();
585 RoutablesMap::iterator routables =
myRoutables.begin();
587 ContainerMap::iterator container =
myContainers.begin();
590 if (routableTime >= time && containerTime >= time) {
591 lastTime =
MIN2(routableTime, containerTime);
594 const SUMOTime minTime =
MIN2(routableTime, containerTime);
595 if (routableTime == minTime) {
597 if (lastTime != routableTime && lastTime != -1) {
599 if (options.
getInt(
"stats-period") >= 0 && ((int)routableTime % options.
getInt(
"stats-period")) == 0) {
603 lastTime = routableTime;
604 for (
const RORoutable*
const r : routables->second) {
626 if (containerTime == minTime) {
665 for (std::multimap<std::string, double>::const_iterator a = stop.second->accessPos.begin(); a != stop.second->accessPos.end(); ++a) {
671 if (i.second->line !=
"") {
673 const std::vector<SUMOVehicleParameter::Stop>* addStops = 0;
705 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)
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
std::map< SumoXMLTag, NamedObjectCont< SUMOVehicleParameter::Stop * > > myStoppingPlaces
Known bus / train / container stops and parking areas.
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
void writeIntermodal(const OptionsCont &options, ROIntermodalRouter &router) const
Writes the intermodal network and weights if requested.
bool hasPermissions() const
void close()
Closes the device and removes it from the dictionary.
SumoXMLTag
Numbers representing SUMO-XML - element names.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
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...
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 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.
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)
double repetitionProbability
The probability for emitting a vehicle per second.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
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.
weights: time range begin
void writeNetwork(OutputDevice &dev)
NamedObjectCont< ROEdge * > myEdges
Known edges.
void writeWeights(OutputDevice &dev)
int myDiscardedRouteNo
The number of discarded routes.
std::map< std::string, std::vector< SUMOTime > > myDepartures
Departure times for randomized flows.
std::vector< const RORoutable * > myPTVehicles
vehicles to keep for public transport routing
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)
static OptionsCont & getOptions()
Retrieves the options.
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
double getMaxSpeed() const
Returns the vehicle's maximum speed.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
bool add(const std::string &id, T item)
Adds an item.
T get(const std::string &id) const
Retrieves an item.
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.
void openOutput(const OptionsCont &options)
Opens the output for computed routes.
const std::string & getID() const
Returns the id.
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
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.
bool isInternal() const
return whether this edge is an internal edge
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=0)
void addAccess(const std::string &stopId, const E *stopEdge, const double pos, const SumoXMLTag category)
Adds access edges for stopping places to the intermodal network.
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.
void addContainer(const SUMOTime depart, const std::string desc)
RoutablesMap myRoutables
Known routables.
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
SUMOTime depart
The vehicle's departure time.
ContainerMap myContainers
virtual bool furtherStored()
Returns the information whether further vehicles, persons or containers are stored.
bool isPartOfFlow() const
A person as used by router.
static RONet * myInstance
Unique instance of RONet.
SUMOAbstractRouter< E, V > & getVehicleRouter() const
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 bool myKeepVTypeDist
whether to keep the the vtype distribution in output
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
int parametersSet
Information for the router which parameter were set.
ROEdge * getEdgeForLaneID(const std::string &laneID) const
Retrieves an edge from the network when the lane id is given.
The router's network representation.
bool addDistrict(const std::string id, ROEdge *source, ROEdge *sink)
Structure representing possible vehicle parameter.
A train stop (alias for bus stop)
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.
void addStoppingPlace(const std::string &id, const SumoXMLTag category, SUMOVehicleParameter::Stop *stop)
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
int getEdgeNumber() const
Returns the total number of edges the network contains including internal edges.
const std::string DEFAULT_PEDTYPE_ID
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
const std::string & getID() const
Returns the id of the routable.
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.
virtual bool addEdge(ROEdge *edge)
an aggreagated-output interval
IntermodalRouter< E, L, N, V > & getIntermodalRouter() const
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
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.
bool isPublicTransport() 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).
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.
bool remove(const std::string &id, const bool del=true)
Removes an item.
#define WRITE_MESSAGE(msg)
const int VTYPEPARS_VEHICLECLASS_SET
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.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
void checkFlows(SUMOTime time, MsgHandler *errorHandler, const bool keepPT)
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.
int size() const
Returns the number of stored items within the container.
void setFunction(SumoXMLEdgeFunc func)
Sets the function of the edge.