65 myVehicleTypes(), myDefaultVTypeMayBeDeleted(true),
66 myDefaultPedTypeMayBeDeleted(true),
67 myDefaultBikeTypeMayBeDeleted(true),
68 myDefaultTaxiTypeMayBeDeleted(true),
69 myDefaultRailTypeMayBeDeleted(true),
70 myHaveActiveFlows(true),
71 myRoutesOutput(nullptr), myRouteAlternativesOutput(nullptr), myTypesOutput(nullptr),
72 myReadRouteNo(0), myDiscardedRouteNo(0), myWrittenRouteNo(0),
73 myHavePermissions(false),
74 myHaveParamRestrictions(false),
75 myNumInternalEdges(0),
76 myErrorHandler(
OptionsCont::getOptions().exists(
"ignore-errors")
78 myKeepVTypeDist(
OptionsCont::getOptions().exists(
"keep-vtype-distributions")
79 &&
OptionsCont::getOptions().getBool(
"keep-vtype-distributions")),
80 myDoPTRouting(!
OptionsCont::getOptions().exists(
"ptline-routing")
81 ||
OptionsCont::getOptions().getBool(
"ptline-routing")),
82 myKeepFlows(
OptionsCont::getOptions().exists(
"keep-flows")
83 &&
OptionsCont::getOptions().getBool(
"keep-flows")),
84 myHasBidiEdges(false),
119 for (
RORoutable*
const r : routables.second) {
142 delete vTypeDist.second;
158 auto it2 = it->second.find(routingType);
159 if (it2 != it->second.end()) {
165 auto it4 = it3->second.find(routingType);
166 if (it4 != it3->second.end()) {
173 auto it2 = it->second.find(routingType);
174 if (it2 != it->second.end()) {
198const std::map<SUMOVehicleClass, double>*
200 std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i =
mySpeedRestrictions.find(
id);
240 myDistricts[id] = std::make_pair(std::vector<std::string>(), std::vector<std::string>());
252 if (edge ==
nullptr) {
253 WRITE_ERRORF(
TL(
"The edge '%' for TAZ '%' is unknown."), edgeID, tazID);
270 const std::string tazID = item.first;
272 WRITE_WARNINGF(
TL(
"A TAZ with id '%' already exists. Not building junction TAZ."), tazID);
275 const std::string sourceID = tazID +
"-source";
276 const std::string sinkID = tazID +
"-sink";
286 const RONode* junction = item.second;
288 if (!edge->isInternal()) {
289 const_cast<ROEdge*
>(edge)->addSuccessor(sink);
290 district.second.push_back(edge->getID());
294 if (!edge->isInternal()) {
296 district.first.push_back(edge->getID());
305 for (
const auto& item : bidiMap) {
307 if (bidi ==
nullptr) {
310 item.first->setBidiEdge(bidi);
342 if (options.
isSet(
"output-file") && options.
getString(
"output-file") !=
"") {
350 if (options.
exists(
"alternatives-output") && options.
isSet(
"alternatives-output")
351 && !(options.
exists(
"write-trips") && options.
getBool(
"write-trips"))) {
359 if (options.
isSet(
"vtype-output")) {
368 if (options.
exists(
"intermodal-network-output") && options.
isSet(
"intermodal-network-output")) {
372 if (options.
exists(
"intermodal-weight-output") && options.
isSet(
"intermodal-weight-output")) {
401 if (myThreadPool.size() > 0) {
402 myThreadPool.clear();
424 if (type !=
nullptr) {
429 return it2->second->get();
506 delete vehTypeDistribution;
551 throw ProcessError(
TLF(
"Requesting departure time for unknown vehicle '%'", vehID));
592 myContainers.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
599 for (
const auto& i :
myFlows) {
609 if (type ==
nullptr) {
613 if (dist !=
nullptr) {
614 WRITE_WARNINGF(
"Keeping flow '%' with a vTypeDistribution can lead to invalid routes if the distribution contains different vClasses", pars->
id);
635 for (StopParVector::iterator stop = newPars->
stops.begin(); stop != newPars->
stops.end(); ++stop) {
636 if (stop->until >= 0) {
637 stop->until += pars->
depart - origDepart;
639 if (stop->arrival >= 0) {
640 stop->arrival += pars->
depart - origDepart;
646 if (type ==
nullptr) {
668 if (depart >= time +
DELTA_T) {
677 for (StopParVector::iterator stop = newPars->
stops.begin(); stop != newPars->
stops.end(); ++stop) {
678 if (stop->until >= 0) {
679 stop->until += depart - pars->
depart;
681 if (stop->arrival >= 0) {
682 stop->arrival += depart - pars->
depart;
688 if (type ==
nullptr) {
707 std::map<const int, std::vector<RORoutable*> > bulkVehs;
710 if (i->first >= time) {
713 for (
RORoutable*
const routable : i->second) {
714 const ROEdge*
const depEdge = routable->getDepartEdge();
718 if (first->
getMaxSpeed() != routable->getMaxSpeed()) {
719 WRITE_WARNINGF(
TL(
"Bulking different maximum speeds ('%' and '%') may lead to suboptimal routes."), first->
getID(), routable->getID());
721 if (first->
getVClass() != routable->getVClass()) {
722 WRITE_WARNINGF(
TL(
"Bulking different vehicle classes ('%' and '%') may lead to invalid routes."), first->
getID(), routable->getID());
729 if ((
int)bulkVehs.size() < numBulked) {
730 WRITE_MESSAGE(
TLF(
"Using bulk-mode for % entities from % origins", numBulked, bulkVehs.size()));
732 for (std::map<
const int, std::vector<RORoutable*> >::const_iterator i = bulkVehs.begin(); i != bulkVehs.end(); ++i) {
734 if (myThreadPool.size() > 0) {
737 myThreadPool.add(
new RoutingTask(r, removeLoops,
myErrorHandler), workerIndex);
739 myThreadPool.add(
new BulkmodeTask(
true), workerIndex);
743 myThreadPool.add(
new BulkmodeTask(
false), workerIndex);
745 if (workerIndex == (
int)myThreadPool.size()) {
769 const bool removeLoops = options.
getBool(
"remove-loops");
771 const int maxNumThreads = options.
getInt(
"routing-threads");
774 if (options.
getBool(
"bulk-routing")) {
776 while ((
int)myThreadPool.size() < maxNumThreads) {
777 new WorkerThread(myThreadPool, provider);
783 if (i->first >= time) {
786 for (
RORoutable*
const routable : i->second) {
789 if (maxNumThreads > 0) {
790 const int numThreads = (int)myThreadPool.size();
791 if (numThreads == 0) {
795 new WorkerThread(myThreadPool, provider);
798 if (numThreads < maxNumThreads && myThreadPool.isFull()) {
799 new WorkerThread(myThreadPool, provider);
801 myThreadPool.add(
new RoutingTask(routable, removeLoops,
myErrorHandler));
811 myThreadPool.waitAll();
814 const double scale = options.
exists(
"scale-suffix") ? options.
getFloat(
"scale") : 1;
818 RoutablesMap::iterator routables =
myRoutables.begin();
820 ContainerMap::iterator container =
myContainers.begin();
823 if (routableTime >= time && containerTime >= time) {
824 lastTime =
MIN2(routableTime, containerTime);
827 const SUMOTime minTime =
MIN2(routableTime, containerTime);
829 if (routableTime == minTime) {
831 if (lastTime != routableTime && lastTime != -1) {
833 if (options.
getInt(
"stats-period") >= 0 && ((
int)routableTime % options.
getInt(
"stats-period")) == 0) {
837 lastTime = routableTime;
838 for (
const RORoutable*
const r : routables->second) {
840 if (r->getRoutingSuccess()) {
849 if (!r->isPublicTransport() || r->isPartOfFlow()) {
862 if (containerTime == minTime) {
911 for (
const auto& stop : stopType.second) {
913 stop.second->startPos, stop.second->endPos, 0., element,
false, taxiWait);
916 for (
const auto& a : stop.second->accessPos) {
918 std::get<1>(a), std::get<1>(a), std::get<2>(a),
SUMO_TAG_BUS_STOP,
true, taxiWait);
925 if (i.second->line !=
"") {
942 if (!edge->isTazConnector() && (edge->getPermissions() &
SVC_PEDESTRIAN) != 0 && (edge->getPermissions() &
SVC_TAXI) != 0) {
963 for (
const auto& item :
myEdges) {
964 if (item.second->hasStoredEffort()) {
975 if (stop !=
nullptr) {
987 if (stop !=
nullptr) {
999 throw ProcessError(
TLF(
"Already loaded prohibition for edge '%'. (Only one prohibition per edge is supported)", edge->
getID()));
1009 throw ProcessError(
TLF(
"Already loaded prohibition for lane '%'. (Only one prohibition per lane is supported)", lane->
getID()));
1011 assert(prohibition.
end > prohibition.
begin);
1029 for (
ROEdge* pred : lane->getEdge().getPredecessors()) {
1030 pred->resetSuccessors();
1032 if (t == rp.
begin) {
1050 myRoutable->computeRoute(*
static_cast<WorkerThread*
>(context), myRemoveLoops, myErrorHandler);
@ TAXI_PICKUP_ANYWHERE
taxi customer may be picked up anywhere
#define WRITE_WARNINGF(...)
#define WRITE_ERRORF(...)
#define WRITE_MESSAGE(msg)
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
const long long int VTYPEPARS_VEHICLECLASS_SET
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const std::string DEFAULT_TAXITYPE_ID
const std::string DEFAULT_RAILTYPE_ID
const std::string DEFAULT_PEDTYPE_ID
const std::string DEFAULT_VTYPE_ID
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_RAIL
vehicle is a not electrified rail
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_TAXI
vehicle is a taxi
@ SVC_PEDESTRIAN
pedestrian
const std::string DEFAULT_BIKETYPE_ID
std::vector< SUMOVehicleParameter::Stop > StopParVector
@ TRIGGERED
The departure is person triggered.
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
int getScalingQuota(double frac, long long int loaded)
Returns the number of instances of the current object that shall be emitted given the number of loade...
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void addCarAccess(const E *edge, SUMOVehicleClass svc, double traveltime)
Adds access edges for transfering from walking to vehicle use.
void addAccess(const std::string &stopId, const E *stopEdge, const double startPos, const double endPos, const double length, const SumoXMLTag category, bool isAccess, double taxiWait)
Adds access edges for stopping places to the intermodal network.
void addSchedule(const SUMOVehicleParameter &pars, const StopParVector *addStops=nullptr)
Network * getNetwork() const
void writeWeights(OutputDevice &dev)
int getCarWalkTransfer() const
void writeNetwork(OutputDevice &dev)
A thread repeatingly calculating incoming tasks.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
const std::string & getID() const
Returns the id.
T get(const std::string &id) const
Retrieves an item.
int size() const
Returns the number of stored items within the container.
bool remove(const std::string &id, const bool del=true)
Removes an item.
bool add(const std::string &id, T item)
Adds an item.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool exists(const std::string &name) const
Returns the information whether the named option is known.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed
void close()
Closes the device and removes it from the dictionary.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false, const bool escape=false)
writes a named attribute
virtual bool isNull()
returns the information whether the device will discard all output
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="", const int maximumDepth=2)
Creates the device using the output definition stored in the named option.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >(), bool includeConfig=true)
Writes an XML header with optional configuration.
Interface for building instances of router-edges.
virtual ROEdge * buildEdge(const std::string &name, RONode *from, RONode *to, const int priority, const std::string &type, const std::string &routingType)=0
Builds an edge with the given name.
A basic edge for routing applications.
void resetSuccessors()
reset after lane permissions changes
int getNumericalID() const
Returns the index (numeric id) of the edge.
void setFunction(SumoXMLEdgeFunc func)
Sets the function of the edge.
bool isInternal() const
return whether this edge is an internal edge
void setOtherTazConnector(const ROEdge *edge)
const std::vector< ROLane * > & getLanes() const
Returns this edge's lanes.
virtual void addSuccessor(ROEdge *s, ROEdge *via=nullptr, std::string dir="")
Adds information about a connected edge.
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
A single lane the router may use.
ROEdge & getEdge() const
Returns the lane's edge.
The router's network representation.
bool knowsVType(const std::string &id) const
returns whether a vehicle type or distribution with the given id was already loaded
void createBulkRouteRequests(const RORouterProvider &provider, const SUMOTime time, const bool removeLoops)
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
bool myHaveProcessedRoutes
int myNumInternalEdges
The number of internal edges in the dictionary.
bool myDefaultPedTypeMayBeDeleted
Whether the default pedestrian type was already used or can still be replaced.
void setPermissionsFound()
void updateLaneProhibitions(SUMOTime begin)
bool myDefaultRailTypeMayBeDeleted
Whether the default rail type was already used or can still be replaced.
std::map< std::string, std::map< SUMOVehicleClass, double > > mySpeedRestrictions
The vehicle class specific speed restrictions.
bool myDefaultVTypeMayBeDeleted
Whether the default vehicle type was already used or can still be replaced.
void checkFlows(SUMOTime time, MsgHandler *errorHandler)
std::map< SUMOVehicleClass, std::map< std::string, double > > myVClassPreferences
Preferences for routing.
std::map< double, std::set< const ROLane * > > myLaneProhibitionTimes
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.
const RandomDistributor< SUMOVTypeParameter * > * getVTypeDistribution(const std::string &id)
Retrieves the named vehicle type distribution.
double getPreference(const std::string &routingType, const SUMOVTypeParameter &pars) const
retriefe edge type specific routing preference
ContainerMap myContainers
std::set< std::string > myPersonIDs
Known person ids.
std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > myDistricts
traffic assignment zones with sources and sinks
bool addRouteDef(RORouteDef *def)
void addStoppingPlace(const std::string &id, const SumoXMLTag category, SUMOVehicleParameter::Stop *stop)
bool knowsVehicle(const std::string &id) const
returns whether a vehicle with the given id was already loaded
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary
bool myHaveActiveFlows
whether any flows are still active
std::map< std::string, SUMOTime > myVehIDs
Known vehicle ids and their departure.
void openOutput(const OptionsCont &options)
Opens the output for computed routes.
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
bool myDefaultBikeTypeMayBeDeleted
Whether the default bicycle type was already used or can still be replaced.
RoutablesMap myRoutables
Known routables.
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
SUMOTime getDeparture(const std::string &vehID) const
returns departure time for the given vehicle id
bool myHasBidiEdges
whether the network contains bidirectional railway edges
bool addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource)
void addSpeedRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
MsgHandler * myErrorHandler
handler for ignorable error messages
void writeIntermodal(const OptionsCont &options, ROIntermodalRouter &router) const
Writes the intermodal network and weights if requested.
NamedObjectCont< RONode * > myNodes
Known nodes.
const std::string getStoppingPlaceElement(const std::string &id) const
return the element name for the given stopping place id
void addContainer(const SUMOTime depart, const std::string desc)
void addProhibition(const ROEdge *edge, const RouterProhibition &prohibition)
static void adaptIntermodalRouter(ROIntermodalRouter &router)
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
bool furtherStored()
Returns the information whether further vehicles, persons or containers are stored.
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
OutputDevice * myRoutesOutput
The file to write the computed routes into.
bool addPerson(ROPerson *person)
int myWrittenRouteNo
The number of written routes.
static RONet * myInstance
Unique instance of RONet.
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, const RORouterProvider &provider, SUMOTime time)
Computes routes described by their definitions and saves them.
void addLaneProhibition(const ROLane *lane, const RouterProhibition &prohibition)
virtual bool addEdge(ROEdge *edge)
bool myDefaultTaxiTypeMayBeDeleted
Whether the default taxi type was already used or can still be replaced.
std::map< SumoXMLTag, NamedObjectCont< SUMOVehicleParameter::Stop * > > myStoppingPlaces
Known bus / train / container stops and parking areas.
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
bool hasPermissions() const
void setBidiEdges(const std::map< ROEdge *, std::string > &bidiMap)
add a taz for every junction unless a taz with the same id already exists
ROLane * getLane(const std::string &laneID) const
Retrieves a lane rom the network given its id.
int myDiscardedRouteNo
The number of discarded routes.
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
std::vector< const RORoutable * > myPTVehicles
vehicles to keep for public transport routing
NamedObjectCont< ROEdge * > myEdges
Known edges.
LaneProhibitions myLaneProhibitions
temporary lane closing (rerouters)
void addNode(RONode *node)
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
void addJunctionTaz(ROAbstractEdgeBuilder &eb)
add a taz for every junction unless a taz with the same id already exists
OutputDevice * myTypesOutput
The file to write the vehicle types into.
const bool myKeepFlows
whether to preserve flows
const bool myDoPTRouting
whether to calculate routes for public transport
Prohibitions myProhibitions
temporary edge closing (rerouters)
const bool myKeepVTypeDist
whether to keep the vtype distribution in output
virtual ~RONet()
Destructor.
const std::string getStoppingPlaceName(const std::string &id) const
return the name for the given stopping place id
std::map< std::string, std::vector< SUMOTime > > myDepartures
Departure times for randomized flows.
int getEdgeNumber() const
Returns the total number of edges the network contains including internal edges.
ROEdge * getEdgeForLaneID(const std::string &laneID) const
Retrieves an edge from the network when the lane id is given.
std::map< std::string, std::map< std::string, double > > myVTypePreferences
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
bool hasLoadedEffort() const
whether efforts were loaded from file
void addPreference(const std::string &routingType, SUMOVehicleClass svc, double prio)
add edge type specific routing preference
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
bool addDistrict(const std::string id, ROEdge *source, ROEdge *sink)
Base class for nodes used by the router.
const ConstROEdgeVector & getOutgoing() const
const ConstROEdgeVector & getIncoming() const
A person as used by router.
A routable thing such as a vehicle or person.
SUMOVehicleClass getVClass() const
bool isPublicTransport() const
bool isPartOfFlow() const
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
const std::string & getID() const
Returns the id of the routable.
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
double getMaxSpeed() const
Returns the vehicle's maximum speed.
Base class for a vehicle's route definition.
std::shared_ptr< const RORoute > getFirstRoute() const
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
A vehicle as used by router.
SUMOTime getDepartureTime() const
Returns the time the vehicle starts at, 0 for triggered vehicles.
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Represents a generic random distribution.
void setBulkMode(const bool mode) const
Structure representing possible vehicle parameter.
long long int parametersSet
Information for the router which parameter were set.
bool onlyReferenced
Information whether this is a type-stub, being only referenced but not defined (needed by routers)
SUMOVehicleClass vehicleClass
The vehicle's class.
std::string id
The vehicle type's id.
Definition of vehicle stop (position and duration)
std::string actType
act Type (only used by Persons) (used by netedit)
std::string busstop
(Optional) bus stop if one is assigned to the stop
Structure representing possible vehicle parameter.
double repetitionProbability
The probability for emitting a vehicle per second.
void incrementFlow(double scale, SumoRNG *rng=nullptr)
increment flow
std::string vtypeid
The vehicle's type id.
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
long long int repetitionsDone
The number of times the vehicle was already inserted.
long long int repetitionNumber
SUMOTime repetitionTotalOffset
The offset between depart and the time for the next vehicle insertions.
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
std::string line
The vehicle's line (mainly for public transport)
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
static int getIndexFromLane(const std::string laneID)
return lane index when given the lane ID
Prohibitions and their estimated end time.
SVCPermissions permissions