SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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-2016 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 #ifdef CHECK_MEMORY_LEAKS
52 #include <foreign/nvwa/debug_new.h>
53 #endif // CHECK_MEMORY_LEAKS
54 
55 
56 // ===========================================================================
57 // static member definitions
58 // ===========================================================================
60 
61 
62 // ===========================================================================
63 // method definitions
64 // ===========================================================================
65 RONet*
67  if (myInstance != 0) {
68  return myInstance;
69  }
70  throw ProcessError("A network was not yet constructed.");
71 }
72 
73 
75  : myVehicleTypes(), myDefaultVTypeMayBeDeleted(true), myDefaultPedTypeMayBeDeleted(true),
76  myRoutesOutput(0), myRouteAlternativesOutput(0), myTypesOutput(0),
77  myReadRouteNo(0), myDiscardedRouteNo(0), myWrittenRouteNo(0),
78  myHavePermissions(false),
79  myNumInternalEdges(0),
80  myErrorHandler(OptionsCont::getOptions().exists("ignore-errors")
81  && OptionsCont::getOptions().getBool("ignore-errors") ? MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()) {
82  if (myInstance != 0) {
83  throw ProcessError("A network was already constructed.");
84  }
86  type->onlyReferenced = true;
87  myVehicleTypes.add(type->id, type);
89  defPedType->onlyReferenced = true;
91  myVehicleTypes.add(defPedType->id, defPedType);
92  myInstance = this;
93 }
94 
95 
97  for (RoutablesMap::iterator routables = myRoutables.begin(); routables != myRoutables.end(); ++routables) {
98  for (std::deque<RORoutable*>::iterator r = routables->second.begin(); r != routables->second.end(); ++r) {
99  const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(*r);
100  // delete routes and the vehicle
101  if (veh != 0 && veh->getRouteDefinition()->getID()[0] == '!') {
102  if (!myRoutes.erase(veh->getRouteDefinition()->getID())) {
103  delete veh->getRouteDefinition();
104  }
105  }
106  delete *r;
107  }
108  }
109  for (std::map<std::string, SUMOVehicleParameter::Stop*>::iterator it = myBusStops.begin(); it != myBusStops.end(); ++it) {
110  delete it->second;
111  }
112  for (std::map<std::string, SUMOVehicleParameter::Stop*>::iterator it = myContainerStops.begin(); it != myContainerStops.end(); ++it) {
113  delete it->second;
114  }
115  myNodes.clear();
116  myEdges.clear();
118  myRoutes.clear();
119  myRoutables.clear();
120 }
121 
122 
123 void
124 RONet::addRestriction(const std::string& id, const SUMOVehicleClass svc, const SUMOReal speed) {
125  myRestrictions[id][svc] = speed;
126 }
127 
128 
129 const std::map<SUMOVehicleClass, SUMOReal>*
130 RONet::getRestrictions(const std::string& id) const {
131  std::map<std::string, std::map<SUMOVehicleClass, SUMOReal> >::const_iterator i = myRestrictions.find(id);
132  if (i == myRestrictions.end()) {
133  return 0;
134  }
135  return &i->second;
136 }
137 
138 
139 bool
141  if (!myEdges.add(edge->getID(), edge)) {
142  WRITE_ERROR("The edge '" + edge->getID() + "' occurs at least twice.");
143  delete edge;
144  return false;
145  }
146  if (edge->getFunc() == ROEdge::ET_INTERNAL) {
147  myNumInternalEdges += 1;
148  }
149  return true;
150 }
151 
152 
153 bool
154 RONet::addDistrict(const std::string id, ROEdge* source, ROEdge* sink) {
155  if (myDistricts.count(id) > 0) {
156  WRITE_ERROR("The TAZ '" + id + "' occurs at least twice.");
157  delete source;
158  delete sink;
159  return false;
160  }
162  addEdge(sink);
163  source->setFunc(ROEdge::ET_DISTRICT);
164  addEdge(source);
165  myDistricts[id] = std::make_pair(std::vector<std::string>(), std::vector<std::string>());
166  return true;
167 }
168 
169 
170 bool
171 RONet::addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource) {
172  if (myDistricts.count(tazID) == 0) {
173  WRITE_ERROR("The TAZ '" + tazID + "' is unknown.");
174  return false;
175  }
176  ROEdge* edge = getEdge(edgeID);
177  if (edge == 0) {
178  WRITE_ERROR("The edge '" + edgeID + "' for TAZ '" + tazID + "' is unknown.");
179  return false;
180  }
181  if (isSource) {
182  getEdge(tazID + "-source")->addSuccessor(edge);
183  myDistricts[tazID].first.push_back(edgeID);
184  } else {
185  edge->addSuccessor(getEdge(tazID + "-sink"));
186  myDistricts[tazID].second.push_back(edgeID);
187  }
188  return true;
189 }
190 
191 
192 void
194  if (!myNodes.add(node->getID(), node)) {
195  WRITE_ERROR("The node '" + node->getID() + "' occurs at least twice.");
196  delete node;
197  }
198 }
199 
200 
201 void
202 RONet::addBusStop(const std::string& id, SUMOVehicleParameter::Stop* stop) {
203  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myBusStops.find(id);
204  if (it != myBusStops.end()) {
205  WRITE_ERROR("The bus stop '" + id + "' occurs at least twice.");
206  delete stop;
207  }
208  myBusStops[id] = stop;
209 }
210 
211 
212 void
214  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myContainerStops.find(id);
215  if (it != myContainerStops.end()) {
216  WRITE_ERROR("The container stop '" + id + "' occurs at least twice.");
217  delete stop;
218  }
219  myContainerStops[id] = stop;
220 }
221 
222 
223 bool
225  return myRoutes.add(def->getID(), def);
226 }
227 
228 
229 void
230 RONet::openOutput(const OptionsCont& options, const std::string altFilename) {
231  if (options.isSet("output-file") && options.getString("output-file") != "") {
232  OutputDevice::createDeviceByOption("output-file", "routes", "routes_file.xsd");
234  }
235  if (altFilename != "") {
238  myRouteAlternativesOutput->writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/routes_file.xsd");
239  }
240  if (options.isSet("vtype-output") && options.getString("vtype-output") != "") {
241  OutputDevice::createDeviceByOption("vtype-output", "routes", "routes_file.xsd");
243  }
244 }
245 
246 
247 void
249  // end writing
250  if (myRoutesOutput != 0) {
252  }
253  // only if opened
254  if (myRouteAlternativesOutput != 0) {
256  }
257  // only if opened
258  if (myTypesOutput != 0) {
259  myTypesOutput->close();
260  }
262 #ifdef HAVE_FOX
263  if (myThreadPool.size() > 0) {
264  myThreadPool.clear();
265  }
266 #endif
267 }
268 
269 
270 
272 RONet::getVehicleTypeSecure(const std::string& id) {
273  // check whether the type was already known
275  if (id == DEFAULT_VTYPE_ID) {
277  }
278  if (id == DEFAULT_PEDTYPE_ID) {
280  }
281  if (type != 0) {
282  return type;
283  }
284  VTypeDistDictType::iterator it2 = myVTypeDistDict.find(id);
285  if (it2 != myVTypeDistDict.end()) {
286  return it2->second->get();
287  }
288  if (id == "") {
289  // ok, no vehicle type or an unknown type was given within the user input
290  // return the default type
293  }
294  return type;
295 }
296 
297 
298 bool
299 RONet::checkVType(const std::string& id) {
300  if (id == DEFAULT_VTYPE_ID) {
304  } else {
305  return false;
306  }
307  } else if (id == DEFAULT_PEDTYPE_ID) {
311  } else {
312  return false;
313  }
314  } else {
315  if (myVehicleTypes.get(id) != 0 || myVTypeDistDict.find(id) != myVTypeDistDict.end()) {
316  return false;
317  }
318  }
319  return true;
320 }
321 
322 
323 bool
325  if (checkVType(type->id)) {
326  myVehicleTypes.add(type->id, type);
327  } else {
328  WRITE_ERROR("The vehicle type '" + type->id + "' occurs at least twice.");
329  delete type;
330  return false;
331  }
332  return true;
333 }
334 
335 
336 bool
337 RONet::addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution) {
338  if (checkVType(id)) {
339  myVTypeDistDict[id] = vehTypeDistribution;
340  return true;
341  }
342  return false;
343 }
344 
345 
346 bool
347 RONet::addVehicle(const std::string& id, ROVehicle* veh) {
348  if (myVehIDs.find(id) == myVehIDs.end()) {
349  myVehIDs.insert(id);
350  myRoutables[veh->getDepart()].push_back(veh);
351  myReadRouteNo++;
352  return true;
353  }
354  WRITE_ERROR("Another vehicle with the id '" + id + "' exists.");
355  return false;
356 }
357 
358 
359 bool
360 RONet::addFlow(SUMOVehicleParameter* flow, const bool randomize) {
361  if (randomize) {
362  myDepartures[flow->id].reserve(flow->repetitionNumber);
363  for (int i = 0; i < flow->repetitionNumber; ++i) {
364  myDepartures[flow->id].push_back(flow->depart + RandHelper::rand(flow->repetitionNumber * flow->repetitionOffset));
365  }
366  std::sort(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
367  std::reverse(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
368  }
369  return myFlows.add(flow->id, flow);
370 }
371 
372 
373 bool
375  if (myPersonIDs.count(person->getID()) == 0) {
376  myPersonIDs.insert(person->getID());
377  myRoutables[person->getDepart()].push_back(person);
378  return true;
379  }
380  WRITE_ERROR("Another person with the id '" + person->getID() + "' exists.");
381  return false;
382 }
383 
384 
385 void
386 RONet::addContainer(const SUMOTime depart, const std::string desc) {
387  myContainers.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
388 }
389 
390 
391 void
392 RONet::checkFlows(SUMOTime time, MsgHandler* errorHandler) {
393  std::vector<std::string> toRemove;
395  SUMOVehicleParameter* pars = i->second;
396  if (pars->repetitionProbability > 0) {
397  const SUMOTime origDepart = pars->depart;
398  while (pars->depart < time) {
399  if (pars->repetitionEnd <= pars->depart) {
400  toRemove.push_back(i->first);
401  break;
402  }
403  // only call rand if all other conditions are met
404  if (RandHelper::rand() < (pars->repetitionProbability * TS)) {
405  SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
406  newPars->id = pars->id + "." + toString(pars->repetitionsDone);
407  newPars->depart = pars->depart;
408  for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->stops.begin(); stop != newPars->stops.end(); ++stop) {
409  if (stop->until >= 0) {
410  stop->until += pars->depart - origDepart;
411  }
412  }
413  pars->repetitionsDone++;
414  // try to build the vehicle
416  if (type == 0) {
418  } else {
419  // fix the type id in case we used a distribution
420  newPars->vtypeid = type->id;
421  }
422  const SUMOTime stopOffset = pars->routeid[0] == '!' ? pars->depart - origDepart : pars->depart;
423  RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id, stopOffset);
424  ROVehicle* veh = new ROVehicle(*newPars, route, type, this, errorHandler);
425  addVehicle(newPars->id, veh);
426  delete newPars;
427  }
428  pars->depart += DELTA_T;
429  }
430  } else {
431  while (pars->repetitionsDone < pars->repetitionNumber) {
432  SUMOTime depart = static_cast<SUMOTime>(pars->depart + pars->repetitionsDone * pars->repetitionOffset);
433  if (myDepartures.find(pars->id) != myDepartures.end()) {
434  depart = myDepartures[pars->id].back();
435  }
436  if (depart >= time + DELTA_T) {
437  break;
438  }
439  if (myDepartures.find(pars->id) != myDepartures.end()) {
440  myDepartures[pars->id].pop_back();
441  }
442  SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
443  newPars->id = pars->id + "." + toString(pars->repetitionsDone);
444  newPars->depart = depart;
445  for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->stops.begin(); stop != newPars->stops.end(); ++stop) {
446  if (stop->until >= 0) {
447  stop->until += depart - pars->depart;
448  }
449  }
450  pars->repetitionsDone++;
451  // try to build the vehicle
453  if (type == 0) {
455  } else {
456  // fix the type id in case we used a distribution
457  newPars->vtypeid = type->id;
458  }
459  const SUMOTime stopOffset = pars->routeid[0] == '!' ? depart - pars->depart : depart;
460  RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id, stopOffset);
461  ROVehicle* veh = new ROVehicle(*newPars, route, type, this, errorHandler);
462  addVehicle(newPars->id, veh);
463  delete newPars;
464  }
465  if (pars->repetitionsDone == pars->repetitionNumber) {
466  toRemove.push_back(i->first);
467  }
468  }
469  }
470  for (std::vector<std::string>::const_iterator i = toRemove.begin(); i != toRemove.end(); ++i) {
471  myFlows.erase(*i);
472  }
473 }
474 
475 
476 void
477 RONet::createBulkRouteRequests(const RORouterProvider& provider, const SUMOTime time, const bool removeLoops) {
478  std::map<const int, std::vector<RORoutable*> > bulkVehs;
479  for (RoutablesMap::const_iterator i = myRoutables.begin(); i != myRoutables.end(); ++i) {
480  if (i->first >= time) {
481  break;
482  }
483  for (std::deque<RORoutable*>::const_iterator r = i->second.begin(); r != i->second.end(); ++r) {
484  RORoutable* const routable = *r;
485  const ROEdge* const depEdge = routable->getDepartEdge();
486  bulkVehs[depEdge->getNumericalID()].push_back(routable);
487  RORoutable* const first = bulkVehs[depEdge->getNumericalID()].front();
488  if (first->getMaxSpeed() != routable->getMaxSpeed()) {
489  WRITE_WARNING("Bulking different maximum speeds ('" + first->getID() + "' and '" + routable->getID() + "') may lead to suboptimal routes.");
490  }
491  if (first->getVClass() != routable->getVClass()) {
492  WRITE_WARNING("Bulking different vehicle classes ('" + first->getID() + "' and '" + routable->getID() + "') may lead to invalid routes.");
493  }
494  }
495  }
496  int workerIndex = 0;
497  for (std::map<const int, std::vector<RORoutable*> >::const_iterator i = bulkVehs.begin(); i != bulkVehs.end(); ++i) {
498 #ifdef HAVE_FOX
499  if (myThreadPool.size() > 0) {
500  RORoutable* const first = i->second.front();
501  myThreadPool.add(new RoutingTask(first, removeLoops, myErrorHandler), workerIndex);
502  myThreadPool.add(new BulkmodeTask(true), workerIndex);
503  for (std::vector<RORoutable*>::const_iterator j = i->second.begin() + 1; j != i->second.end(); ++j) {
504  myThreadPool.add(new RoutingTask(*j, removeLoops, myErrorHandler), workerIndex);
505  }
506  myThreadPool.add(new BulkmodeTask(false), workerIndex);
507  workerIndex++;
508  if (workerIndex == (int)myThreadPool.size()) {
509  workerIndex = 0;
510  }
511  continue;
512  }
513 #endif
514  for (std::vector<RORoutable*>::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
515  (*j)->computeRoute(provider, removeLoops, myErrorHandler);
516  provider.getVehicleRouter().setBulkMode(true);
517  }
518  provider.getVehicleRouter().setBulkMode(false);
519  }
520 }
521 
522 
523 SUMOTime
525  SUMOTime time) {
526  MsgHandler* mh = (options.getBool("ignore-errors") ?
528  checkFlows(time, mh);
529  SUMOTime lastTime = -1;
530  const bool removeLoops = options.getBool("remove-loops");
531  const int maxNumThreads = options.getInt("routing-threads");
532  if (myRoutables.size() != 0) {
533  if (options.getBool("bulk-routing")) {
534 #ifdef HAVE_FOX
535  while ((int)myThreadPool.size() < maxNumThreads) {
536  new WorkerThread(myThreadPool, provider);
537  }
538 #endif
539  createBulkRouteRequests(provider, time, removeLoops);
540  } else {
541  for (RoutablesMap::const_iterator i = myRoutables.begin(); i != myRoutables.end(); ++i) {
542  if (i->first >= time) {
543  break;
544  }
545  for (std::deque<RORoutable*>::const_iterator r = i->second.begin(); r != i->second.end(); ++r) {
546  RORoutable* const routable = *r;
547 #ifdef HAVE_FOX
548  // add task
549  if (maxNumThreads > 0) {
550  // add thread if necessary
551  const int numThreads = (int)myThreadPool.size();
552  if (numThreads < maxNumThreads && myThreadPool.isFull()) {
553  new WorkerThread(myThreadPool, provider);
554  }
555  myThreadPool.add(new RoutingTask(routable, removeLoops, myErrorHandler));
556  continue;
557  }
558 #endif
559  routable->computeRoute(provider, removeLoops, myErrorHandler);
560  }
561  }
562  }
563 #ifdef HAVE_FOX
564  myThreadPool.waitAll();
565 #endif
566  }
567  // write all vehicles (and additional structures)
568  while (myRoutables.size() != 0 || myContainers.size() != 0) {
569  // get the next vehicle, person or container
570  RoutablesMap::iterator routables = myRoutables.begin();
571  const SUMOTime routableTime = routables == myRoutables.end() ? SUMOTime_MAX : routables->first;
572  ContainerMap::iterator container = myContainers.begin();
573  const SUMOTime containerTime = container == myContainers.end() ? SUMOTime_MAX : container->first;
574  // check whether it shall not yet be computed
575  if (routableTime >= time && containerTime >= time) {
576  lastTime = MIN2(routableTime, containerTime);
577  break;
578  }
579  const SUMOTime minTime = MIN2(routableTime, containerTime);
580  if (routableTime == minTime) {
581  const RORoutable* const r = routables->second.front();
582  // check whether to print the output
583  if (lastTime != routableTime && lastTime != -1) {
584  // report writing progress
585  if (options.getInt("stats-period") >= 0 && ((int) routableTime % options.getInt("stats-period")) == 0) {
586  WRITE_MESSAGE("Read: " + toString(myReadRouteNo) + ", Discarded: " + toString(myDiscardedRouteNo) + ", Written: " + toString(myWrittenRouteNo));
587  }
588  }
589  lastTime = routableTime;
590 
591  // ok, compute the route (try it)
592  if (r->getRoutingSuccess()) {
593  // write the route
596  } else {
598  }
599  const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(r);
600  // delete routes and the vehicle
601  if (veh != 0 && veh->getRouteDefinition()->getID()[0] == '!') {
602  if (!myRoutes.erase(veh->getRouteDefinition()->getID())) {
603  delete veh->getRouteDefinition();
604  }
605  }
606  routables->second.pop_front();
607  if (routables->second.empty()) {
608  myRoutables.erase(routables);
609  }
610  delete r;
611  }
612  if (containerTime == minTime) {
613  myRoutesOutput->writePreformattedTag(container->second);
614  if (myRouteAlternativesOutput != 0) {
616  }
617  myContainers.erase(container);
618  }
619  }
620  return lastTime;
621 }
622 
623 
624 bool
626  return myRoutables.size() > 0 || myFlows.size() > 0 || myContainers.size() > 0;
627 }
628 
629 
630 int
632  return myEdges.size();
633 }
634 
635 
636 int
638  return myNumInternalEdges;
639 }
640 
641 
642 const std::map<std::string, ROEdge*>&
644  return myEdges.getMyMap();
645 }
646 
647 
648 void
650  // add access to all public transport stops
651  for (std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator i = myInstance->myBusStops.begin(); i != myInstance->myBusStops.end(); ++i) {
652  router.addAccess(i->first, myInstance->getEdgeForLaneID(i->second->lane), i->second->endPos);
653  for (std::multimap<std::string, SUMOReal>::const_iterator a = i->second->accessPos.begin(); a != i->second->accessPos.end(); ++a) {
654  router.addAccess(i->first, myInstance->getEdgeForLaneID(a->first), a->second);
655  }
656  }
657  // fill the public transport router with pre-parsed public transport lines
658  for (std::map<std::string, SUMOVehicleParameter*>::const_iterator i = myInstance->myFlows.getMyMap().begin(); i != myInstance->myFlows.getMyMap().end(); ++i) {
659  if (i->second->line != "") {
660  router.addSchedule(*i->second);
661  }
662  }
663  for (RoutablesMap::const_iterator i = myInstance->myRoutables.begin(); i != myInstance->myRoutables.end(); ++i) {
664  for (std::deque<RORoutable*>::const_iterator r = i->second.begin(); r != i->second.end(); ++r) {
665  const ROVehicle* const veh = dynamic_cast<ROVehicle*>(*r);
666  // add single vehicles with line attribute which are not part of a flow
667  if (veh != 0 && veh->getParameter().line != "" && veh->getParameter().repetitionNumber < 0) {
668  router.addSchedule(veh->getParameter());
669  }
670  }
671  }
672 }
673 
674 
675 bool
677  return myHavePermissions;
678 }
679 
680 
681 void
683  myHavePermissions = true;
684 }
685 
686 
687 #ifdef HAVE_FOX
688 // ---------------------------------------------------------------------------
689 // RONet::RoutingTask-methods
690 // ---------------------------------------------------------------------------
691 void
692 RONet::RoutingTask::run(FXWorkerThread* context) {
693  myRoutable->computeRoute(*static_cast<WorkerThread*>(context), myRemoveLoops, myErrorHandler);
694 }
695 #endif
696 
697 
698 /****************************************************************************/
699 
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Definition: MsgHandler.cpp:71
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:171
SUMOReal repetitionProbability
The probability for emitting a vehicle per second.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:257
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
Definition: RONet.h:532
bool hasPermissions() const
Definition: RONet.cpp:676
void close()
Closes the device and removes it from the dictionary.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:80
long long int SUMOTime
Definition: SUMOTime.h:43
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const SUMOReal speed)
Adds a restriction for an edge type.
Definition: RONet.cpp:124
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
Definition: RONet.h:516
is a pedestrian
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:526
std::string vtypeid
The vehicle'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:547
bool getRoutingSuccess() const
Definition: RORoutable.h:144
int myNumInternalEdges
The number of internal edges in the dictionary.
Definition: RONet.h:553
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
Definition: RONet.cpp:299
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:649
void addNode(RONode *node)
Definition: RONet.cpp:193
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)
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed ...
Definition: OutputDevice.h:303
static SUMOReal rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
int repetitionsDone
The number of times the vehicle was already inserted.
void checkFlows(SUMOTime time, MsgHandler *errorHandler)
Definition: RONet.cpp:392
EdgeFunc getFunc() const
Returns the function of the edge.
Definition: ROEdge.h:190
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
NamedObjectCont< ROEdge * > myEdges
Known edges.
Definition: RONet.h:487
An internal edge which models vehicles driving across a junction. This is currently not used for rout...
Definition: ROEdge.h:97
void addAccess(const std::string &stopId, const E *stopEdge, const SUMOReal pos)
void setFunc(EdgeFunc func)
Sets the function of the edge.
Definition: ROEdge.h:141
int myDiscardedRouteNo
The number of discarded routes.
Definition: RONet.h:541
#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:523
OutputDevice * myTypesOutput
The file to write the vehicle types into.
Definition: RONet.h:535
const std::string DEFAULT_VTYPE_ID
int myWrittenRouteNo
The number of written routes.
Definition: RONet.h:544
#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:324
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition: RONet.cpp:347
const std::map< std::string, ROEdge * > & getEdgeMap() const
Definition: RONet.cpp:643
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
Definition: RONet.cpp:66
void openOutput(const OptionsCont &options, const std::string altFilename="")
Opens the output for computed routes.
Definition: RONet.cpp:230
std::vector< Stop > stops
List of the stops the vehicle will make.
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:189
std::set< std::string > myPersonIDs
Known person ids.
Definition: RONet.h:481
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:337
SUMOReal getMaxSpeed() const
Returns the vehicle's maximum speed.
Definition: RORoutable.h:112
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:248
bool addRouteDef(RORouteDef *def)
Definition: RONet.cpp:224
std::string routeid
The vehicle's route id.
OutputDevice * myRoutesOutput
The file to write the computed routes into.
Definition: RONet.h:529
void addContainer(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:386
std::map< std::string, SUMOVehicleParameter::Stop * > myContainerStops
Known container stops.
Definition: RONet.h:493
virtual bool remove(const std::string &id)
Removes an item.
RoutablesMap myRoutables
Known routables.
Definition: RONet.h:513
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
Definition: RONet.h:496
SUMOTime depart
The vehicle's departure time.
std::map< std::string, std::map< SUMOVehicleClass, SUMOReal > > myRestrictions
The vehicle class specific speed restrictions.
Definition: RONet.h:550
ContainerMap myContainers
Definition: RONet.h:520
virtual bool furtherStored()
Returns the information whether further vehicles, persons or containers are stored.
Definition: RONet.cpp:625
T MIN2(T a, T b)
Definition: StdDefs.h:69
A person as used by router.
Definition: ROPerson.h:58
static RONet * myInstance
Unique instance of RONet.
Definition: RONet.h:475
SUMOAbstractRouter< E, V > & getVehicleRouter() const
int getEdgeNo() const
Returns the total number of edges the network contains including internal edges.
Definition: RONet.cpp:631
bool myDefaultVTypeMayBeDeleted
Whether no vehicle type has been loaded yet.
Definition: RONet.h:504
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
Definition: RONet.h:510
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
void createBulkRouteRequests(const RORouterProvider &provider, const SUMOTime time, const bool removeLoops)
Definition: RONet.cpp:477
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) ...
void addSchedule(const SUMOVehicleParameter &pars)
std::string line
The vehicle's line (mainly for public transport)
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
Definition: RONet.cpp:637
virtual void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)=0
const IDMap & getMyMap() const
#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:74
The router's network representation.
Definition: RONet.h:76
bool addDistrict(const std::string id, ROEdge *source, ROEdge *sink)
Definition: RONet.cpp:154
Structure representing possible vehicle parameter.
virtual void addSuccessor(ROEdge *s, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:109
#define SUMOTime_MAX
Definition: SUMOTime.h:44
int myReadRouteNo
The number of read routes.
Definition: RONet.h:538
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:406
const std::string DEFAULT_PEDTYPE_ID
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
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:501
Base class for a vehicle's route definition.
Definition: RORouteDef.h:63
std::string id
The vehicle type's id.
void addBusStop(const std::string &id, SUMOVehicleParameter::Stop *stop)
Definition: RONet.cpp:202
virtual bool addEdge(ROEdge *edge)
Definition: RONet.cpp:140
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.
#define SUMOReal
Definition: config.h:214
std::set< std::string > myVehIDs
Known vehicle ids.
Definition: RONet.h:478
virtual ~RONet()
Destructor.
Definition: RONet.cpp:96
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:272
A thread repeatingly calculating incoming tasks.
MsgHandler * myErrorHandler
handler for ignorable error messages
Definition: RONet.h:556
Base class for nodes used by the router.
Definition: RONode.h:53
NamedObjectCont< RONode * > myNodes
Known nodes.
Definition: RONet.h:484
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:360
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
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:213
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:374
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition: RONet.h:327
vehicles ignoring classes
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, const RORouterProvider &provider, SUMOTime time)
Computes routes described by their definitions and saves them.
Definition: RONet.cpp:524
std::map< std::string, SUMOVehicleParameter::Stop * > myBusStops
Known bus stops.
Definition: RONet.h:490
int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:205
std::string id
The vehicle's id.
bool myDefaultPedTypeMayBeDeleted
Whether no pedestrian type has been loaded yet.
Definition: RONet.h:507
void setPermissionsFound()
Definition: RONet.cpp:682
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
const std::map< SUMOVehicleClass, SUMOReal > * getRestrictions(const std::string &id) const
Returns the restrictions for an edge type If no restrictions are present, 0 is returned.
Definition: RONet.cpp:130
int size() const
Returns the number of items within the container.