60 throw ProcessError(
"A network was not yet constructed.");
75 &&
OptionsCont::getOptions().getBool(
"keep-vtype-distributions")) {
77 throw ProcessError(
"A network was already constructed.");
95 for (RoutablesMap::iterator routables =
myRoutables.begin(); routables !=
myRoutables.end(); ++routables) {
96 for (
RORoutable*
const r : routables->second) {
127 const std::map<SUMOVehicleClass, double>*
129 std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i =
myRestrictions.find(
id);
154 WRITE_ERROR(
"The TAZ '" +
id +
"' occurs at least twice.");
163 myDistricts[id] = std::make_pair(std::vector<std::string>(), std::vector<std::string>());
171 WRITE_ERROR(
"The TAZ '" + tazID +
"' is unknown.");
175 if (edge ==
nullptr) {
176 WRITE_ERROR(
"The edge '" + edgeID +
"' for TAZ '" + tazID +
"' is unknown.");
216 if (options.
isSet(
"output-file") && options.
getString(
"output-file") !=
"") {
219 myRoutesOutput->
writeAttr(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").
writeAttr(
"xsi:noNamespaceSchemaLocation",
"http://sumo.dlr.de/xsd/routes_file.xsd");
221 if (options.
exists(
"alternatives-output") && options.
isSet(
"alternatives-output")
222 && !(options.
exists(
"write-trips") && options.
getBool(
"write-trips"))) {
227 if (options.
isSet(
"vtype-output")) {
230 myTypesOutput->
writeAttr(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").
writeAttr(
"xsi:noNamespaceSchemaLocation",
"http://sumo.dlr.de/xsd/routes_file.xsd");
237 if (options.
exists(
"intermodal-network-output") && options.
isSet(
"intermodal-network-output")) {
241 if (options.
exists(
"intermodal-weight-output") && options.
isSet(
"intermodal-weight-output")) {
270 if (myThreadPool.size() > 0) {
271 myThreadPool.clear();
291 if (type !=
nullptr) {
296 return it2->second->get();
338 WRITE_ERROR(
"The vehicle type '" + type->
id +
"' occurs at least twice.");
371 WRITE_ERROR(
"Another vehicle with the id '" +
id +
"' exists.");
397 WRITE_ERROR(
"Another person with the id '" + person->
getID() +
"' exists.");
404 myContainers.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
411 for (
const auto& i :
myFlows) {
418 while (pars->
depart < time) {
427 for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->
stops.begin(); stop != newPars->
stops.end(); ++stop) {
428 if (stop->until >= 0) {
429 stop->until += pars->
depart - origDepart;
454 if (depart >= time +
DELTA_T) {
463 for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->
stops.begin(); stop != newPars->
stops.end(); ++stop) {
464 if (stop->until >= 0) {
465 stop->until += depart - pars->
depart;
471 if (type ==
nullptr) {
490 std::map<const int, std::vector<RORoutable*> > bulkVehs;
492 if (i->first >= time) {
495 for (
RORoutable*
const routable : i->second) {
500 WRITE_WARNING(
"Bulking different maximum speeds ('" + first->
getID() +
"' and '" + routable->
getID() +
"') may lead to suboptimal routes.");
503 WRITE_WARNING(
"Bulking different vehicle classes ('" + first->
getID() +
"' and '" + routable->
getID() +
"') may lead to invalid routes.");
508 for (std::map<
const int, std::vector<RORoutable*> >::const_iterator i = bulkVehs.begin(); i != bulkVehs.end(); ++i) {
510 if (myThreadPool.size() > 0) {
512 myThreadPool.add(
new RoutingTask(first, removeLoops,
myErrorHandler), workerIndex);
513 myThreadPool.add(
new BulkmodeTask(
true), workerIndex);
514 for (std::vector<RORoutable*>::const_iterator j = i->second.begin() + 1; j != i->second.end(); ++j) {
515 myThreadPool.add(
new RoutingTask(*j, removeLoops,
myErrorHandler), workerIndex);
517 myThreadPool.add(
new BulkmodeTask(
false), workerIndex);
519 if (workerIndex == (
int)myThreadPool.size()) {
525 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 (
RORoutable*
const routable : i->second) {
561 if (maxNumThreads > 0) {
562 const int numThreads = (int)myThreadPool.size();
563 if (numThreads == 0) {
567 new WorkerThread(myThreadPool, provider);
570 if (numThreads < maxNumThreads && myThreadPool.isFull()) {
571 new WorkerThread(myThreadPool, provider);
573 myThreadPool.add(
new RoutingTask(routable, removeLoops,
myErrorHandler));
583 myThreadPool.waitAll();
589 RoutablesMap::iterator routables =
myRoutables.begin();
591 ContainerMap::iterator container =
myContainers.begin();
594 if (routableTime >= time && containerTime >= time) {
595 lastTime =
MIN2(routableTime, containerTime);
598 const SUMOTime minTime =
MIN2(routableTime, containerTime);
599 if (routableTime == minTime) {
601 if (lastTime != routableTime && lastTime != -1) {
603 if (options.
getInt(
"stats-period") >= 0 && ((int)routableTime % options.
getInt(
"stats-period")) == 0) {
607 lastTime = routableTime;
608 for (
const RORoutable*
const r : routables->second) {
630 if (containerTime == minTime) {
669 for (
const auto& a : stop.second->accessPos) {
675 if (i.second->line !=
"") {
677 const std::vector<SUMOVehicleParameter::Stop>* addStops =
nullptr;
707 if (stop !=
nullptr) {
721 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)
void writeWeights(OutputDevice &dev)
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.
int getEdgeNumber() const
Returns the total number of edges the network contains including internal edges.
void close()
Closes the device and removes it from the dictionary.
SumoXMLTag
Numbers representing SUMO-XML - element names.
bool isPartOfFlow() const
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.
void writeNetwork(OutputDevice &dev)
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...
void writeIntermodal(const OptionsCont &options, ROIntermodalRouter &router) const
Writes the intermodal network and weights if requested.
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.
double getMaxSpeed() const
Returns the vehicle's maximum speed.
int size() const
Returns the number of stored items within the container.
Structure representing possible vehicle parameter.
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person 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.
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.
void checkFlows(SUMOTime time, MsgHandler *errorHandler)
weights: time range begin
std::string busstop
(Optional) bus stop if one is assigned to the stop
bool myHaveActiveFlows
whether any flows are still active
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.
const std::string DEFAULT_BIKETYPE_ID
bool hasPermissions() const
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
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
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 OptionsCont & getOptions()
Retrieves the options.
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
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.
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.
void openOutput(const OptionsCont &options)
Opens the output for computed routes.
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.
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.
bool isPublicTransport() const
void addContainer(const SUMOTime depart, const std::string desc)
bool getRoutingSuccess() const
RoutablesMap myRoutables
Known routables.
bool myDefaultBikeTypeMayBeDeleted
Whether the default bicycle type was already used or can still be replaced.
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.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
ContainerMap myContainers
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.
bool myDefaultVTypeMayBeDeleted
Whether the default vehicle type was already used or can still be replaced.
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
const std::string & getID() const
Returns the id of the routable.
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.
Definition of vehicle stop (position and duration)
virtual void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)=0
int parametersSet
Information for the router which parameter were set.
bool isInternal() const
return whether this edge is an internal edge
SUMOAbstractRouter< E, V > & getVehicleRouter() const
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)
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=nullptr)
int myReadRouteNo
The number of read routes.
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.
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.
virtual void addSuccessor(ROEdge *s, ROEdge *via=nullptr, std::string dir="")
Adds information about a connected edge.
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.
const std::string getStoppingPlaceName(const std::string &id) const
return the name for the given stopping place id
virtual bool addEdge(ROEdge *edge)
an aggreagated-output interval
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(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
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)
bool remove(const std::string &id, const bool del=true)
Removes an item.
#define WRITE_MESSAGE(msg)
const int VTYPEPARS_VEHICLECLASS_SET
bool addPerson(ROPerson *person)
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, const RORouterProvider &provider, SUMOTime time)
Computes routes described by their definitions and saves them.
void addAccess(const std::string &stopId, const E *stopEdge, const double pos, const double length, const SumoXMLTag category)
Adds access edges for stopping places to the intermodal network.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Network * getNetwork() const
std::string id
The vehicle's id.
bool myDefaultPedTypeMayBeDeleted
Whether the default pedestrian type was already used or can still be replaced.
void setPermissionsFound()
void setFunction(SumoXMLEdgeFunc func)
Sets the function of the edge.