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