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-2015 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>
34 #include "ROEdge.h"
35 #include "RONode.h"
36 #include "RONet.h"
37 #include "RORoute.h"
38 #include "RORouteDef.h"
39 #include "ROVehicle.h"
45 #include <utils/common/ToString.h>
49 
50 #ifdef CHECK_MEMORY_LEAKS
51 #include <foreign/nvwa/debug_new.h>
52 #endif // CHECK_MEMORY_LEAKS
53 
54 
55 // ===========================================================================
56 // static member definitions
57 // ===========================================================================
59 
60 
61 // ===========================================================================
62 // method definitions
63 // ===========================================================================
64 RONet*
66  if (myInstance != 0) {
67  return myInstance;
68  }
69  throw ProcessError("A network was not yet constructed.");
70 }
71 
72 
77  myHavePermissions(false),
79  myErrorHandler(OptionsCont::getOptions().exists("ignore-errors")
80  && OptionsCont::getOptions().getBool("ignore-errors") ? MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()) {
81  if (myInstance != 0) {
82  throw ProcessError("A network was already constructed.");
83  }
85  type->onlyReferenced = true;
86  myVehicleTypes.add(type->id, type);
87  myInstance = this;
88 }
89 
90 
92  myNodes.clear();
93  myEdges.clear();
95  myRoutes.clear();
96  myVehicles.clear();
97 }
98 
99 
100 void
101 RONet::addRestriction(const std::string& id, const SUMOVehicleClass svc, const SUMOReal speed) {
102  myRestrictions[id][svc] = speed;
103 }
104 
105 
106 const std::map<SUMOVehicleClass, SUMOReal>*
107 RONet::getRestrictions(const std::string& id) const {
108  std::map<std::string, std::map<SUMOVehicleClass, SUMOReal> >::const_iterator i = myRestrictions.find(id);
109  if (i == myRestrictions.end()) {
110  return 0;
111  }
112  return &i->second;
113 }
114 
115 
116 bool
118  if (!myEdges.add(edge->getID(), edge)) {
119  WRITE_ERROR("The edge '" + edge->getID() + "' occurs at least twice.");
120  delete edge;
121  return false;
122  }
123  if (edge->getFunc() == ROEdge::ET_INTERNAL) {
124  myNumInternalEdges += 1;
125  }
126  return true;
127 }
128 
129 
130 bool
131 RONet::addDistrict(const std::string id, ROEdge* source, ROEdge* sink) {
132  if (myDistricts.count(id) > 0) {
133  WRITE_ERROR("The TAZ '" + id + "' occurs at least twice.");
134  delete source;
135  delete sink;
136  return false;
137  }
139  addEdge(sink);
140  source->setFunc(ROEdge::ET_DISTRICT);
141  addEdge(source);
142  myDistricts[id] = std::make_pair(std::vector<std::string>(), std::vector<std::string>());
143  return true;
144 }
145 
146 
147 bool
148 RONet::addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource) {
149  if (myDistricts.count(tazID) == 0) {
150  WRITE_ERROR("The TAZ '" + tazID + "' is unknown.");
151  return false;
152  }
153  ROEdge* edge = getEdge(edgeID);
154  if (edge == 0) {
155  WRITE_ERROR("The edge '" + edgeID + "' for TAZ '" + tazID + "' is unknown.");
156  return false;
157  }
158  if (isSource) {
159  getEdge(tazID + "-source")->addSuccessor(edge);
160  myDistricts[tazID].first.push_back(edgeID);
161  } else {
162  edge->addSuccessor(getEdge(tazID + "-sink"));
163  myDistricts[tazID].second.push_back(edgeID);
164  }
165  return true;
166 }
167 
168 
169 void
171  if (!myNodes.add(node->getID(), node)) {
172  WRITE_ERROR("The node '" + node->getID() + "' occurs at least twice.");
173  delete node;
174  }
175 }
176 
177 
178 void
179 RONet::addBusStop(const std::string& id, SUMOVehicleParameter::Stop* stop) {
180  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myBusStops.find(id);
181  if (it != myBusStops.end()) {
182  WRITE_ERROR("The bus stop '" + id + "' occurs at least twice.");
183  delete stop;
184  }
185  myBusStops[id] = stop;
186 }
187 
188 
189 void
191  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myContainerStops.find(id);
192  if (it != myContainerStops.end()) {
193  WRITE_ERROR("The container stop '" + id + "' occurs at least twice.");
194  delete stop;
195  }
196  myContainerStops[id] = stop;
197 }
198 
199 
200 bool
202  return myRoutes.add(def->getID(), def);
203 }
204 
205 
206 void
207 RONet::openOutput(const std::string& filename, const std::string altFilename, const std::string typeFilename) {
208  if (filename != "") {
211  myRoutesOutput->writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/routes_file.xsd");
212  }
213  if (altFilename != "") {
216  myRouteAlternativesOutput->writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/routes_file.xsd");
217  }
218  if (typeFilename != "") {
219  myTypesOutput = &OutputDevice::getDevice(typeFilename);
220  myTypesOutput->writeXMLHeader("routes", "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/routes_file.xsd\"");
221  }
222 }
223 
224 
225 void
227  // end writing
228  if (myRoutesOutput != 0) {
230  }
231  // only if opened
232  if (myRouteAlternativesOutput != 0) {
234  }
235  // only if opened
236  if (myTypesOutput != 0) {
237  myTypesOutput->close();
238  }
240 #ifdef HAVE_FOX
241  if (myThreadPool.size() > 0) {
242  myThreadPool.clear();
243  return;
244  }
245 #endif
246  delete router;
247 }
248 
249 
250 
252 RONet::getVehicleTypeSecure(const std::string& id) {
253  // check whether the type was already known
255  if (id == DEFAULT_VTYPE_ID) {
257  }
258  if (type != 0) {
259  return type;
260  }
261  VTypeDistDictType::iterator it2 = myVTypeDistDict.find(id);
262  if (it2 != myVTypeDistDict.end()) {
263  return it2->second->get();
264  }
265  if (id == "") {
266  // ok, no vehicle type or an unknown type was given within the user input
267  // return the default type
270  }
271  return type;
272 }
273 
274 
275 bool
276 RONet::checkVType(const std::string& id) {
277  if (id == DEFAULT_VTYPE_ID) {
281  } else {
282  return false;
283  }
284  } else {
285  if (myVehicleTypes.get(id) != 0 || myVTypeDistDict.find(id) != myVTypeDistDict.end()) {
286  return false;
287  }
288  }
289  return true;
290 }
291 
292 
293 bool
295  if (checkVType(type->id)) {
296  myVehicleTypes.add(type->id, type);
297  } else {
298  WRITE_ERROR("The vehicle type '" + type->id + "' occurs at least twice.");
299  delete type;
300  return false;
301  }
302  return true;
303 }
304 
305 
306 bool
307 RONet::addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution) {
308  if (checkVType(id)) {
309  myVTypeDistDict[id] = vehTypeDistribution;
310  return true;
311  }
312  return false;
313 }
314 
315 
316 bool
317 RONet::addVehicle(const std::string& id, ROVehicle* veh) {
318  if (myVehIDs.find(id) == myVehIDs.end() && myVehicles.add(id, veh)) {
319  myVehIDs.insert(id);
320  myReadRouteNo++;
321  return true;
322  }
323  WRITE_ERROR("Another vehicle with the id '" + id + "' exists.");
324  return false;
325 }
326 
327 
328 bool
329 RONet::addFlow(SUMOVehicleParameter* flow, const bool randomize) {
330  if (randomize) {
331  myDepartures[flow->id].reserve(flow->repetitionNumber);
332  for (int i = 0; i < flow->repetitionNumber; ++i) {
333  myDepartures[flow->id].push_back(flow->depart + RandHelper::rand(flow->repetitionNumber * flow->repetitionOffset));
334  }
335  std::sort(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
336  std::reverse(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
337  }
338  return myFlows.add(flow->id, flow);
339 }
340 
341 
342 void
343 RONet::addPerson(const SUMOTime depart, const std::string desc) {
344  myPersons.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
345 }
346 
347 void
348 RONet::addContainer(const SUMOTime depart, const std::string desc) {
349  myContainers.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
350 }
351 
352 
353 bool
355  const ROVehicle* const veh, const bool removeLoops,
356  MsgHandler* errorHandler) {
357  std::string noRouteMsg = "The vehicle '" + veh->getID() + "' has no valid route.";
358  RORouteDef* const routeDef = veh->getRouteDefinition();
359  // check if the route definition is valid
360  if (routeDef == 0) {
361  errorHandler->inform(noRouteMsg);
362  return false;
363  }
364  RORoute* current = routeDef->buildCurrentRoute(router, veh->getDepartureTime(), *veh);
365  if (current == 0 || current->size() == 0) {
366  delete current;
367  errorHandler->inform(noRouteMsg);
368  return false;
369  }
370  // check whether we have to evaluate the route for not containing loops
371  if (removeLoops) {
372  current->recheckForLoops();
373  // check whether the route is still valid
374  if (current->size() == 0) {
375  delete current;
376  errorHandler->inform(noRouteMsg + " (after removing loops)");
377  return false;
378  }
379  }
380  // add built route
381  routeDef->addAlternative(router, veh, current, veh->getDepartureTime());
382  return true;
383 }
384 
385 
386 void
388  std::vector<std::string> toRemove;
390  SUMOVehicleParameter* pars = i->second;
391  if (pars->repetitionProbability > 0) {
392  while (pars->depart < time) {
393  if (pars->repetitionEnd <= pars->depart) {
394  toRemove.push_back(i->first);
395  break;
396  }
397  // only call rand if all other conditions are met
398  if (RandHelper::rand() < (pars->repetitionProbability * TS)) {
399  SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
400  newPars->id = pars->id + "." + toString(pars->repetitionsDone);
401  newPars->depart = pars->depart;
402  pars->repetitionsDone++;
403  // try to build the vehicle
405  if (type == 0) {
407  } else {
408  // fix the type id in case we used a distribution
409  newPars->vtypeid = type->id;
410  }
411  RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id);
412  ROVehicle* veh = new ROVehicle(*newPars, route, type, this);
413  addVehicle(newPars->id, veh);
414  delete newPars;
415  }
416  pars->depart += DELTA_T;
417  }
418  } else {
419  while (pars->repetitionsDone < pars->repetitionNumber) {
420  SUMOTime depart = static_cast<SUMOTime>(pars->depart + pars->repetitionsDone * pars->repetitionOffset);
421  if (myDepartures.find(pars->id) != myDepartures.end()) {
422  depart = myDepartures[pars->id].back();
423  }
424  if (depart >= time + DELTA_T) {
425  break;
426  }
427  if (myDepartures.find(pars->id) != myDepartures.end()) {
428  myDepartures[pars->id].pop_back();
429  }
430  SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
431  newPars->id = pars->id + "." + toString(pars->repetitionsDone);
432  newPars->depart = depart;
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  RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id);
443  ROVehicle* veh = new ROVehicle(*newPars, route, type, this);
444  addVehicle(newPars->id, veh);
445  delete newPars;
446  }
447  if (pars->repetitionsDone == pars->repetitionNumber) {
448  toRemove.push_back(i->first);
449  }
450  }
451  }
452  for (std::vector<std::string>::const_iterator i = toRemove.begin(); i != toRemove.end(); ++i) {
453  myFlows.erase(*i);
454  }
455 }
456 
457 
458 void
459 RONet::createBulkRouteRequests(SUMOAbstractRouter<ROEdge, ROVehicle>& router, const SUMOTime time, const bool removeLoops, const std::map<std::string, ROVehicle*>& mmap) {
460  std::map<const unsigned int, std::vector<ROVehicle*> > bulkVehs;
461  for (std::map<std::string, ROVehicle*>::const_iterator i = mmap.begin(); i != mmap.end(); ++i) {
462  ROVehicle* const vehicle = i->second;
463  if (vehicle->getDepart() < time) {
464  const RORoute* const stub = vehicle->getRouteDefinition()->getFirstRoute();
465  bulkVehs[stub->getFirst()->getNumericalID()].push_back(vehicle);
466  ROVehicle* const first = bulkVehs[stub->getFirst()->getNumericalID()].front();
467  if (first->getMaxSpeed() != vehicle->getMaxSpeed()) {
468  WRITE_WARNING("Bulking different maximum speeds ('" + first->getID() + "' and '" + vehicle->getID() + "') may lead to suboptimal routes.");
469  }
470  if (first->getVClass() != vehicle->getVClass()) {
471  WRITE_WARNING("Bulking different vehicle classes ('" + first->getID() + "' and '" + vehicle->getID() + "') may lead to invalid routes.");
472  }
473  }
474  }
475  int workerIndex = 0;
476  for (std::map<const unsigned int, std::vector<ROVehicle*> >::const_iterator i = bulkVehs.begin(); i != bulkVehs.end(); ++i) {
477 #ifdef HAVE_FOX
478  if (myThreadPool.size() > 0) {
479  ROVehicle* const first = i->second.front();
480  myThreadPool.add(new RoutingTask(first, removeLoops, myErrorHandler), workerIndex);
481  myThreadPool.add(new BulkmodeTask(true), workerIndex);
482  for (std::vector<ROVehicle*>::const_iterator j = i->second.begin() + 1; j != i->second.end(); ++j) {
483  myThreadPool.add(new RoutingTask(*j, removeLoops, myErrorHandler), workerIndex);
484  }
485  myThreadPool.add(new BulkmodeTask(false), workerIndex);
486  workerIndex++;
487  if (workerIndex == (int)myThreadPool.size()) {
488  workerIndex = 0;
489  }
490  continue;
491  }
492 #endif
493  for (std::vector<ROVehicle*>::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
494  (*j)->setRoutingSuccess(computeRoute(router, *j, removeLoops, myErrorHandler));
495  router.setBulkMode(true);
496  }
497  router.setBulkMode(false);
498  }
499 }
500 
501 
502 SUMOTime
504  SUMOTime time) {
505  checkFlows(time);
506  SUMOTime lastTime = -1;
507  const bool removeLoops = options.getBool("remove-loops");
508 #ifdef HAVE_FOX
509  const int maxNumThreads = options.getInt("routing-threads");
510 #endif
511  if (myVehicles.size() != 0) {
512  const std::map<std::string, ROVehicle*>& mmap = myVehicles.getMyMap();
513  if (options.getBool("bulk-routing")) {
514 #ifdef HAVE_FOX
515  while ((int)myThreadPool.size() < maxNumThreads) {
516  new WorkerThread(myThreadPool, myThreadPool.size() == 0 ? &router : router.clone());
517  }
518 #endif
519  createBulkRouteRequests(router, time, removeLoops, mmap);
520  } else {
521  for (std::map<std::string, ROVehicle*>::const_iterator i = mmap.begin(); i != mmap.end(); ++i) {
522  ROVehicle* const vehicle = i->second;
523  if (vehicle->getDepart() >= time) {
524  // we cannot go through a sorted list here, because the priority queue in the myVehicles container is not fully sorted
525  continue;
526  }
527 #ifdef HAVE_FOX
528  // add task
529  if (maxNumThreads > 0) {
530  vehicle->setRoutingSuccess(false);
531  // add thread if necessary
532  const int numThreads = (int)myThreadPool.size();
533  if (numThreads < maxNumThreads && myThreadPool.isFull()) {
534  new WorkerThread(myThreadPool, numThreads == 0 ? &router : router.clone());
535  }
536  myThreadPool.add(new RoutingTask(vehicle, removeLoops, myErrorHandler));
537  continue;
538  }
539 #endif
540  vehicle->setRoutingSuccess(computeRoute(router, vehicle, removeLoops, myErrorHandler));
541  }
542  }
543 #ifdef HAVE_FOX
544  myThreadPool.waitAll();
545 #endif
546  }
547  // write all vehicles (and additional structures)
548  while (myVehicles.size() != 0 || myPersons.size() != 0 || myContainers.size() != 0) {
549  // get the next vehicle, person or container
550  const ROVehicle* const veh = myVehicles.getTopVehicle();
551  const SUMOTime vehicleTime = veh == 0 ? SUMOTime_MAX : veh->getDepart();
552  PersonMap::iterator person = myPersons.begin();
553  const SUMOTime personTime = person == myPersons.end() ? SUMOTime_MAX : person->first;
554  ContainerMap::iterator container = myContainers.begin();
555  const SUMOTime containerTime = container == myContainers.end() ? SUMOTime_MAX : container->first;
556  // check whether it shall not yet be computed
557  if (vehicleTime >= time && personTime >= time && containerTime >= time) {
558  lastTime = MIN3(vehicleTime, personTime, containerTime);
559  break;
560  }
561  SUMOTime minTime = MIN3(vehicleTime, personTime, containerTime);
562  if (vehicleTime == minTime) {
563  // check whether to print the output
564  if (lastTime != vehicleTime && lastTime != -1) {
565  // report writing progress
566  if (options.getInt("stats-period") >= 0 && ((int) vehicleTime % options.getInt("stats-period")) == 0) {
567  WRITE_MESSAGE("Read: " + toString(myReadRouteNo) + ", Discarded: " + toString(myDiscardedRouteNo) + ", Written: " + toString(myWrittenRouteNo));
568  }
569  }
570  lastTime = vehicleTime;
571 
572  // ok, compute the route (try it)
573  if (veh->getRoutingSuccess()) {
574  // write the route
576  veh->saveAllAsXML(*myRoutesOutput, false, options.getBool("exit-times"));
577  if (myRouteAlternativesOutput != 0) {
578  veh->saveAllAsXML(*myRouteAlternativesOutput, true, options.getBool("exit-times"));
579  }
581  } else {
583  }
584  // delete routes and the vehicle
585  if (veh->getRouteDefinition()->getID()[0] == '!') {
586  if (!myRoutes.erase(veh->getRouteDefinition()->getID())) {
587  delete veh->getRouteDefinition();
588  }
589  }
590  myVehicles.erase(veh->getID());
591  }
592  if (personTime == minTime) {
593  myRoutesOutput->writePreformattedTag(person->second);
594  if (myRouteAlternativesOutput != 0) {
596  }
597  myPersons.erase(person);
598  }
599  if (containerTime == minTime) {
600  myRoutesOutput->writePreformattedTag(container->second);
601  if (myRouteAlternativesOutput != 0) {
603  }
604  myContainers.erase(container);
605  }
606  }
607  return lastTime;
608 }
609 
610 
611 bool
613  return myVehicles.size() > 0 || myFlows.size() > 0 || myPersons.size() > 0 || myContainers.size() > 0;
614 }
615 
616 
617 size_t
619  return myEdges.size();
620 }
621 
622 
623 int
625  return myNumInternalEdges;
626 }
627 
628 
629 const std::map<std::string, ROEdge*>&
631  return myEdges.getMyMap();
632 }
633 
634 
635 bool
637  return myHavePermissions;
638 }
639 
640 
641 void
643  myHavePermissions = true;
644 }
645 
646 
647 #ifdef HAVE_FOX
648 // ---------------------------------------------------------------------------
649 // RONet::RoutingTask-methods
650 // ---------------------------------------------------------------------------
651 void
652 RONet::RoutingTask::run(FXWorkerThread* context) {
653  myVehicle->setRoutingSuccess(RONet::computeRoute(static_cast<WorkerThread*>(context)->getRouter(), myVehicle, myRemoveLoops, myErrorHandler));
654 }
655 #endif
656 
657 
658 /****************************************************************************/
659 
SUMOTime getDepartureTime() const
Returns the time the vehicle starts at, 0 for triggered vehicles.
Definition: ROVehicle.h:112
const std::string & getID() const
Returns the id of the vehicle.
Definition: ROVehicle.h:103
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:148
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:504
bool hasPermissions() const
Definition: RONet.cpp:636
void close()
Closes the device and removes it from the dictionary.
void setRoutingSuccess(const bool val)
Definition: ROVehicle.h:166
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:101
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
Definition: RONet.h:484
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > myDistricts
traffic assignment zones with sources and sinks
Definition: RONet.h:498
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:519
int myNumInternalEdges
The number of internal edges in the dictionary.
Definition: RONet.h:525
void clear()
Deletes all vehicles stored; clears the lists.
size_t getEdgeNo() const
Returns the total number of edges the network contains including internal edges.
Definition: RONet.cpp:618
unsigned int size() const
Returns the number of edges in this route.
Definition: RORoute.h:146
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
Definition: RONet.cpp:276
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.
SUMOVehicleClass getVClass() const
Definition: ROVehicle.h:132
Structure representing possible vehicle parameter.
void addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin)
Adds an alternative to the list of routes.
Definition: RORouteDef.cpp:284
void addNode(RONode *node)
Definition: RONet.cpp:170
RORoute * buildCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Triggers building of the complete route (via preComputeCurrentRoute) or returns precomputed route...
Definition: RORouteDef.cpp:95
virtual SUMOAbstractRouter * clone() const =0
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:158
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 createBulkRouteRequests(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const SUMOTime time, const bool removeLoops, const std::map< std::string, ROVehicle * > &mmap)
Definition: RONet.cpp:459
EdgeFunc getFunc() const
Returns the function of the edge.
Definition: ROEdge.h:186
SUMOReal getMaxSpeed() const
Returns the vehicle&#39;s maximum speed.
Definition: ROVehicle.cpp:153
void recheckForLoops()
Checks whether this route contains loops and removes such.
Definition: RORoute.cpp:86
NamedObjectCont< ROEdge * > myEdges
Known edges.
Definition: RONet.h:458
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
Definition: ROVehicle.h:120
An internal edge which models vehicles driving across a junction. This is currently not used for rout...
Definition: ROEdge.h:93
unsigned int myDiscardedRouteNo
The number of discarded routes.
Definition: RONet.h:513
void setFunc(EdgeFunc func)
Sets the function of the edge.
Definition: ROEdge.h:137
#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:495
OutputDevice * myTypesOutput
The file to write the vehicle types into.
Definition: RONet.h:507
SUMOReal repetitionOffset
The time offset between vehicle reinsertions.
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:294
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition: RONet.cpp:317
const std::map< std::string, ROEdge * > & getEdgeMap() const
Definition: RONet.cpp:630
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
Definition: RONet.cpp:65
virtual bool add(const std::string &id, ROVehicle *item)
Adds a vehicle to the container.
void openOutput(const std::string &filename, const std::string altFilename, const std::string typeFilename)
Opens the output for computed routes.
Definition: RONet.cpp:207
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 checkFlows(SUMOTime time)
Definition: RONet.cpp:387
void clear()
Removes all items from the container (deletes them, too)
bool writeHeader(const SumoXMLTag &rootElement)
Definition: OutputDevice.h:189
void saveTypeAsXML(OutputDevice &os, OutputDevice *const altos, OutputDevice *const typeos) const
Saves the vehicle type if it was not saved before.
Definition: ROVehicle.cpp:116
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:307
bool getRoutingSuccess() const
Definition: ROVehicle.h:170
A vehicle as used by router.
Definition: ROVehicle.h:60
bool addRouteDef(RORouteDef *def)
Definition: RONet.cpp:201
std::string routeid
The vehicle&#39;s route id.
OutputDevice * myRoutesOutput
The file to write the computed routes into.
Definition: RONet.h:501
void addContainer(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:348
std::map< std::string, SUMOVehicleParameter::Stop * > myContainerStops
Known container stops.
Definition: RONet.h:464
virtual bool remove(const std::string &id)
Removes an item.
const ROVehicle * getTopVehicle() const
Returns the vehicle that departs most early.
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
Definition: RONet.h:467
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:522
void addPerson(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:343
ContainerMap myContainers
Definition: RONet.h:492
virtual bool furtherStored()
Returns the information whether further vehicles, persons or containers are stored.
Definition: RONet.cpp:612
unsigned int size() const
Returns the number of items within the container.
unsigned int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:201
ROVehicleCont myVehicles
Known vehicles.
Definition: RONet.h:481
static RONet * myInstance
Unique instance of RONet.
Definition: RONet.h:449
unsigned int myReadRouteNo
The number of read routes.
Definition: RONet.h:510
bool myDefaultVTypeMayBeDeleted
Whether no vehicle type was loaded.
Definition: RONet.h:475
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
Definition: RONet.h:478
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
const ROEdge * getFirst() const
Returns the first edge in the route.
Definition: RORoute.h:94
bool erase(const std::string &id)
Tries to remove (and delete) the named vehicle.
A basic edge for routing applications.
Definition: ROEdge.h:73
bool onlyReferenced
Information whether this is a type-stub, being only referenced but not defined (needed by routers) ...
void saveAllAsXML(OutputDevice &os, bool asAlternatives, bool withExitTimes) const
Saves the complete vehicle description.
Definition: ROVehicle.cpp:135
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
Definition: RONet.cpp:624
const IDMap & getMyMap() const
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
RONet()
Constructor.
Definition: RONet.cpp:73
The router&#39;s network representation.
Definition: RONet.h:72
bool addDistrict(const std::string id, ROEdge *source, ROEdge *sink)
Definition: RONet.cpp:131
Structure representing possible vehicle parameter.
virtual void addSuccessor(ROEdge *s, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:110
#define SUMOTime_MAX
Definition: SUMOTime.h:44
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
RORouteDef * copy(const std::string &id) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:406
Definition of vehicle stop (position and duration)
PersonMap myPersons
Definition: RONet.h:488
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:89
A storage for options typed value containers)
Definition: OptionsCont.h:108
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
Definition: RONet.h:472
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:179
virtual bool addEdge(ROEdge *edge)
Definition: RONet.cpp:117
static bool computeRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const veh, const bool removeLoops, MsgHandler *errorHandler)
Definition: RONet.cpp:354
#define SUMOReal
Definition: config.h:214
std::set< std::string > myVehIDs
Known vehicle ids.
Definition: RONet.h:452
virtual ~RONet()
Destructor.
Definition: RONet.cpp:91
const RORoute * getFirstRoute() const
Definition: RORouteDef.h:108
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:252
A thread repeatingly calculating incoming tasks.
MsgHandler * myErrorHandler
handler for ignorable error messages
Definition: RONet.h:528
T MIN3(T a, T b, T c)
Definition: StdDefs.h:86
Base class for nodes used by the router.
Definition: RONode.h:53
#define DELTA_T
Definition: SUMOTime.h:50
NamedObjectCont< RONode * > myNodes
Known nodes.
Definition: RONet.h:455
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition: RONet.cpp:329
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:83
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime time)
Computes routes described by their definitions and saves them.
Definition: RONet.cpp:503
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
void cleanup(SUMOAbstractRouter< ROEdge, ROVehicle > *router)
closes the file output for computed routes and deletes routers and associated threads if necessary ...
Definition: RONet.cpp:226
void addContainerStop(const std::string &id, SUMOVehicleParameter::Stop *stop)
Definition: RONet.cpp:190
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition: RONet.h:310
vehicles ignoring classes
std::map< std::string, SUMOVehicleParameter::Stop * > myBusStops
Known bus stops.
Definition: RONet.h:461
A complete router&#39;s route.
Definition: RORoute.h:62
std::string id
The vehicle&#39;s id.
void setPermissionsFound()
Definition: RONet.cpp:642
void setBulkMode(const bool mode)
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:107
unsigned int myWrittenRouteNo
The number of written routes.
Definition: RONet.h:516