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  if (myInstance != 0) {
79  throw ProcessError("A network was already constructed.");
80  }
82  type->onlyReferenced = true;
83  myVehicleTypes.add(type->id, type);
85  defPedType->onlyReferenced = true;
87  myVehicleTypes.add(defPedType->id, defPedType);
88  myInstance = this;
89 }
90 
91 
93  for (RoutablesMap::iterator routables = myRoutables.begin(); routables != myRoutables.end(); ++routables) {
94  for (std::deque<RORoutable*>::iterator r = routables->second.begin(); r != routables->second.end(); ++r) {
95  const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(*r);
96  // delete routes and the vehicle
97  if (veh != 0 && veh->getRouteDefinition()->getID()[0] == '!') {
98  if (!myRoutes.erase(veh->getRouteDefinition()->getID())) {
99  delete veh->getRouteDefinition();
100  }
101  }
102  delete *r;
103  }
104  }
105  for (std::map<std::string, SUMOVehicleParameter::Stop*>::iterator it = myBusStops.begin(); it != myBusStops.end(); ++it) {
106  delete it->second;
107  }
108  for (std::map<std::string, SUMOVehicleParameter::Stop*>::iterator it = myContainerStops.begin(); it != myContainerStops.end(); ++it) {
109  delete it->second;
110  }
111  myNodes.clear();
112  myEdges.clear();
114  myRoutes.clear();
115  myRoutables.clear();
116 }
117 
118 
119 void
120 RONet::addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
121  myRestrictions[id][svc] = speed;
122 }
123 
124 
125 const std::map<SUMOVehicleClass, double>*
126 RONet::getRestrictions(const std::string& id) const {
127  std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i = myRestrictions.find(id);
128  if (i == myRestrictions.end()) {
129  return 0;
130  }
131  return &i->second;
132 }
133 
134 
135 bool
137  if (!myEdges.add(edge->getID(), edge)) {
138  WRITE_ERROR("The edge '" + edge->getID() + "' occurs at least twice.");
139  delete edge;
140  return false;
141  }
142  if (edge->getFunc() == ROEdge::ET_INTERNAL) {
143  myNumInternalEdges += 1;
144  }
145  return true;
146 }
147 
148 
149 bool
150 RONet::addDistrict(const std::string id, ROEdge* source, ROEdge* sink) {
151  if (myDistricts.count(id) > 0) {
152  WRITE_ERROR("The TAZ '" + id + "' occurs at least twice.");
153  delete source;
154  delete sink;
155  return false;
156  }
158  addEdge(sink);
159  source->setFunc(ROEdge::ET_DISTRICT);
160  addEdge(source);
161  myDistricts[id] = std::make_pair(std::vector<std::string>(), std::vector<std::string>());
162  return true;
163 }
164 
165 
166 bool
167 RONet::addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource) {
168  if (myDistricts.count(tazID) == 0) {
169  WRITE_ERROR("The TAZ '" + tazID + "' is unknown.");
170  return false;
171  }
172  ROEdge* edge = getEdge(edgeID);
173  if (edge == 0) {
174  WRITE_ERROR("The edge '" + edgeID + "' for TAZ '" + tazID + "' is unknown.");
175  return false;
176  }
177  if (isSource) {
178  getEdge(tazID + "-source")->addSuccessor(edge);
179  myDistricts[tazID].first.push_back(edgeID);
180  } else {
181  edge->addSuccessor(getEdge(tazID + "-sink"));
182  myDistricts[tazID].second.push_back(edgeID);
183  }
184  return true;
185 }
186 
187 
188 void
190  if (!myNodes.add(node->getID(), node)) {
191  WRITE_ERROR("The node '" + node->getID() + "' occurs at least twice.");
192  delete node;
193  }
194 }
195 
196 
197 void
198 RONet::addBusStop(const std::string& id, SUMOVehicleParameter::Stop* stop) {
199  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myBusStops.find(id);
200  if (it != myBusStops.end()) {
201  WRITE_ERROR("The bus stop '" + id + "' occurs at least twice.");
202  delete stop;
203  }
204  myBusStops[id] = stop;
205 }
206 
207 
208 void
210  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myContainerStops.find(id);
211  if (it != myContainerStops.end()) {
212  WRITE_ERROR("The container stop '" + id + "' occurs at least twice.");
213  delete stop;
214  }
215  myContainerStops[id] = stop;
216 }
217 
218 
219 void
220 RONet::addParkingArea(const std::string& id, SUMOVehicleParameter::Stop* stop) {
221  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myParkingAreas.find(id);
222  if (it != myParkingAreas.end()) {
223  WRITE_ERROR("The parking area '" + id + "' occurs at least twice.");
224  delete stop;
225  }
226  myParkingAreas[id] = stop;
227 }
228 
229 
230 bool
232  return myRoutes.add(def->getID(), def);
233 }
234 
235 
236 void
237 RONet::openOutput(const OptionsCont& options, const std::string altFilename) {
238  if (options.isSet("output-file") && options.getString("output-file") != "") {
239  myRoutesOutput = &OutputDevice::getDevice(options.getString("output-file"));
241  myRoutesOutput->writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/routes_file.xsd");
242  }
243  if (altFilename != "") {
246  myRouteAlternativesOutput->writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/routes_file.xsd");
247  }
248  if (options.isSet("vtype-output") && options.getString("vtype-output") != "") {
249  myTypesOutput = &OutputDevice::getDevice(options.getString("vtype-output"));
251  myTypesOutput->writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/routes_file.xsd");
252  }
253 }
254 
255 
256 void
258  // end writing
259  if (myRoutesOutput != 0) {
261  }
262  // only if opened
263  if (myRouteAlternativesOutput != 0) {
265  }
266  // only if opened
267  if (myTypesOutput != 0) {
268  myTypesOutput->close();
269  }
271 #ifdef HAVE_FOX
272  if (myThreadPool.size() > 0) {
273  myThreadPool.clear();
274  }
275 #endif
276 }
277 
278 
279 
281 RONet::getVehicleTypeSecure(const std::string& id) {
282  // check whether the type was already known
284  if (id == DEFAULT_VTYPE_ID) {
286  }
287  if (id == DEFAULT_PEDTYPE_ID) {
289  }
290  if (type != 0) {
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  myRoutables[veh->getDepart()].push_back(veh);
360  myReadRouteNo++;
361  return true;
362  }
363  WRITE_ERROR("Another vehicle with the id '" + id + "' exists.");
364  return false;
365 }
366 
367 
368 bool
369 RONet::addFlow(SUMOVehicleParameter* flow, const bool randomize) {
370  if (randomize) {
371  myDepartures[flow->id].reserve(flow->repetitionNumber);
372  for (int i = 0; i < flow->repetitionNumber; ++i) {
373  myDepartures[flow->id].push_back(flow->depart + RandHelper::rand(flow->repetitionNumber * flow->repetitionOffset));
374  }
375  std::sort(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
376  std::reverse(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
377  }
378  return myFlows.add(flow->id, flow);
379 }
380 
381 
382 bool
384  if (myPersonIDs.count(person->getID()) == 0) {
385  myPersonIDs.insert(person->getID());
386  myRoutables[person->getDepart()].push_back(person);
387  return true;
388  }
389  WRITE_ERROR("Another person with the id '" + person->getID() + "' exists.");
390  return false;
391 }
392 
393 
394 void
395 RONet::addContainer(const SUMOTime depart, const std::string desc) {
396  myContainers.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
397 }
398 
399 
400 void
401 RONet::checkFlows(SUMOTime time, MsgHandler* errorHandler) {
402  std::vector<std::string> toRemove;
404  SUMOVehicleParameter* pars = i->second;
405  if (pars->repetitionProbability > 0) {
406  const SUMOTime origDepart = pars->depart;
407  while (pars->depart < time) {
408  if (pars->repetitionEnd <= pars->depart) {
409  toRemove.push_back(i->first);
410  break;
411  }
412  // only call rand if all other conditions are met
413  if (RandHelper::rand() < (pars->repetitionProbability * TS)) {
414  SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
415  newPars->id = pars->id + "." + toString(pars->repetitionsDone);
416  newPars->depart = pars->depart;
417  for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->stops.begin(); stop != newPars->stops.end(); ++stop) {
418  if (stop->until >= 0) {
419  stop->until += pars->depart - origDepart;
420  }
421  }
422  pars->repetitionsDone++;
423  // try to build the vehicle
425  if (type == 0) {
427  } else {
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 
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:402
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Definition: MsgHandler.cpp:67
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:167
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
Definition: RONet.h:559
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
SUMOVehicleClass getVClass() const
Definition: RORoutable.h:106
int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:205
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
Definition: RONet.h:543
ROEdge * getEdgeForLaneID(const std::string &laneID) const
Retrieves an edge from the network when the lane id is given.
Definition: RONet.h:175
is a pedestrian
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
Definition: RONet.cpp:653
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
virtual const ROEdge * getDepartEdge() const =0
std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > myDistricts
traffic assignment zones with sources and sinks
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...
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
Definition: RONet.h:574
Represents a generic random distribution.
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:308
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.
int getEdgeNo() const
Returns the total number of edges the network contains including internal edges.
Definition: RONet.cpp:647
double getMaxSpeed() const
Returns the vehicle&#39;s maximum speed.
Definition: RORoutable.h:112
int size() const
Returns the number of items within the container.
Structure representing possible vehicle parameter.
static void adaptIntermodalRouter(ROIntermodalRouter &router)
Definition: RONet.cpp:665
void addNode(RONode *node)
Definition: RONet.cpp:189
const RORoute * getFirstRoute() const
Definition: RORouteDef.h:108
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
T get(const std::string &id) const
Retrieves an item.
double repetitionProbability
The probability for emitting a vehicle per second.
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
int repetitionsDone
The number of times the vehicle was already inserted.
void checkFlows(SUMOTime time, MsgHandler *errorHandler)
Definition: RONet.cpp:401
SUMOTime DELTA_T
Definition: SUMOTime.cpp:40
NamedObjectCont< ROEdge * > myEdges
Known edges.
Definition: RONet.h:511
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:126
bool hasPermissions() const
Definition: RONet.cpp:697
An internal edge which models vehicles driving across a junction. This is currently not used for rout...
Definition: ROEdge.h:97
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void setFunc(EdgeFunc func)
Sets the function of the edge.
Definition: ROEdge.h:141
const std::string & getID() const
Returns the id.
Definition: Named.h:66
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)
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition: RONet.h:351
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:333
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition: RONet.cpp:356
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
Definition: RONet.cpp:62
void openOutput(const OptionsCont &options, const std::string altFilename="")
Opens the output for computed routes.
Definition: RONet.cpp:237
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:220
void clear()
Removes all items from the container (deletes them, too)
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
Definition: RORoutable.h:101
bool writeHeader(const SumoXMLTag &rootElement)
Definition: OutputDevice.h:188
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter *> *vehTypeDistribution)
Adds a vehicle type distribution.
Definition: RONet.cpp:346
std::set< std::string > myPersonIDs
Known person ids.
Definition: RONet.h:505
A routable thing such as a vehicle or person.
Definition: RORoutable.h:62
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
A vehicle as used by router.
Definition: ROVehicle.h:60
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary ...
Definition: RONet.cpp:257
root element of a route file
bool addRouteDef(RORouteDef *def)
Definition: RONet.cpp:231
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
Definition: RONet.cpp:120
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
std::string routeid
The vehicle&#39;s route id.
OutputDevice * myRoutesOutput
The file to write the computed routes into.
Definition: RONet.h:556
EdgeFunc getFunc() const
Returns the function of the edge.
Definition: ROEdge.h:190
#define SUMOTime_MAX
Definition: TraCIDefs.h:53
void addContainer(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:395
std::map< std::string, SUMOVehicleParameter::Stop * > myContainerStops
Known container stops.
Definition: RONet.h:517
virtual bool remove(const std::string &id)
Removes an item.
const IDMap & getMyMap() const
bool getRoutingSuccess() const
Definition: RORoutable.h:144
RoutablesMap myRoutables
Known routables.
Definition: RONet.h:540
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
Definition: RONet.h:523
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the list of stops this route contains.
Definition: RORoute.h:191
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
static double rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
T MIN2(T a, T b)
Definition: StdDefs.h:64
A person as used by router.
Definition: ROPerson.h:58
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle parameter.
Definition: ROVehicle.h:92
static RONet * myInstance
Unique instance of RONet.
Definition: RONet.h:499
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 std::string & getID() const
Returns the id of the vehicle.
Definition: RORoutable.h:92
vehicle is a passenger car (a "normal" car)
A basic edge for routing applications.
Definition: ROEdge.h:77
bool onlyReferenced
Information whether this is a type-stub, being only referenced but not defined (needed by routers) ...
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
Definition: ROVehicle.h:83
std::string line
The vehicle&#39;s line (mainly for public transport)
virtual void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)=0
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
SUMOAbstractRouter< E, V > & getVehicleRouter() const
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:150
Structure representing possible vehicle parameter.
virtual void addSuccessor(ROEdge *s, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:105
int myReadRouteNo
The number of read routes.
Definition: RONet.h:565
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.
Definition of vehicle stop (position and duration)
A storage for options typed value containers)
Definition: OptionsCont.h:99
const std::map< std::string, ROEdge * > & getEdgeMap() const
Definition: RONet.cpp:659
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:198
virtual bool addEdge(ROEdge *edge)
Definition: RONet.cpp:136
std::set< std::string > myVehIDs
Known vehicle ids.
Definition: RONet.h:502
virtual ~RONet()
Destructor.
Definition: RONet.cpp:92
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:281
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
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:165
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition: RONet.cpp:369
An edge representing a whole district.
Definition: ROEdge.h:87
#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:209
bool addPerson(ROPerson *person)
Definition: RONet.cpp:383
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
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