 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
60 throw ProcessError(
"A network was not yet constructed.");
65 : myVehicleTypes(), myDefaultVTypeMayBeDeleted(true),
66 myDefaultPedTypeMayBeDeleted(true), myDefaultBikeTypeMayBeDeleted(true),
67 myHaveActiveFlows(true),
68 myRoutesOutput(nullptr), myRouteAlternativesOutput(nullptr), myTypesOutput(nullptr),
69 myReadRouteNo(0), myDiscardedRouteNo(0), myWrittenRouteNo(0),
70 myHavePermissions(false),
71 myNumInternalEdges(0),
72 myErrorHandler(
OptionsCont::getOptions().exists(
"ignore-errors")
74 myKeepVTypeDist(
OptionsCont::getOptions().exists(
"keep-vtype-distributions")
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) {
97 const ROVehicle*
const veh = dynamic_cast<const ROVehicle*>(r);
108 const ROVehicle*
const veh = dynamic_cast<const ROVehicle*>(r);
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) {
619 const ROVehicle*
const veh = dynamic_cast<const ROVehicle*>(r);
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);
A train stop (alias for bus stop)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
bool isInternal() const
return whether this edge is an internal edge
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
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.
bool myHaveActiveFlows
whether any flows are still active
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
int myDiscardedRouteNo
The number of discarded routes.
std::map< std::string, std::vector< SUMOTime > > myDepartures
Departure times for randomized flows.
void openOutput(const OptionsCont &options)
Opens the output for computed routes.
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed
int getEdgeNumber() const
Returns the total number of edges the network contains including internal edges.
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
MsgHandler * myErrorHandler
handler for ignorable error messages
#define WRITE_WARNING(msg)
bool addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource)
const std::string DEFAULT_PEDTYPE_ID
int myNumInternalEdges
The number of internal edges in the dictionary.
Static storage of an output device and its base (abstract) implementation.
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
void writeNetwork(OutputDevice &dev)
root element of a route file
bool isPublicTransport() const
std::string vtypeid
The vehicle's type id.
bool isPartOfFlow() const
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
std::string busstop
(Optional) bus stop if one is assigned to the stop
void addNode(RONode *node)
virtual bool addEdge(ROEdge *edge)
bool hasPermissions() const
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
const RORoute * getFirstRoute() const
bool exists(const std::string &name) const
Returns the information whether the named option is known.
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
OutputDevice * myRoutesOutput
The file to write the computed routes into.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void writeIntermodal(const OptionsCont &options, ROIntermodalRouter &router) const
Writes the intermodal network and weights if requested.
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=nullptr)
static OptionsCont & getOptions()
Retrieves the options.
Base class for a vehicle's route definition.
static void adaptIntermodalRouter(ROIntermodalRouter &router)
The router's network representation.
A person as used by router.
int myWrittenRouteNo
The number of written routes.
A vehicle as used by router.
Structure representing possible vehicle parameter.
std::vector< const RORoutable * > myPTVehicles
vehicles to keep for public transport routing
void close()
Closes the device and removes it from the dictionary.
bool addPerson(ROPerson *person)
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
bool addRouteDef(RORouteDef *def)
SumoXMLTag
Numbers representing SUMO-XML - element names.
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
NamedObjectCont< ROEdge * > myEdges
Known edges.
SUMOVehicleClass getVClass() const
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
bool onlyReferenced
Information whether this is a type-stub, being only referenced but not defined (needed by routers)
weights: time range begin
int parametersSet
Information for the router which parameter were set.
void addStoppingPlace(const std::string &id, const SumoXMLTag category, SUMOVehicleParameter::Stop *stop)
std::set< std::string > myPersonIDs
Known person ids.
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
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.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
int size() const
Returns the number of stored items within the container.
bool getRoutingSuccess() const
virtual void addSuccessor(ROEdge *s, ROEdge *via=nullptr, std::string dir="")
Adds information about a connected edge.
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
bool remove(const std::string &id, const bool del=true)
Removes an item.
std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > myDistricts
traffic assignment zones with sources and sinks
Structure representing possible vehicle parameter.
OutputDevice * myTypesOutput
The file to write the vehicle types into.
const std::string DEFAULT_VTYPE_ID
void addContainer(const SUMOTime depart, const std::string desc)
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
vehicle is a passenger car (a "normal" car)
std::string id
The vehicle's id.
const std::string & getID() const
Returns the id of the routable.
double repetitionProbability
The probability for emitting a vehicle per second.
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
void createBulkRouteRequests(const RORouterProvider &provider, const SUMOTime time, const bool removeLoops)
SUMOAbstractRouter< E, V > & getVehicleRouter() const
int repetitionsDone
The number of times the vehicle was already inserted.
A storage for options typed value containers)
bool myDefaultVTypeMayBeDeleted
Whether the default vehicle type was already used or can still be replaced.
int getNumericalID() const
Returns the index (numeric id) of the edge.
std::string routeid
The vehicle's route id.
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
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).
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
A routable thing such as a vehicle or person.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
bool writeHeader(const SumoXMLTag &rootElement)
std::string id
The vehicle type's id.
NamedObjectCont< RONode * > myNodes
Known nodes.
static RONet * myInstance
Unique instance of RONet.
T get(const std::string &id) const
Retrieves an item.
bool addDistrict(const std::string id, ROEdge *source, ROEdge *sink)
ContainerMap myContainers
void setPermissionsFound()
RoutablesMap myRoutables
Known routables.
virtual ~RONet()
Destructor.
A basic edge for routing applications.
virtual void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)=0
bool furtherStored()
Returns the information whether further vehicles, persons or containers are stored.
void writeWeights(OutputDevice &dev)
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
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.
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
void checkFlows(SUMOTime time, MsgHandler *errorHandler)
an aggreagated-output interval
const std::string getStoppingPlaceName(const std::string &id) const
return the name for the given stopping place id
std::set< std::string > myVehIDs
Known vehicle ids.
bool myDefaultBikeTypeMayBeDeleted
Whether the default bicycle type was already used or can still be replaced.
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, const RORouterProvider &provider, SUMOTime time)
Computes routes described by their definitions and saves them.
double getMaxSpeed() const
Returns the vehicle's maximum speed.
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Network * getNetwork() const
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.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
const std::string DEFAULT_BIKETYPE_ID
Base class for nodes used by the router.
bool myDefaultPedTypeMayBeDeleted
Whether the default pedestrian type was already used or can still be replaced.
void setFunction(SumoXMLEdgeFunc func)
Sets the function of the edge.
ROEdge * getEdgeForLaneID(const std::string &laneID) const
Retrieves an edge from the network when the lane id is given.
const std::string & getID() const
Returns the id.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
#define WRITE_MESSAGE(msg)
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
const bool myKeepVTypeDist
whether to keep the the vtype distribution in output
A thread repeatingly calculating incoming tasks.
const int VTYPEPARS_VEHICLECLASS_SET
Definition of vehicle stop (position and duration)
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the list of stops this route contains.
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
bool add(const std::string &id, T item)
Adds an item.
virtual const ROEdge * getDepartEdge() const =0