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