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