Eclipse SUMO - Simulation of Urban MObility
RONet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // The router's network representation
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <algorithm>
32 #include <utils/common/ToString.h>
36 #include "ROEdge.h"
37 #include "ROLane.h"
38 #include "RONode.h"
39 #include "ROPerson.h"
40 #include "RORoute.h"
41 #include "RORouteDef.h"
42 #include "ROVehicle.h"
43 #include "RONet.h"
44 
45 
46 // ===========================================================================
47 // static member definitions
48 // ===========================================================================
49 RONet* RONet::myInstance = nullptr;
50 
51 
52 // ===========================================================================
53 // method definitions
54 // ===========================================================================
55 RONet*
57  if (myInstance != nullptr) {
58  return myInstance;
59  }
60  throw ProcessError("A network was not yet constructed.");
61 }
62 
63 
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")
73  && OptionsCont::getOptions().getBool("ignore-errors") ? MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()),
74  myKeepVTypeDist(OptionsCont::getOptions().exists("keep-vtype-distributions")
75  && OptionsCont::getOptions().getBool("keep-vtype-distributions")) {
76  if (myInstance != nullptr) {
77  throw ProcessError("A network was already constructed.");
78  }
80  type->onlyReferenced = true;
81  myVehicleTypes.add(type->id, type);
83  defPedType->onlyReferenced = true;
85  myVehicleTypes.add(defPedType->id, defPedType);
87  defBikeType->onlyReferenced = true;
89  myVehicleTypes.add(defBikeType->id, defBikeType);
90  myInstance = this;
91 }
92 
93 
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);
98  // delete routes and the vehicle
99  if (veh != nullptr && veh->getRouteDefinition()->getID()[0] == '!') {
100  if (!myRoutes.remove(veh->getRouteDefinition()->getID())) {
101  delete veh->getRouteDefinition();
102  }
103  }
104  delete r;
105  }
106  }
107  for (const RORoutable* const r : myPTVehicles) {
108  const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(r);
109  // delete routes and the vehicle
110  if (veh != nullptr && veh->getRouteDefinition()->getID()[0] == '!') {
111  if (!myRoutes.remove(veh->getRouteDefinition()->getID())) {
112  delete veh->getRouteDefinition();
113  }
114  }
115  delete r;
116  }
117  myRoutables.clear();
118 }
119 
120 
121 void
122 RONet::addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
123  myRestrictions[id][svc] = speed;
124 }
125 
126 
127 const std::map<SUMOVehicleClass, double>*
128 RONet::getRestrictions(const std::string& id) const {
129  std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i = myRestrictions.find(id);
130  if (i == myRestrictions.end()) {
131  return nullptr;
132  }
133  return &i->second;
134 }
135 
136 
137 bool
139  if (!myEdges.add(edge->getID(), edge)) {
140  WRITE_ERROR("The edge '" + edge->getID() + "' occurs at least twice.");
141  delete edge;
142  return false;
143  }
144  if (edge->isInternal()) {
145  myNumInternalEdges += 1;
146  }
147  return true;
148 }
149 
150 
151 bool
152 RONet::addDistrict(const std::string id, ROEdge* source, ROEdge* sink) {
153  if (myDistricts.count(id) > 0) {
154  WRITE_ERROR("The TAZ '" + id + "' occurs at least twice.");
155  delete source;
156  delete sink;
157  return false;
158  }
160  addEdge(sink);
162  addEdge(source);
163  myDistricts[id] = std::make_pair(std::vector<std::string>(), std::vector<std::string>());
164  return true;
165 }
166 
167 
168 bool
169 RONet::addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource) {
170  if (myDistricts.count(tazID) == 0) {
171  WRITE_ERROR("The TAZ '" + tazID + "' is unknown.");
172  return false;
173  }
174  ROEdge* edge = getEdge(edgeID);
175  if (edge == nullptr) {
176  WRITE_ERROR("The edge '" + edgeID + "' for TAZ '" + tazID + "' is unknown.");
177  return false;
178  }
179  if (isSource) {
180  getEdge(tazID + "-source")->addSuccessor(edge);
181  myDistricts[tazID].first.push_back(edgeID);
182  } else {
183  edge->addSuccessor(getEdge(tazID + "-sink"));
184  myDistricts[tazID].second.push_back(edgeID);
185  }
186  return true;
187 }
188 
189 
190 void
192  if (!myNodes.add(node->getID(), node)) {
193  WRITE_ERROR("The node '" + node->getID() + "' occurs at least twice.");
194  delete node;
195  }
196 }
197 
198 
199 void
200 RONet::addStoppingPlace(const std::string& id, const SumoXMLTag category, SUMOVehicleParameter::Stop* stop) {
201  if (!myStoppingPlaces[category == SUMO_TAG_TRAIN_STOP ? SUMO_TAG_BUS_STOP : category].add(id, stop)) {
202  WRITE_ERROR("The " + toString(category) + " '" + id + "' occurs at least twice.");
203  delete stop;
204  }
205 }
206 
207 
208 bool
210  return myRoutes.add(def->getID(), def);
211 }
212 
213 
214 void
216  if (options.isSet("output-file") && options.getString("output-file") != "") {
217  myRoutesOutput = &OutputDevice::getDevice(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");
220  }
221  if (options.exists("alternatives-output") && options.isSet("alternatives-output")
222  && !(options.exists("write-trips") && options.getBool("write-trips"))) {
223  myRouteAlternativesOutput = &OutputDevice::getDevice(options.getString("alternatives-output"));
225  myRouteAlternativesOutput->writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/routes_file.xsd");
226  }
227  if (options.isSet("vtype-output")) {
228  myTypesOutput = &OutputDevice::getDevice(options.getString("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");
231  }
232 }
233 
234 
235 void
236 RONet::writeIntermodal(const OptionsCont& options, ROIntermodalRouter& router) const {
237  if (options.exists("intermodal-network-output") && options.isSet("intermodal-network-output")) {
238  OutputDevice::createDeviceByOption("intermodal-network-output", "intermodal");
239  router.writeNetwork(OutputDevice::getDevice(options.getString("intermodal-network-output")));
240  }
241  if (options.exists("intermodal-weight-output") && options.isSet("intermodal-weight-output")) {
242  OutputDevice::createDeviceByOption("intermodal-weight-output", "weights", "meandata_file.xsd");
243  OutputDevice& dev = OutputDevice::getDeviceByOption("intermodal-weight-output");
245  dev.writeAttr(SUMO_ATTR_ID, "intermodalweights");
246  dev.writeAttr(SUMO_ATTR_BEGIN, 0);
248  router.writeWeights(dev);
249  dev.closeTag();
250  }
251 }
252 
253 
254 void
256  // end writing
257  if (myRoutesOutput != nullptr) {
259  }
260  // only if opened
261  if (myRouteAlternativesOutput != nullptr) {
263  }
264  // only if opened
265  if (myTypesOutput != nullptr) {
266  myTypesOutput->close();
267  }
269 #ifdef HAVE_FOX
270  if (myThreadPool.size() > 0) {
271  myThreadPool.clear();
272  }
273 #endif
274 }
275 
276 
277 
279 RONet::getVehicleTypeSecure(const std::string& id) {
280  // check whether the type was already known
282  if (id == DEFAULT_VTYPE_ID) {
284  }
285  if (id == DEFAULT_PEDTYPE_ID) {
287  }
288  if (id == DEFAULT_BIKETYPE_ID) {
290  }
291  if (type != nullptr) {
292  return type;
293  }
294  VTypeDistDictType::iterator it2 = myVTypeDistDict.find(id);
295  if (it2 != myVTypeDistDict.end()) {
296  return it2->second->get();
297  }
298  if (id == "") {
299  // ok, no vehicle type or an unknown type was given within the user input
300  // return the default type
303  }
304  return type;
305 }
306 
307 
308 bool
309 RONet::checkVType(const std::string& id) {
310  if (id == DEFAULT_VTYPE_ID) {
314  } else {
315  return false;
316  }
317  } else if (id == DEFAULT_PEDTYPE_ID) {
321  } else {
322  return false;
323  }
324  } else {
325  if (myVehicleTypes.get(id) != 0 || myVTypeDistDict.find(id) != myVTypeDistDict.end()) {
326  return false;
327  }
328  }
329  return true;
330 }
331 
332 
333 bool
335  if (checkVType(type->id)) {
336  myVehicleTypes.add(type->id, type);
337  } else {
338  WRITE_ERROR("The vehicle type '" + type->id + "' occurs at least twice.");
339  delete type;
340  return false;
341  }
342  return true;
343 }
344 
345 
346 bool
347 RONet::addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution) {
348  if (checkVType(id)) {
349  myVTypeDistDict[id] = vehTypeDistribution;
350  return true;
351  }
352  return false;
353 }
354 
355 
356 bool
357 RONet::addVehicle(const std::string& id, ROVehicle* veh) {
358  if (myVehIDs.find(id) == myVehIDs.end()) {
359  myVehIDs.insert(id);
360  if (veh->isPublicTransport()) {
361  if (!veh->isPartOfFlow()) {
362  myPTVehicles.push_back(veh);
363  }
364  if (OptionsCont::getOptions().exists("ptline-routing") && !OptionsCont::getOptions().getBool("ptline-routing")) {
365  return true;
366  }
367  }
368  myRoutables[veh->getDepart()].push_back(veh);
369  return true;
370  }
371  WRITE_ERROR("Another vehicle with the id '" + id + "' exists.");
372  return false;
373 }
374 
375 
376 bool
377 RONet::addFlow(SUMOVehicleParameter* flow, const bool randomize) {
378  if (randomize) {
379  myDepartures[flow->id].reserve(flow->repetitionNumber);
380  for (int i = 0; i < flow->repetitionNumber; ++i) {
381  myDepartures[flow->id].push_back(flow->depart + RandHelper::rand(flow->repetitionNumber * flow->repetitionOffset));
382  }
383  std::sort(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
384  std::reverse(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
385  }
386  return myFlows.add(flow->id, flow);
387 }
388 
389 
390 bool
392  if (myPersonIDs.count(person->getID()) == 0) {
393  myPersonIDs.insert(person->getID());
394  myRoutables[person->getDepart()].push_back(person);
395  return true;
396  }
397  WRITE_ERROR("Another person with the id '" + person->getID() + "' exists.");
398  return false;
399 }
400 
401 
402 void
403 RONet::addContainer(const SUMOTime depart, const std::string desc) {
404  myContainers.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
405 }
406 
407 
408 void
409 RONet::checkFlows(SUMOTime time, MsgHandler* errorHandler) {
410  myHaveActiveFlows = false;
411  for (const auto& i : myFlows) {
412  SUMOVehicleParameter* pars = i.second;
413  if (pars->repetitionProbability > 0) {
414  if (pars->repetitionEnd > pars->depart) {
415  myHaveActiveFlows = true;
416  }
417  const SUMOTime origDepart = pars->depart;
418  while (pars->depart < time) {
419  if (pars->repetitionEnd <= pars->depart) {
420  break;
421  }
422  // only call rand if all other conditions are met
423  if (RandHelper::rand() < (pars->repetitionProbability * TS)) {
424  SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
425  newPars->id = pars->id + "." + toString(pars->repetitionsDone);
426  newPars->depart = pars->depart;
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;
430  }
431  }
432  pars->repetitionsDone++;
433  // try to build the vehicle
435  if (!myKeepVTypeDist) {
436  // fix the type id in case we used a distribution
437  newPars->vtypeid = type->id;
438  }
439  const SUMOTime stopOffset = pars->routeid[0] == '!' ? pars->depart - origDepart : pars->depart;
440  RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id, stopOffset);
441  ROVehicle* veh = new ROVehicle(*newPars, route, type, this, errorHandler);
442  addVehicle(newPars->id, veh);
443  delete newPars;
444  }
445  pars->depart += DELTA_T;
446  }
447  } else {
448  while (pars->repetitionsDone < pars->repetitionNumber) {
449  myHaveActiveFlows = true;
450  SUMOTime depart = static_cast<SUMOTime>(pars->depart + pars->repetitionsDone * pars->repetitionOffset);
451  if (myDepartures.find(pars->id) != myDepartures.end()) {
452  depart = myDepartures[pars->id].back();
453  }
454  if (depart >= time + DELTA_T) {
455  break;
456  }
457  if (myDepartures.find(pars->id) != myDepartures.end()) {
458  myDepartures[pars->id].pop_back();
459  }
460  SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
461  newPars->id = pars->id + "." + toString(pars->repetitionsDone);
462  newPars->depart = depart;
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;
466  }
467  }
468  pars->repetitionsDone++;
469  // try to build the vehicle
471  if (type == nullptr) {
473  } else {
474  // fix the type id in case we used a distribution
475  newPars->vtypeid = type->id;
476  }
477  const SUMOTime stopOffset = pars->routeid[0] == '!' ? depart - pars->depart : depart;
478  RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id, stopOffset);
479  ROVehicle* veh = new ROVehicle(*newPars, route, type, this, errorHandler);
480  addVehicle(newPars->id, veh);
481  delete newPars;
482  }
483  }
484  }
485 }
486 
487 
488 void
489 RONet::createBulkRouteRequests(const RORouterProvider& provider, const SUMOTime time, const bool removeLoops) {
490  std::map<const int, std::vector<RORoutable*> > bulkVehs;
491  for (RoutablesMap::const_iterator i = myRoutables.begin(); i != myRoutables.end(); ++i) {
492  if (i->first >= time) {
493  break;
494  }
495  for (RORoutable* const routable : i->second) {
496  const ROEdge* const depEdge = routable->getDepartEdge();
497  bulkVehs[depEdge->getNumericalID()].push_back(routable);
498  RORoutable* const first = bulkVehs[depEdge->getNumericalID()].front();
499  if (first->getMaxSpeed() != routable->getMaxSpeed()) {
500  WRITE_WARNING("Bulking different maximum speeds ('" + first->getID() + "' and '" + routable->getID() + "') may lead to suboptimal routes.");
501  }
502  if (first->getVClass() != routable->getVClass()) {
503  WRITE_WARNING("Bulking different vehicle classes ('" + first->getID() + "' and '" + routable->getID() + "') may lead to invalid routes.");
504  }
505  }
506  }
507  int workerIndex = 0;
508  for (std::map<const int, std::vector<RORoutable*> >::const_iterator i = bulkVehs.begin(); i != bulkVehs.end(); ++i) {
509 #ifdef HAVE_FOX
510  if (myThreadPool.size() > 0) {
511  RORoutable* const first = i->second.front();
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);
516  }
517  myThreadPool.add(new BulkmodeTask(false), workerIndex);
518  workerIndex++;
519  if (workerIndex == (int)myThreadPool.size()) {
520  workerIndex = 0;
521  }
522  continue;
523  }
524 #endif
525  for (std::vector<RORoutable*>::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
526  (*j)->computeRoute(provider, removeLoops, myErrorHandler);
527  provider.getVehicleRouter().setBulkMode(true);
528  }
529  provider.getVehicleRouter().setBulkMode(false);
530  }
531 }
532 
533 
534 SUMOTime
536  SUMOTime time) {
537  MsgHandler* mh = (options.getBool("ignore-errors") ?
539  if (myHaveActiveFlows) {
540  checkFlows(time, mh);
541  }
542  SUMOTime lastTime = -1;
543  const bool removeLoops = options.getBool("remove-loops");
544  const int maxNumThreads = options.getInt("routing-threads");
545  if (myRoutables.size() != 0) {
546  if (options.getBool("bulk-routing")) {
547 #ifdef HAVE_FOX
548  while ((int)myThreadPool.size() < maxNumThreads) {
549  new WorkerThread(myThreadPool, provider);
550  }
551 #endif
552  createBulkRouteRequests(provider, time, removeLoops);
553  } else {
554  for (RoutablesMap::const_iterator i = myRoutables.begin(); i != myRoutables.end(); ++i) {
555  if (i->first >= time) {
556  break;
557  }
558  for (RORoutable* const routable : i->second) {
559 #ifdef HAVE_FOX
560  // add task
561  if (maxNumThreads > 0) {
562  const int numThreads = (int)myThreadPool.size();
563  if (numThreads == 0) {
564  // This is the very first routing. Since at least the CHRouter needs initialization
565  // before it gets cloned, we do not do this in parallel
566  routable->computeRoute(provider, removeLoops, myErrorHandler);
567  new WorkerThread(myThreadPool, provider);
568  } else {
569  // add thread if necessary
570  if (numThreads < maxNumThreads && myThreadPool.isFull()) {
571  new WorkerThread(myThreadPool, provider);
572  }
573  myThreadPool.add(new RoutingTask(routable, removeLoops, myErrorHandler));
574  }
575  continue;
576  }
577 #endif
578  routable->computeRoute(provider, removeLoops, myErrorHandler);
579  }
580  }
581  }
582 #ifdef HAVE_FOX
583  myThreadPool.waitAll();
584 #endif
585  }
586  // write all vehicles (and additional structures)
587  while (myRoutables.size() != 0 || myContainers.size() != 0) {
588  // get the next vehicle, person or container
589  RoutablesMap::iterator routables = myRoutables.begin();
590  const SUMOTime routableTime = routables == myRoutables.end() ? SUMOTime_MAX : routables->first;
591  ContainerMap::iterator container = myContainers.begin();
592  const SUMOTime containerTime = container == myContainers.end() ? SUMOTime_MAX : container->first;
593  // check whether it shall not yet be computed
594  if (routableTime >= time && containerTime >= time) {
595  lastTime = MIN2(routableTime, containerTime);
596  break;
597  }
598  const SUMOTime minTime = MIN2(routableTime, containerTime);
599  if (routableTime == minTime) {
600  // check whether to print the output
601  if (lastTime != routableTime && lastTime != -1) {
602  // report writing progress
603  if (options.getInt("stats-period") >= 0 && ((int)routableTime % options.getInt("stats-period")) == 0) {
604  WRITE_MESSAGE("Read: " + toString(myVehIDs.size()) + ", Discarded: " + toString(myDiscardedRouteNo) + ", Written: " + toString(myWrittenRouteNo));
605  }
606  }
607  lastTime = routableTime;
608  for (const RORoutable* const r : routables->second) {
609  // ok, check whether it has been routed
610  if (r->getRoutingSuccess()) {
611  // write the route
614  } else {
616  }
617  // delete routes and the vehicle
618  if (!r->isPublicTransport() || r->isPartOfFlow()) {
619  const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(r);
620  if (veh != nullptr && veh->getRouteDefinition()->getID()[0] == '!') {
621  if (!myRoutes.remove(veh->getRouteDefinition()->getID())) {
622  delete veh->getRouteDefinition();
623  }
624  }
625  delete r;
626  }
627  }
628  myRoutables.erase(routables);
629  }
630  if (containerTime == minTime) {
631  myRoutesOutput->writePreformattedTag(container->second);
632  if (myRouteAlternativesOutput != nullptr) {
634  }
635  myContainers.erase(container);
636  }
637  }
638  return lastTime;
639 }
640 
641 
642 bool
644  return myRoutables.size() > 0 || (myFlows.size() > 0 && myHaveActiveFlows) || myContainers.size() > 0;
645 }
646 
647 
648 int
650  return myEdges.size();
651 }
652 
653 
654 int
656  return myNumInternalEdges;
657 }
658 
659 
660 void
662  // add access to all parking areas
663  for (const auto& i : myInstance->myStoppingPlaces[SUMO_TAG_PARKING_AREA]) {
664  router.getNetwork()->addAccess(i.first, myInstance->getEdgeForLaneID(i.second->lane), (i.second->startPos + i.second->endPos) / 2., 0., SUMO_TAG_PARKING_AREA);
665  }
666  // add access to all public transport stops
667  for (const auto& stop : myInstance->myStoppingPlaces[SUMO_TAG_BUS_STOP]) {
668  router.getNetwork()->addAccess(stop.first, myInstance->getEdgeForLaneID(stop.second->lane), (stop.second->startPos + stop.second->endPos) / 2., 0., SUMO_TAG_BUS_STOP);
669  for (const auto& a : stop.second->accessPos) {
670  router.getNetwork()->addAccess(stop.first, myInstance->getEdgeForLaneID(std::get<0>(a)), std::get<1>(a), std::get<2>(a), SUMO_TAG_BUS_STOP);
671  }
672  }
673  // fill the public transport router with pre-parsed public transport lines
674  for (const auto& i : myInstance->myFlows) {
675  if (i.second->line != "") {
676  const RORouteDef* const route = myInstance->getRouteDef(i.second->routeid);
677  const std::vector<SUMOVehicleParameter::Stop>* addStops = nullptr;
678  if (route != nullptr && route->getFirstRoute() != nullptr) {
679  addStops = &route->getFirstRoute()->getStops();
680  }
681  router.getNetwork()->addSchedule(*i.second, addStops);
682  }
683  }
684  for (const RORoutable* const veh : myInstance->myPTVehicles) {
685  // add single vehicles with line attribute which are not part of a flow
686  // no need to add route stops here, they have been added to the vehicle before
687  router.getNetwork()->addSchedule(veh->getParameter());
688  }
689 }
690 
691 
692 bool
694  return myHavePermissions;
695 }
696 
697 
698 void
700  myHavePermissions = true;
701 }
702 
703 const std::string
704 RONet::getStoppingPlaceName(const std::string& id) const {
705  for (const auto& mapItem : myStoppingPlaces) {
706  SUMOVehicleParameter::Stop* stop = mapItem.second.get(id);
707  if (stop != nullptr) {
708  // see RONetHandler::parseStoppingPlace
709  return stop->busstop;
710  }
711  }
712  return "";
713 }
714 
715 #ifdef HAVE_FOX
716 // ---------------------------------------------------------------------------
717 // RONet::RoutingTask-methods
718 // ---------------------------------------------------------------------------
719 void
720 RONet::RoutingTask::run(FXWorkerThread* context) {
721  myRoutable->computeRoute(*static_cast<WorkerThread*>(context), myRemoveLoops, myErrorHandler);
722 }
723 #endif
724 
725 
726 /****************************************************************************/
727 
SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
Definition: SUMOXMLDefinitions.h:100
OptionsCont::isSet
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
Definition: OptionsCont.cpp:136
ROEdge::isInternal
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:148
SVC_PEDESTRIAN
pedestrian
Definition: SUMOVehicleClass.h:157
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:134
OutputDevice::createDeviceByOption
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.
Definition: OutputDevice.cpp:102
RONet::myHaveActiveFlows
bool myHaveActiveFlows
whether any flows are still active
Definition: RONet.h:491
OptionsCont::getInt
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
Definition: OptionsCont.cpp:216
ToString.h
RONet::myDiscardedRouteNo
int myDiscardedRouteNo
The number of discarded routes.
Definition: RONet.h:519
RONet::myDepartures
std::map< std::string, std::vector< SUMOTime > > myDepartures
Departure times for randomized flows.
Definition: RONet.h:501
RONet::openOutput
void openOutput(const OptionsCont &options)
Opens the output for computed routes.
Definition: RONet.cpp:215
OutputDevice::writePreformattedTag
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed
Definition: OutputDevice.h:302
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:74
RONet::getEdgeNumber
int getEdgeNumber() const
Returns the total number of edges the network contains including internal edges.
Definition: RONet.cpp:649
RONet::myHavePermissions
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
Definition: RONet.h:525
RONet::myErrorHandler
MsgHandler * myErrorHandler
handler for ignorable error messages
Definition: RONet.h:534
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
RONet::addDistrictEdge
bool addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource)
Definition: RONet.cpp:169
DEFAULT_PEDTYPE_ID
const std::string DEFAULT_PEDTYPE_ID
RONet::myNumInternalEdges
int myNumInternalEdges
The number of internal edges in the dictionary.
Definition: RONet.h:531
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
DELTA_T
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
RouteCostCalculator.h
OptionsCont.h
RONet::getEdge
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:153
IntermodalRouter
Definition: MSNet.h:80
RONet::myRouteAlternativesOutput
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
Definition: RONet.h:510
IntermodalRouter::writeNetwork
void writeNetwork(OutputDevice &dev)
Definition: IntermodalRouter.h:211
RONode.h
SUMO_TAG_ROUTES
root element of a route file
Definition: SUMOXMLDefinitions.h:118
RORoutable::isPublicTransport
bool isPublicTransport() const
Definition: RORoutable.h:122
SUMOVehicleParameter::vtypeid
std::string vtypeid
The vehicle's type id.
Definition: SUMOVehicleParameter.h:468
RORoutable::isPartOfFlow
bool isPartOfFlow() const
Definition: RORoutable.h:126
SUMOVehicleParameter::repetitionOffset
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
Definition: SUMOVehicleParameter.h:544
SUMOVehicleParameter::Stop::busstop
std::string busstop
(Optional) bus stop if one is assigned to the stop
Definition: SUMOVehicleParameter.h:583
RONet::addNode
void addNode(RONode *node)
Definition: RONet.cpp:191
RONet::addEdge
virtual bool addEdge(ROEdge *edge)
Definition: RONet.cpp:138
RONet::hasPermissions
bool hasPermissions() const
Definition: RONet.cpp:693
OptionsCont::getString
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
Definition: OptionsCont.cpp:202
RORouteDef::getFirstRoute
const RORoute * getFirstRoute() const
Definition: RORouteDef.h:101
RouteCostCalculator::cleanup
static void cleanup()
Definition: RouteCostCalculator.h:48
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
OptionsCont::exists
bool exists(const std::string &name) const
Returns the information whether the named option is known.
Definition: OptionsCont.cpp:130
RONet::getRouteDef
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition: RONet.h:294
RONet::myRoutesOutput
OutputDevice * myRoutesOutput
The file to write the computed routes into.
Definition: RONet.h:507
OptionsCont::getBool
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Definition: OptionsCont.cpp:223
RONet::writeIntermodal
void writeIntermodal(const OptionsCont &options, ROIntermodalRouter &router) const
Writes the intermodal network and weights if requested.
Definition: RONet.cpp:236
IntermodalNetwork::addSchedule
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=nullptr)
Definition: IntermodalNetwork.h:546
SVC_BICYCLE
vehicle is a bicycle
Definition: SUMOVehicleClass.h:180
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
RORouteDef
Base class for a vehicle's route definition.
Definition: RORouteDef.h:56
RONet::adaptIntermodalRouter
static void adaptIntermodalRouter(ROIntermodalRouter &router)
Definition: RONet.cpp:661
RONet
The router's network representation.
Definition: RONet.h:64
ROPerson
A person as used by router.
Definition: ROPerson.h:51
SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:379
RONet::myWrittenRouteNo
int myWrittenRouteNo
The number of written routes.
Definition: RONet.h:522
ROVehicle
A vehicle as used by router.
Definition: ROVehicle.h:53
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:291
ROVehicle.h
RORouteDef.h
RONet::myPTVehicles
std::vector< const RORoutable * > myPTVehicles
vehicles to keep for public transport routing
Definition: RONet.h:498
OutputDevice::close
void close()
Closes the device and removes it from the dictionary.
Definition: OutputDevice.cpp:208
RONet::addPerson
bool addPerson(ROPerson *person)
Definition: RONet.cpp:391
RONet::getInstance
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
Definition: RONet.cpp:56
RONet::getInternalEdgeNumber
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
Definition: RONet.cpp:655
RORoute.h
RORoutable::getDepart
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
Definition: RORoutable.h:103
RONet::addRouteDef
bool addRouteDef(RORouteDef *def)
Definition: RONet.cpp:209
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:42
SUMOVehicleParameter::depart
SUMOTime depart
Definition: SUMOVehicleParameter.h:476
RONet::addRestriction
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
Definition: RONet.cpp:122
RONet::myEdges
NamedObjectCont< ROEdge * > myEdges
Known edges.
Definition: RONet.h:459
RORoutable::getVClass
SUMOVehicleClass getVClass() const
Definition: RORoutable.h:108
OutputDevice::closeTag
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition: OutputDevice.cpp:254
SUMOVTypeParameter::onlyReferenced
bool onlyReferenced
Information whether this is a type-stub, being only referenced but not defined (needed by routers)
Definition: SUMOVTypeParameter.h:314
SUMO_ATTR_BEGIN
weights: time range begin
Definition: SUMOXMLDefinitions.h:675
SUMOVTypeParameter::parametersSet
int parametersSet
Information for the router which parameter were set.
Definition: SUMOVTypeParameter.h:308
RONet::addStoppingPlace
void addStoppingPlace(const std::string &id, const SumoXMLTag category, SUMOVehicleParameter::Stop *stop)
Definition: RONet.cpp:200
RONet::myPersonIDs
std::set< std::string > myPersonIDs
Known person ids.
Definition: RONet.h:453
RONet::myRestrictions
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
Definition: RONet.h:528
OutputDevice::writeAttr
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
RONet::myStoppingPlaces
std::map< SumoXMLTag, NamedObjectCont< SUMOVehicleParameter::Stop * > > myStoppingPlaces
Known bus / train / container stops and parking areas.
Definition: RONet.h:462
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:60
NamedObjectCont::size
int size() const
Returns the number of stored items within the container.
Definition: NamedObjectCont.h:117
MsgHandler
Definition: MsgHandler.h:44
RORoutable::getRoutingSuccess
bool getRoutingSuccess() const
Definition: RORoutable.h:154
ROEdge::addSuccessor
virtual void addSuccessor(ROEdge *s, ROEdge *via=nullptr, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:105
MsgHandler::getWarningInstance
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Definition: MsgHandler.cpp:72
NamedObjectCont::remove
bool remove(const std::string &id, const bool del=true)
Removes an item.
Definition: NamedObjectCont.h:79
TS
#define TS
Definition: SUMOTime.h:44
RONet::myDistricts
std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > myDistricts
traffic assignment zones with sources and sinks
Definition: RONet.h:504
RONet.h
SUMOVTypeParameter
Structure representing possible vehicle parameter.
Definition: SUMOVTypeParameter.h:86
RONet::myTypesOutput
OutputDevice * myTypesOutput
The file to write the vehicle types into.
Definition: RONet.h:513
DEFAULT_VTYPE_ID
const std::string DEFAULT_VTYPE_ID
RONet::addContainer
void addContainer(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:403
RORoutable::getParameter
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
Definition: RORoutable.h:74
SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
Definition: SUMOVehicleClass.h:160
SUMOVehicleClass.h
SUMOVehicleParameter::id
std::string id
The vehicle's id.
Definition: SUMOVehicleParameter.h:462
SUMO_TAG_PARKING_AREA
A parking area.
Definition: SUMOXMLDefinitions.h:108
RORoutable::getID
const std::string & getID() const
Returns the id of the routable.
Definition: RORoutable.h:94
SUMOVehicleParameter::repetitionProbability
double repetitionProbability
The probability for emitting a vehicle per second.
Definition: SUMOVehicleParameter.h:547
OutputDevice.h
ROVehicle::getRouteDefinition
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
Definition: ROVehicle.h:76
ProcessError
Definition: UtilExceptions.h:40
RONet::createBulkRouteRequests
void createBulkRouteRequests(const RORouterProvider &provider, const SUMOTime time, const bool removeLoops)
Definition: RONet.cpp:489
RouterProvider::getVehicleRouter
SUMOAbstractRouter< E, V > & getVehicleRouter() const
Definition: RouterProvider.h:50
UtilExceptions.h
SUMOVehicleParameter::repetitionsDone
int repetitionsDone
The number of times the vehicle was already inserted.
Definition: SUMOVehicleParameter.h:541
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:90
EDGEFUNC_CONNECTOR
Definition: SUMOXMLDefinitions.h:1077
RONet::myDefaultVTypeMayBeDeleted
bool myDefaultVTypeMayBeDeleted
Whether the default vehicle type was already used or can still be replaced.
Definition: RONet.h:473
ROEdge::getNumericalID
int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:210
RONet::RONet
RONet()
Constructor.
Definition: RONet.cpp:64
SUMOVehicleParameter::routeid
std::string routeid
The vehicle's route id.
Definition: SUMOVehicleParameter.h:465
RONet::myVehicleTypes
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
Definition: RONet.h:465
RouterProvider
Definition: RouterProvider.h:38
RONet::addVehicle
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition: RONet.cpp:357
ROPerson.h
RONet::addVTypeDistribution
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
Definition: RONet.cpp:347
RandomDistributor< SUMOVTypeParameter * >
RORoutable::write
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).
Definition: RORoutable.h:141
SUMOVehicleParameter::repetitionEnd
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
Definition: SUMOVehicleParameter.h:550
RORoutable
A routable thing such as a vehicle or person.
Definition: RORoutable.h:55
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:240
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
RONet::myVTypeDistDict
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
Definition: RONet.h:470
SUMO_TAG_BUS_STOP
A bus stop.
Definition: SUMOXMLDefinitions.h:98
RONet::cleanup
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary
Definition: RONet.cpp:255
OutputDevice::getDevice
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
Definition: OutputDevice.cpp:55
OutputDevice::writeHeader
bool writeHeader(const SumoXMLTag &rootElement)
Definition: OutputDevice.h:188
SUMOVTypeParameter::id
std::string id
The vehicle type's id.
Definition: SUMOVTypeParameter.h:210
RONet::myNodes
NamedObjectCont< RONode * > myNodes
Known nodes.
Definition: RONet.h:456
RONet::myInstance
static RONet * myInstance
Unique instance of RONet.
Definition: RONet.h:447
NamedObjectCont::get
T get(const std::string &id) const
Retrieves an item.
Definition: NamedObjectCont.h:99
RONet::addDistrict
bool addDistrict(const std::string id, ROEdge *source, ROEdge *sink)
Definition: RONet.cpp:152
RONet::myContainers
ContainerMap myContainers
Definition: RONet.h:495
RONet::setPermissionsFound
void setPermissionsFound()
Definition: RONet.cpp:699
RONet::myRoutables
RoutablesMap myRoutables
Known routables.
Definition: RONet.h:485
RONet::~RONet
virtual ~RONet()
Destructor.
Definition: RONet.cpp:94
ROEdge
A basic edge for routing applications.
Definition: ROEdge.h:73
RORoutable::computeRoute
virtual void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)=0
RONet::furtherStored
bool furtherStored()
Returns the information whether further vehicles, persons or containers are stored.
Definition: RONet.cpp:643
IntermodalRouter::writeWeights
void writeWeights(OutputDevice &dev)
Definition: IntermodalRouter.h:223
config.h
ROLane.h
RandHelper.h
RONet::addFlow
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition: RONet.cpp:377
IntermodalNetwork::addAccess
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.
Definition: IntermodalNetwork.h:453
SUMO_ATTR_END
weights: time range end
Definition: SUMOXMLDefinitions.h:677
RONet::myRoutes
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
Definition: RONet.h:482
RONet::checkFlows
void checkFlows(SUMOTime time, MsgHandler *errorHandler)
Definition: RONet.cpp:409
SUMO_TAG_INTERVAL
an aggreagated-output interval
Definition: SUMOXMLDefinitions.h:160
RONet::getStoppingPlaceName
const std::string getStoppingPlaceName(const std::string &id) const
return the name for the given stopping place id
Definition: RONet.cpp:704
RONet::myVehIDs
std::set< std::string > myVehIDs
Known vehicle ids.
Definition: RONet.h:450
SUMOTime_MAX
#define SUMOTime_MAX
Definition: SUMOTime.h:36
RONet::myDefaultBikeTypeMayBeDeleted
bool myDefaultBikeTypeMayBeDeleted
Whether the default bicycle type was already used or can still be replaced.
Definition: RONet.h:479
RONet::saveAndRemoveRoutesUntil
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, const RORouterProvider &provider, SUMOTime time)
Computes routes described by their definitions and saves them.
Definition: RONet.cpp:535
RORoutable::getMaxSpeed
double getMaxSpeed() const
Returns the vehicle's maximum speed.
Definition: RORoutable.h:114
RONet::checkVType
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
Definition: RONet.cpp:309
MsgHandler::getErrorInstance
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:81
RORouteDef::copy
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:386
SUMOVehicleParameter::repetitionNumber
int repetitionNumber
Definition: SUMOVehicleParameter.h:538
IntermodalRouter::getNetwork
Network * getNetwork() const
Definition: IntermodalRouter.h:235
RONet::getRestrictions
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.
Definition: RONet.cpp:128
SUMOVehicleParameter::stops
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
Definition: SUMOVehicleParameter.h:638
RONet::getVehicleTypeSecure
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:279
DEFAULT_BIKETYPE_ID
const std::string DEFAULT_BIKETYPE_ID
RONode
Base class for nodes used by the router.
Definition: RONode.h:46
SUMOVTypeParameter.h
SUMOAbstractRouter.h
RONet::myDefaultPedTypeMayBeDeleted
bool myDefaultPedTypeMayBeDeleted
Whether the default pedestrian type was already used or can still be replaced.
Definition: RONet.h:476
ROEdge::setFunction
void setFunction(SumoXMLEdgeFunc func)
Sets the function of the edge.
Definition: ROEdge.h:115
RONet::getEdgeForLaneID
ROEdge * getEdgeForLaneID(const std::string &laneID) const
Retrieves an edge from the network when the lane id is given.
Definition: RONet.h:163
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:77
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:245
ROEdge.h
OutputDevice::getDeviceByOption
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
Definition: OutputDevice.cpp:117
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:240
RONet::myFlows
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
Definition: RONet.h:488
RONet::myKeepVTypeDist
const bool myKeepVTypeDist
whether to keep the the vtype distribution in output
Definition: RONet.h:537
FXWorkerThread
A thread repeatingly calculating incoming tasks.
Definition: FXWorkerThread.h:49
VTYPEPARS_VEHICLECLASS_SET
const int VTYPEPARS_VEHICLECLASS_SET
Definition: SUMOVTypeParameter.h:53
SUMOVehicleParameter::Stop
Definition of vehicle stop (position and duration)
Definition: SUMOVehicleParameter.h:566
RORoute::getStops
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the list of stops this route contains.
Definition: RORoute.h:184
RONet::addVehicleType
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
Definition: RONet.cpp:334
NamedObjectCont::add
bool add(const std::string &id, T item)
Adds an item.
Definition: NamedObjectCont.h:66
RORoutable::getDepartEdge
virtual const ROEdge * getDepartEdge() const =0