SUMO - Simulation of Urban MObility
RONet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // The router's network representation
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <algorithm>
39 #include <utils/common/ToString.h>
43 #include "ROEdge.h"
44 #include "RONode.h"
45 #include "ROPerson.h"
46 #include "RORoute.h"
47 #include "RORouteDef.h"
48 #include "ROVehicle.h"
49 #include "RONet.h"
50 
51 
52 // ===========================================================================
53 // static member definitions
54 // ===========================================================================
56 
57 
58 // ===========================================================================
59 // method definitions
60 // ===========================================================================
61 RONet*
63  if (myInstance != 0) {
64  return myInstance;
65  }
66  throw ProcessError("A network was not yet constructed.");
67 }
68 
69 
74  myHavePermissions(false),
76  myErrorHandler(OptionsCont::getOptions().exists("ignore-errors")
77  && OptionsCont::getOptions().getBool("ignore-errors") ? MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()),
78  myKeepVTypeDist(OptionsCont::getOptions().exists("keep-vtype-distributions")
79  && OptionsCont::getOptions().getBool("keep-vtype-distributions")) {
80  if (myInstance != 0) {
81  throw ProcessError("A network was already constructed.");
82  }
84  type->onlyReferenced = true;
85  myVehicleTypes.add(type->id, type);
87  defPedType->onlyReferenced = true;
89  myVehicleTypes.add(defPedType->id, defPedType);
90  myInstance = this;
91 }
92 
93 
95  for (RoutablesMap::iterator routables = myRoutables.begin(); routables != myRoutables.end(); ++routables) {
96  for (std::deque<RORoutable*>::iterator r = routables->second.begin(); r != routables->second.end(); ++r) {
97  const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(*r);
98  // delete routes and the vehicle
99  if (veh != 0 && veh->getRouteDefinition()->getID()[0] == '!') {
100  if (!myRoutes.erase(veh->getRouteDefinition()->getID())) {
101  delete veh->getRouteDefinition();
102  }
103  }
104  delete *r;
105  }
106  }
107  for (std::map<std::string, SUMOVehicleParameter::Stop*>::iterator it = myBusStops.begin(); it != myBusStops.end(); ++it) {
108  delete it->second;
109  }
110  for (std::map<std::string, SUMOVehicleParameter::Stop*>::iterator it = myContainerStops.begin(); it != myContainerStops.end(); ++it) {
111  delete it->second;
112  }
113  myNodes.clear();
114  myEdges.clear();
116  myRoutes.clear();
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 0;
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 == 0) {
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::addBusStop(const std::string& id, SUMOVehicleParameter::Stop* stop) {
201  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myBusStops.find(id);
202  if (it != myBusStops.end()) {
203  WRITE_ERROR("The bus stop '" + id + "' occurs at least twice.");
204  delete stop;
205  }
206  myBusStops[id] = stop;
207 }
208 
209 
210 void
212  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myContainerStops.find(id);
213  if (it != myContainerStops.end()) {
214  WRITE_ERROR("The container stop '" + id + "' occurs at least twice.");
215  delete stop;
216  }
217  myContainerStops[id] = stop;
218 }
219 
220 
221 void
222 RONet::addParkingArea(const std::string& id, SUMOVehicleParameter::Stop* stop) {
223  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myParkingAreas.find(id);
224  if (it != myParkingAreas.end()) {
225  WRITE_ERROR("The parking area '" + id + "' occurs at least twice.");
226  delete stop;
227  }
228  myParkingAreas[id] = stop;
229 }
230 
231 
232 bool
234  return myRoutes.add(def->getID(), def);
235 }
236 
237 
238 void
239 RONet::openOutput(const OptionsCont& options, const std::string altFilename) {
240  if (options.isSet("output-file") && options.getString("output-file") != "") {
241  myRoutesOutput = &OutputDevice::getDevice(options.getString("output-file"));
243  myRoutesOutput->writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/routes_file.xsd");
244  }
245  if (altFilename != "") {
248  myRouteAlternativesOutput->writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/routes_file.xsd");
249  }
250  if (options.isSet("vtype-output") && options.getString("vtype-output") != "") {
251  myTypesOutput = &OutputDevice::getDevice(options.getString("vtype-output"));
253  myTypesOutput->writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/routes_file.xsd");
254  }
255 }
256 
257 
258 void
260  // end writing
261  if (myRoutesOutput != 0) {
263  }
264  // only if opened
265  if (myRouteAlternativesOutput != 0) {
267  }
268  // only if opened
269  if (myTypesOutput != 0) {
270  myTypesOutput->close();
271  }
273 #ifdef HAVE_FOX
274  if (myThreadPool.size() > 0) {
275  myThreadPool.clear();
276  }
277 #endif
278 }
279 
280 
281 
283 RONet::getVehicleTypeSecure(const std::string& id) {
284  // check whether the type was already known
286  if (id == DEFAULT_VTYPE_ID) {
288  }
289  if (id == DEFAULT_PEDTYPE_ID) {
291  }
292  if (type != 0) {
293  return type;
294  }
295  VTypeDistDictType::iterator it2 = myVTypeDistDict.find(id);
296  if (it2 != myVTypeDistDict.end()) {
297  return it2->second->get();
298  }
299  if (id == "") {
300  // ok, no vehicle type or an unknown type was given within the user input
301  // return the default type
304  }
305  return type;
306 }
307 
308 
309 bool
310 RONet::checkVType(const std::string& id) {
311  if (id == DEFAULT_VTYPE_ID) {
315  } else {
316  return false;
317  }
318  } else if (id == DEFAULT_PEDTYPE_ID) {
322  } else {
323  return false;
324  }
325  } else {
326  if (myVehicleTypes.get(id) != 0 || myVTypeDistDict.find(id) != myVTypeDistDict.end()) {
327  return false;
328  }
329  }
330  return true;
331 }
332 
333 
334 bool
336  if (checkVType(type->id)) {
337  myVehicleTypes.add(type->id, type);
338  } else {
339  WRITE_ERROR("The vehicle type '" + type->id + "' occurs at least twice.");
340  delete type;
341  return false;
342  }
343  return true;
344 }
345 
346 
347 bool
348 RONet::addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution) {
349  if (checkVType(id)) {
350  myVTypeDistDict[id] = vehTypeDistribution;
351  return true;
352  }
353  return false;
354 }
355 
356 
357 bool
358 RONet::addVehicle(const std::string& id, ROVehicle* veh) {
359  if (myVehIDs.find(id) == myVehIDs.end()) {
360  myVehIDs.insert(id);
361  myRoutables[veh->getDepart()].push_back(veh);
362  myReadRouteNo++;
363  return true;
364  }
365  WRITE_ERROR("Another vehicle with the id '" + id + "' exists.");
366  return false;
367 }
368 
369 
370 bool
371 RONet::addFlow(SUMOVehicleParameter* flow, const bool randomize) {
372  if (randomize) {
373  myDepartures[flow->id].reserve(flow->repetitionNumber);
374  for (int i = 0; i < flow->repetitionNumber; ++i) {
375  myDepartures[flow->id].push_back(flow->depart + RandHelper::rand(flow->repetitionNumber * flow->repetitionOffset));
376  }
377  std::sort(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
378  std::reverse(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
379  }
380  return myFlows.add(flow->id, flow);
381 }
382 
383 
384 bool
386  if (myPersonIDs.count(person->getID()) == 0) {
387  myPersonIDs.insert(person->getID());
388  myRoutables[person->getDepart()].push_back(person);
389  return true;
390  }
391  WRITE_ERROR("Another person with the id '" + person->getID() + "' exists.");
392  return false;
393 }
394 
395 
396 void
397 RONet::addContainer(const SUMOTime depart, const std::string desc) {
398  myContainers.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
399 }
400 
401 
402 void
403 RONet::checkFlows(SUMOTime time, MsgHandler* errorHandler) {
404  std::vector<std::string> toRemove;
406  SUMOVehicleParameter* pars = i->second;
407  if (pars->repetitionProbability > 0) {
408  const SUMOTime origDepart = pars->depart;
409  while (pars->depart < time) {
410  if (pars->repetitionEnd <= pars->depart) {
411  toRemove.push_back(i->first);
412  break;
413  }
414  // only call rand if all other conditions are met
415  if (RandHelper::rand() < (pars->repetitionProbability * TS)) {
416  SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
417  newPars->id = pars->id + "." + toString(pars->repetitionsDone);
418  newPars->depart = pars->depart;
419  for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->stops.begin(); stop != newPars->stops.end(); ++stop) {
420  if (stop->until >= 0) {
421  stop->until += pars->depart - origDepart;
422  }
423  }
424  pars->repetitionsDone++;
425  // try to build the vehicle
427  if (!myKeepVTypeDist) {
428  // fix the type id in case we used a distribution
429  newPars->vtypeid = type->id;
430  }
431  const SUMOTime stopOffset = pars->routeid[0] == '!' ? pars->depart - origDepart : pars->depart;
432  RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id, stopOffset);
433  ROVehicle* veh = new ROVehicle(*newPars, route, type, this, errorHandler);
434  addVehicle(newPars->id, veh);
435  delete newPars;
436  }
437  pars->depart += DELTA_T;
438  }
439  } else {
440  while (pars->repetitionsDone < pars->repetitionNumber) {
441  SUMOTime depart = static_cast<SUMOTime>(pars->depart + pars->repetitionsDone * pars->repetitionOffset);
442  if (myDepartures.find(pars->id) != myDepartures.end()) {
443  depart = myDepartures[pars->id].back();
444  }
445  if (depart >= time + DELTA_T) {
446  break;
447  }
448  if (myDepartures.find(pars->id) != myDepartures.end()) {
449  myDepartures[pars->id].pop_back();
450  }
451  SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
452  newPars->id = pars->id + "." + toString(pars->repetitionsDone);
453  newPars->depart = depart;
454  for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->stops.begin(); stop != newPars->stops.end(); ++stop) {
455  if (stop->until >= 0) {
456  stop->until += depart - pars->depart;
457  }
458  }
459  pars->repetitionsDone++;
460  // try to build the vehicle
462  if (type == 0) {
464  } else {
465  // fix the type id in case we used a distribution
466  newPars->vtypeid = type->id;
467  }
468  const SUMOTime stopOffset = pars->routeid[0] == '!' ? depart - pars->depart : depart;
469  RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id, stopOffset);
470  ROVehicle* veh = new ROVehicle(*newPars, route, type, this, errorHandler);
471  addVehicle(newPars->id, veh);
472  delete newPars;
473  }
474  if (pars->repetitionsDone == pars->repetitionNumber) {
475  toRemove.push_back(i->first);
476  }
477  }
478  }
479  for (std::vector<std::string>::const_iterator i = toRemove.begin(); i != toRemove.end(); ++i) {
480  myFlows.erase(*i);
481  }
482 }
483 
484 
485 void
486 RONet::createBulkRouteRequests(const RORouterProvider& provider, const SUMOTime time, const bool removeLoops) {
487  std::map<const int, std::vector<RORoutable*> > bulkVehs;
488  for (RoutablesMap::const_iterator i = myRoutables.begin(); i != myRoutables.end(); ++i) {
489  if (i->first >= time) {
490  break;
491  }
492  for (std::deque<RORoutable*>::const_iterator r = i->second.begin(); r != i->second.end(); ++r) {
493  RORoutable* const routable = *r;
494  const ROEdge* const depEdge = routable->getDepartEdge();
495  bulkVehs[depEdge->getNumericalID()].push_back(routable);
496  RORoutable* const first = bulkVehs[depEdge->getNumericalID()].front();
497  if (first->getMaxSpeed() != routable->getMaxSpeed()) {
498  WRITE_WARNING("Bulking different maximum speeds ('" + first->getID() + "' and '" + routable->getID() + "') may lead to suboptimal routes.");
499  }
500  if (first->getVClass() != routable->getVClass()) {
501  WRITE_WARNING("Bulking different vehicle classes ('" + first->getID() + "' and '" + routable->getID() + "') may lead to invalid routes.");
502  }
503  }
504  }
505  int workerIndex = 0;
506  for (std::map<const int, std::vector<RORoutable*> >::const_iterator i = bulkVehs.begin(); i != bulkVehs.end(); ++i) {
507 #ifdef HAVE_FOX
508  if (myThreadPool.size() > 0) {
509  RORoutable* const first = i->second.front();
510  myThreadPool.add(new RoutingTask(first, removeLoops, myErrorHandler), workerIndex);
511  myThreadPool.add(new BulkmodeTask(true), workerIndex);
512  for (std::vector<RORoutable*>::const_iterator j = i->second.begin() + 1; j != i->second.end(); ++j) {
513  myThreadPool.add(new RoutingTask(*j, removeLoops, myErrorHandler), workerIndex);
514  }
515  myThreadPool.add(new BulkmodeTask(false), workerIndex);
516  workerIndex++;
517  if (workerIndex == (int)myThreadPool.size()) {
518  workerIndex = 0;
519  }
520  continue;
521  }
522 #endif
523  for (std::vector<RORoutable*>::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
524  (*j)->computeRoute(provider, removeLoops, myErrorHandler);
525  provider.getVehicleRouter().setBulkMode(true);
526  }
527  provider.getVehicleRouter().setBulkMode(false);
528  }
529 }
530 
531 
532 SUMOTime
534  SUMOTime time) {
535  MsgHandler* mh = (options.getBool("ignore-errors") ?
537  checkFlows(time, mh);
538  SUMOTime lastTime = -1;
539  const bool removeLoops = options.getBool("remove-loops");
540  const int maxNumThreads = options.getInt("routing-threads");
541  if (myRoutables.size() != 0) {
542  if (options.getBool("bulk-routing")) {
543 #ifdef HAVE_FOX
544  while ((int)myThreadPool.size() < maxNumThreads) {
545  new WorkerThread(myThreadPool, provider);
546  }
547 #endif
548  createBulkRouteRequests(provider, time, removeLoops);
549  } else {
550  for (RoutablesMap::const_iterator i = myRoutables.begin(); i != myRoutables.end(); ++i) {
551  if (i->first >= time) {
552  break;
553  }
554  for (std::deque<RORoutable*>::const_iterator r = i->second.begin(); r != i->second.end(); ++r) {
555  RORoutable* const routable = *r;
556 #ifdef HAVE_FOX
557  // add task
558  if (maxNumThreads > 0) {
559  const int numThreads = (int)myThreadPool.size();
560  if (numThreads == 0) {
561  // This is the very first routing. Since at least the CHRouter needs initialization
562  // before it gets cloned, we do not do this in parallel
563  routable->computeRoute(provider, removeLoops, myErrorHandler);
564  new WorkerThread(myThreadPool, provider);
565  } else {
566  // add thread if necessary
567  if (numThreads < maxNumThreads && myThreadPool.isFull()) {
568  new WorkerThread(myThreadPool, provider);
569  }
570  myThreadPool.add(new RoutingTask(routable, removeLoops, myErrorHandler));
571  }
572  continue;
573  }
574 #endif
575  routable->computeRoute(provider, removeLoops, myErrorHandler);
576  }
577  }
578  }
579 #ifdef HAVE_FOX
580  myThreadPool.waitAll();
581 #endif
582  }
583  // write all vehicles (and additional structures)
584  while (myRoutables.size() != 0 || myContainers.size() != 0) {
585  // get the next vehicle, person or container
586  RoutablesMap::iterator routables = myRoutables.begin();
587  const SUMOTime routableTime = routables == myRoutables.end() ? SUMOTime_MAX : routables->first;
588  ContainerMap::iterator container = myContainers.begin();
589  const SUMOTime containerTime = container == myContainers.end() ? SUMOTime_MAX : container->first;
590  // check whether it shall not yet be computed
591  if (routableTime >= time && containerTime >= time) {
592  lastTime = MIN2(routableTime, containerTime);
593  break;
594  }
595  const SUMOTime minTime = MIN2(routableTime, containerTime);
596  if (routableTime == minTime) {
597  const RORoutable* const r = routables->second.front();
598  // check whether to print the output
599  if (lastTime != routableTime && lastTime != -1) {
600  // report writing progress
601  if (options.getInt("stats-period") >= 0 && ((int) routableTime % options.getInt("stats-period")) == 0) {
602  WRITE_MESSAGE("Read: " + toString(myReadRouteNo) + ", Discarded: " + toString(myDiscardedRouteNo) + ", Written: " + toString(myWrittenRouteNo));
603  }
604  }
605  lastTime = routableTime;
606 
607  // ok, compute the route (try it)
608  if (r->getRoutingSuccess()) {
609  // write the route
612  } else {
614  }
615  const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(r);
616  // delete routes and the vehicle
617  if (veh != 0 && veh->getRouteDefinition()->getID()[0] == '!') {
618  if (!myRoutes.erase(veh->getRouteDefinition()->getID())) {
619  delete veh->getRouteDefinition();
620  }
621  }
622  routables->second.pop_front();
623  if (routables->second.empty()) {
624  myRoutables.erase(routables);
625  }
626  delete r;
627  }
628  if (containerTime == minTime) {
629  myRoutesOutput->writePreformattedTag(container->second);
630  if (myRouteAlternativesOutput != 0) {
632  }
633  myContainers.erase(container);
634  }
635  }
636  return lastTime;
637 }
638 
639 
640 bool
642  return myRoutables.size() > 0 || myFlows.size() > 0 || myContainers.size() > 0;
643 }
644 
645 
646 int
648  return myEdges.size();
649 }
650 
651 
652 int
654  return myNumInternalEdges;
655 }
656 
657 
658 const std::map<std::string, ROEdge*>&
660  return myEdges.getMyMap();
661 }
662 
663 
664 void
666  // add access to all public transport stops
667  for (std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator i = myInstance->myBusStops.begin(); i != myInstance->myBusStops.end(); ++i) {
668  router.addAccess(i->first, myInstance->getEdgeForLaneID(i->second->lane), i->second->endPos);
669  for (std::multimap<std::string, double>::const_iterator a = i->second->accessPos.begin(); a != i->second->accessPos.end(); ++a) {
670  router.addAccess(i->first, myInstance->getEdgeForLaneID(a->first), a->second);
671  }
672  }
673  // fill the public transport router with pre-parsed public transport lines
674  for (std::map<std::string, SUMOVehicleParameter*>::const_iterator i = myInstance->myFlows.getMyMap().begin(); i != myInstance->myFlows.getMyMap().end(); ++i) {
675  if (i->second->line != "") {
676  RORouteDef* route = myInstance->getRouteDef(i->second->routeid);
677  const std::vector<SUMOVehicleParameter::Stop>* addStops = 0;
678  if (route != 0 && route->getFirstRoute() != 0) {
679  addStops = &route->getFirstRoute()->getStops();
680  }
681  router.addSchedule(*i->second, addStops);
682  }
683  }
684  for (RoutablesMap::const_iterator i = myInstance->myRoutables.begin(); i != myInstance->myRoutables.end(); ++i) {
685  for (std::deque<RORoutable*>::const_iterator r = i->second.begin(); r != i->second.end(); ++r) {
686  const ROVehicle* const veh = dynamic_cast<ROVehicle*>(*r);
687  // add single vehicles with line attribute which are not part of a flow
688  if (veh != 0 && veh->getParameter().line != "" && veh->getParameter().repetitionNumber < 0) {
689  router.addSchedule(veh->getParameter());
690  }
691  }
692  }
693 }
694 
695 
696 bool
698  return myHavePermissions;
699 }
700 
701 
702 void
704  myHavePermissions = true;
705 }
706 
707 
708 #ifdef HAVE_FOX
709 // ---------------------------------------------------------------------------
710 // RONet::RoutingTask-methods
711 // ---------------------------------------------------------------------------
712 void
713 RONet::RoutingTask::run(FXWorkerThread* context) {
714  myRoutable->computeRoute(*static_cast<WorkerThread*>(context), myRemoveLoops, myErrorHandler);
715 }
716 #endif
717 
718 
719 /****************************************************************************/
720 
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Definition: MsgHandler.cpp:67
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
Definition: RORoutable.h:101
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
bool addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource)
Definition: RONet.cpp:169
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:261
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
Definition: RONet.h:559
bool hasPermissions() const
Definition: RONet.cpp:697
void close()
Closes the device and removes it from the dictionary.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:76
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
Definition: RONet.h:543
is a pedestrian
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
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:553
std::string vtypeid
The vehicle&#39;s type id.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
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
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
Definition: RONet.h:574
bool getRoutingSuccess() const
Definition: RORoutable.h:144
int myNumInternalEdges
The number of internal edges in the dictionary.
Definition: RONet.h:580
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
Definition: RONet.cpp:310
bool erase(const std::string &id)
Removes the named item from the container.
virtual bool add(const std::string &id, T item)
Adds an item.
Structure representing possible vehicle parameter.
static void adaptIntermodalRouter(ROIntermodalRouter &router)
Definition: RONet.cpp:665
void addNode(RONode *node)
Definition: RONet.cpp:191
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:165
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
double repetitionProbability
The probability for emitting a vehicle per second.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:65
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed ...
Definition: OutputDevice.h:307
int repetitionsDone
The number of times the vehicle was already inserted.
void checkFlows(SUMOTime time, MsgHandler *errorHandler)
Definition: RONet.cpp:403
SUMOTime DELTA_T
Definition: SUMOTime.cpp:40
NamedObjectCont< ROEdge * > myEdges
Known edges.
Definition: RONet.h:511
int myDiscardedRouteNo
The number of discarded routes.
Definition: RONet.h:568
#define TS
Definition: SUMOTime.h:52
A map of named object pointers.
std::map< std::string, std::vector< SUMOTime > > myDepartures
Departure times for randomized flows.
Definition: RONet.h:550
OutputDevice * myTypesOutput
The file to write the vehicle types into.
Definition: RONet.h:562
const std::string DEFAULT_VTYPE_ID
void addAccess(const std::string &stopId, const E *stopEdge, const double pos)
int myWrittenRouteNo
The number of written routes.
Definition: RONet.h:571
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
Definition: RONet.cpp:335
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition: RONet.cpp:358
const std::map< std::string, ROEdge * > & getEdgeMap() const
Definition: RONet.cpp:659
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
Definition: RONet.cpp:62
double getMaxSpeed() const
Returns the vehicle&#39;s maximum speed.
Definition: RORoutable.h:112
void openOutput(const OptionsCont &options, const std::string altFilename="")
Opens the output for computed routes.
Definition: RONet.cpp:239
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
void addParkingArea(const std::string &id, SUMOVehicleParameter::Stop *stop)
Definition: RONet.cpp:222
T get(const std::string &id) const
Retrieves an item.
void clear()
Removes all items from the container (deletes them, too)
bool writeHeader(const SumoXMLTag &rootElement)
Definition: OutputDevice.h:193
std::set< std::string > myPersonIDs
Known person ids.
Definition: RONet.h:505
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
A routable thing such as a vehicle or person.
Definition: RORoutable.h:62
const std::string & getID() const
Returns the id.
Definition: Named.h:66
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
Definition: RONet.cpp:348
A vehicle as used by router.
Definition: ROVehicle.h:60
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary ...
Definition: RONet.cpp:259
root element of a route file
bool addRouteDef(RORouteDef *def)
Definition: RONet.cpp:233
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
Definition: RONet.cpp:122
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:150
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=0)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
virtual const ROEdge * getDepartEdge() const =0
std::string routeid
The vehicle&#39;s route id.
OutputDevice * myRoutesOutput
The file to write the computed routes into.
Definition: RONet.h:556
#define SUMOTime_MAX
Definition: TraCIDefs.h:53
void addContainer(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:397
std::map< std::string, SUMOVehicleParameter::Stop * > myContainerStops
Known container stops.
Definition: RONet.h:517
virtual bool remove(const std::string &id)
Removes an item.
RoutablesMap myRoutables
Known routables.
Definition: RONet.h:540
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
Definition: RONet.h:523
SUMOTime depart
The vehicle&#39;s departure time.
std::map< std::string, SUMOVehicleParameter::Stop * > myParkingAreas
Known parking areas.
Definition: RONet.h:520
ContainerMap myContainers
Definition: RONet.h:547
virtual bool furtherStored()
Returns the information whether further vehicles, persons or containers are stored.
Definition: RONet.cpp:641
T MIN2(T a, T b)
Definition: StdDefs.h:68
A person as used by router.
Definition: ROPerson.h:58
static RONet * myInstance
Unique instance of RONet.
Definition: RONet.h:499
SUMOAbstractRouter< E, V > & getVehicleRouter() const
int getEdgeNo() const
Returns the total number of edges the network contains including internal edges.
Definition: RONet.cpp:647
bool myDefaultVTypeMayBeDeleted
Whether no vehicle type has been loaded yet.
Definition: RONet.h:531
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
Definition: RONet.h:537
void createBulkRouteRequests(const RORouterProvider &provider, const SUMOTime time, const bool removeLoops)
Definition: RONet.cpp:486
const bool myKeepVTypeDist
whether to keep the the vtype distribution in output
Definition: RONet.h:586
vehicle is a passenger car (a "normal" car)
A basic edge for routing applications.
Definition: ROEdge.h:78
bool onlyReferenced
Information whether this is a type-stub, being only referenced but not defined (needed by routers) ...
std::string line
The vehicle&#39;s line (mainly for public transport)
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
Definition: RONet.cpp:653
virtual void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)=0
const IDMap & getMyMap() const
Returns a reference to the internal map.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
ROEdge * getEdgeForLaneID(const std::string &laneID) const
Retrieves an edge from the network when the lane id is given.
Definition: RONet.h:175
int setParameter
Information for the router which parameter were set.
RONet()
Constructor.
Definition: RONet.cpp:70
The router&#39;s network representation.
Definition: RONet.h:76
bool addDistrict(const std::string id, ROEdge *source, ROEdge *sink)
Definition: RONet.cpp:152
Structure representing possible vehicle parameter.
virtual void addSuccessor(ROEdge *s, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:107
int myReadRouteNo
The number of read routes.
Definition: RONet.h:565
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:412
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
Definition: RONet.h:577
const std::string DEFAULT_PEDTYPE_ID
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
const std::string & getID() const
Returns the id of the vehicle.
Definition: RORoutable.h:92
Definition of vehicle stop (position and duration)
A storage for options typed value containers)
Definition: OptionsCont.h:99
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
Definition: RONet.h:528
Base class for a vehicle&#39;s route definition.
Definition: RORouteDef.h:63
std::string id
The vehicle type&#39;s id.
void addBusStop(const std::string &id, SUMOVehicleParameter::Stop *stop)
Definition: RONet.cpp:200
virtual bool addEdge(ROEdge *edge)
Definition: RONet.cpp:138
std::set< std::string > myVehIDs
Known vehicle ids.
Definition: RONet.h:502
virtual ~RONet()
Destructor.
Definition: RONet.cpp:94
const RORoute * getFirstRoute() const
Definition: RORouteDef.h:108
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:283
A thread repeatingly calculating incoming tasks.
MsgHandler * myErrorHandler
handler for ignorable error messages
Definition: RONet.h:583
long long int SUMOTime
Definition: TraCIDefs.h:52
Base class for nodes used by the router.
Definition: RONode.h:53
NamedObjectCont< RONode * > myNodes
Known nodes.
Definition: RONet.h:508
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:131
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition: RONet.cpp:371
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
Definition: ROVehicle.h:83
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
const int VTYPEPARS_VEHICLECLASS_SET
void addContainerStop(const std::string &id, SUMOVehicleParameter::Stop *stop)
Definition: RONet.cpp:211
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle parameter.
Definition: ROVehicle.h:92
SUMOVehicleClass getVClass() const
Definition: RORoutable.h:106
bool addPerson(ROPerson *person)
Definition: RONet.cpp:385
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition: RONet.h:351
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the list of stops this route contains.
Definition: RORoute.h:191
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, const RORouterProvider &provider, SUMOTime time)
Computes routes described by their definitions and saves them.
Definition: RONet.cpp:533
std::map< std::string, SUMOVehicleParameter::Stop * > myBusStops
Known bus stops.
Definition: RONet.h:514
int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:212
std::string id
The vehicle&#39;s id.
bool myDefaultPedTypeMayBeDeleted
Whether no pedestrian type has been loaded yet.
Definition: RONet.h:534
void setPermissionsFound()
Definition: RONet.cpp:703
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
int size() const
Returns the number of stored items within the container.
void setFunction(SumoXMLEdgeFunc func)
Sets the function of the edge.
Definition: ROEdge.h:120