SUMO - Simulation of Urban MObility
RONet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // The router's network representation
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <algorithm>
38 #include <utils/common/ToString.h>
42 #include "ROEdge.h"
43 #include "RONode.h"
44 #include "ROPerson.h"
45 #include "RORoute.h"
46 #include "RORouteDef.h"
47 #include "ROVehicle.h"
48 #include "RONet.h"
49 
50 
51 // ===========================================================================
52 // static member definitions
53 // ===========================================================================
55 
56 
57 // ===========================================================================
58 // method definitions
59 // ===========================================================================
60 RONet*
62  if (myInstance != 0) {
63  return myInstance;
64  }
65  throw ProcessError("A network was not yet constructed.");
66 }
67 
68 
73  myHavePermissions(false),
75  myErrorHandler(OptionsCont::getOptions().exists("ignore-errors")
76  && OptionsCont::getOptions().getBool("ignore-errors") ? MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()),
77  myKeepVTypeDist(OptionsCont::getOptions().exists("keep-vtype-distributions")
78  && OptionsCont::getOptions().getBool("keep-vtype-distributions")) {
79  if (myInstance != 0) {
80  throw ProcessError("A network was already constructed.");
81  }
83  type->onlyReferenced = true;
84  myVehicleTypes.add(type->id, type);
86  defPedType->onlyReferenced = true;
88  myVehicleTypes.add(defPedType->id, defPedType);
89  myInstance = this;
90 }
91 
92 
94  for (RoutablesMap::iterator routables = myRoutables.begin(); routables != myRoutables.end(); ++routables) {
95  for (RORoutable* const r : routables->second) {
96  const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(r);
97  // delete routes and the vehicle
98  if (veh != 0 && veh->getRouteDefinition()->getID()[0] == '!') {
99  if (!myRoutes.remove(veh->getRouteDefinition()->getID())) {
100  delete veh->getRouteDefinition();
101  }
102  }
103  delete r;
104  }
105  }
106  for (const RORoutable* const r : myPTVehicles) {
107  const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(r);
108  // delete routes and the vehicle
109  if (veh != 0 && veh->getRouteDefinition()->getID()[0] == '!') {
110  if (!myRoutes.remove(veh->getRouteDefinition()->getID())) {
111  delete veh->getRouteDefinition();
112  }
113  }
114  delete r;
115  }
116  myRoutables.clear();
117 }
118 
119 
120 void
121 RONet::addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
122  myRestrictions[id][svc] = speed;
123 }
124 
125 
126 const std::map<SUMOVehicleClass, double>*
127 RONet::getRestrictions(const std::string& id) const {
128  std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i = myRestrictions.find(id);
129  if (i == myRestrictions.end()) {
130  return 0;
131  }
132  return &i->second;
133 }
134 
135 
136 bool
138  if (!myEdges.add(edge->getID(), edge)) {
139  WRITE_ERROR("The edge '" + edge->getID() + "' occurs at least twice.");
140  delete edge;
141  return false;
142  }
143  if (edge->isInternal()) {
144  myNumInternalEdges += 1;
145  }
146  return true;
147 }
148 
149 
150 bool
151 RONet::addDistrict(const std::string id, ROEdge* source, ROEdge* sink) {
152  if (myDistricts.count(id) > 0) {
153  WRITE_ERROR("The TAZ '" + id + "' occurs at least twice.");
154  delete source;
155  delete sink;
156  return false;
157  }
159  addEdge(sink);
161  addEdge(source);
162  myDistricts[id] = std::make_pair(std::vector<std::string>(), std::vector<std::string>());
163  return true;
164 }
165 
166 
167 bool
168 RONet::addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource) {
169  if (myDistricts.count(tazID) == 0) {
170  WRITE_ERROR("The TAZ '" + tazID + "' is unknown.");
171  return false;
172  }
173  ROEdge* edge = getEdge(edgeID);
174  if (edge == 0) {
175  WRITE_ERROR("The edge '" + edgeID + "' for TAZ '" + tazID + "' is unknown.");
176  return false;
177  }
178  if (isSource) {
179  getEdge(tazID + "-source")->addSuccessor(edge);
180  myDistricts[tazID].first.push_back(edgeID);
181  } else {
182  edge->addSuccessor(getEdge(tazID + "-sink"));
183  myDistricts[tazID].second.push_back(edgeID);
184  }
185  return true;
186 }
187 
188 
189 void
191  if (!myNodes.add(node->getID(), node)) {
192  WRITE_ERROR("The node '" + node->getID() + "' occurs at least twice.");
193  delete node;
194  }
195 }
196 
197 
198 void
199 RONet::addStoppingPlace(const std::string& id, const SumoXMLTag category, SUMOVehicleParameter::Stop* stop) {
200  if (!myStoppingPlaces[category == SUMO_TAG_TRAIN_STOP ? SUMO_TAG_BUS_STOP : category].add(id, stop)) {
201  WRITE_ERROR("The " + toString(category) + " '" + id + "' occurs at least twice.");
202  delete stop;
203  }
204 }
205 
206 
207 bool
209  return myRoutes.add(def->getID(), def);
210 }
211 
212 
213 void
215  if (options.isSet("output-file") && options.getString("output-file") != "") {
216  myRoutesOutput = &OutputDevice::getDevice(options.getString("output-file"));
218  myRoutesOutput->writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/routes_file.xsd");
219  }
220  if (options.exists("alternatives-output") && options.isSet("alternatives-output")) {
221  myRouteAlternativesOutput = &OutputDevice::getDevice(options.getString("alternatives-output"));
223  myRouteAlternativesOutput->writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/routes_file.xsd");
224  }
225  if (options.isSet("vtype-output")) {
226  myTypesOutput = &OutputDevice::getDevice(options.getString("vtype-output"));
228  myTypesOutput->writeAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").writeAttr("xsi:noNamespaceSchemaLocation", "http://sumo.dlr.de/xsd/routes_file.xsd");
229  }
230 }
231 
232 
233 void
234 RONet::writeIntermodal(const OptionsCont& options, ROIntermodalRouter& router) const {
235  if (options.exists("intermodal-network-output") && options.isSet("intermodal-network-output")) {
236  OutputDevice::createDeviceByOption("intermodal-network-output", "intermodal");
237  router.writeNetwork(OutputDevice::getDevice(options.getString("intermodal-network-output")));
238  }
239  if (options.exists("intermodal-weight-output") && options.isSet("intermodal-weight-output")) {
240  OutputDevice::createDeviceByOption("intermodal-weight-output", "weights", "meandata_file.xsd");
241  OutputDevice& dev = OutputDevice::getDeviceByOption("intermodal-weight-output");
243  dev.writeAttr(SUMO_ATTR_ID, "intermodalweights");
244  dev.writeAttr(SUMO_ATTR_BEGIN, 0);
246  router.writeWeights(dev);
247  dev.closeTag();
248  }
249 }
250 
251 
252 void
254  // end writing
255  if (myRoutesOutput != 0) {
257  }
258  // only if opened
259  if (myRouteAlternativesOutput != 0) {
261  }
262  // only if opened
263  if (myTypesOutput != 0) {
264  myTypesOutput->close();
265  }
267 #ifdef HAVE_FOX
268  if (myThreadPool.size() > 0) {
269  myThreadPool.clear();
270  }
271 #endif
272 }
273 
274 
275 
277 RONet::getVehicleTypeSecure(const std::string& id) {
278  // check whether the type was already known
280  if (id == DEFAULT_VTYPE_ID) {
282  }
283  if (id == DEFAULT_PEDTYPE_ID) {
285  }
286  if (type != 0) {
287  return type;
288  }
289  VTypeDistDictType::iterator it2 = myVTypeDistDict.find(id);
290  if (it2 != myVTypeDistDict.end()) {
291  return it2->second->get();
292  }
293  if (id == "") {
294  // ok, no vehicle type or an unknown type was given within the user input
295  // return the default type
298  }
299  return type;
300 }
301 
302 
303 bool
304 RONet::checkVType(const std::string& id) {
305  if (id == DEFAULT_VTYPE_ID) {
309  } else {
310  return false;
311  }
312  } else if (id == DEFAULT_PEDTYPE_ID) {
316  } else {
317  return false;
318  }
319  } else {
320  if (myVehicleTypes.get(id) != 0 || myVTypeDistDict.find(id) != myVTypeDistDict.end()) {
321  return false;
322  }
323  }
324  return true;
325 }
326 
327 
328 bool
330  if (checkVType(type->id)) {
331  myVehicleTypes.add(type->id, type);
332  } else {
333  WRITE_ERROR("The vehicle type '" + type->id + "' occurs at least twice.");
334  delete type;
335  return false;
336  }
337  return true;
338 }
339 
340 
341 bool
342 RONet::addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution) {
343  if (checkVType(id)) {
344  myVTypeDistDict[id] = vehTypeDistribution;
345  return true;
346  }
347  return false;
348 }
349 
350 
351 bool
352 RONet::addVehicle(const std::string& id, ROVehicle* veh) {
353  if (myVehIDs.find(id) == myVehIDs.end()) {
354  myVehIDs.insert(id);
355  if (veh->isPublicTransport()) {
356  if (!veh->isPartOfFlow()) {
357  myPTVehicles.push_back(veh);
358  }
359  if (OptionsCont::getOptions().exists("ptline-routing") && !OptionsCont::getOptions().getBool("ptline-routing")) {
360  return true;
361  }
362  }
363  myRoutables[veh->getDepart()].push_back(veh);
364  return true;
365  }
366  WRITE_ERROR("Another vehicle with the id '" + id + "' exists.");
367  return false;
368 }
369 
370 
371 bool
372 RONet::addFlow(SUMOVehicleParameter* flow, const bool randomize) {
373  if (randomize) {
374  myDepartures[flow->id].reserve(flow->repetitionNumber);
375  for (int i = 0; i < flow->repetitionNumber; ++i) {
376  myDepartures[flow->id].push_back(flow->depart + RandHelper::rand(flow->repetitionNumber * flow->repetitionOffset));
377  }
378  std::sort(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
379  std::reverse(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
380  }
381  return myFlows.add(flow->id, flow);
382 }
383 
384 
385 bool
387  if (myPersonIDs.count(person->getID()) == 0) {
388  myPersonIDs.insert(person->getID());
389  myRoutables[person->getDepart()].push_back(person);
390  return true;
391  }
392  WRITE_ERROR("Another person with the id '" + person->getID() + "' exists.");
393  return false;
394 }
395 
396 
397 void
398 RONet::addContainer(const SUMOTime depart, const std::string desc) {
399  myContainers.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
400 }
401 
402 
403 void
404 RONet::checkFlows(SUMOTime time, MsgHandler* errorHandler, const bool keepPT) {
405  std::vector<std::string> toRemove;
406  for (const auto& i : myFlows) {
407  SUMOVehicleParameter* pars = i.second;
408  if (pars->repetitionProbability > 0) {
409  const SUMOTime origDepart = pars->depart;
410  while (pars->depart < time) {
411  if (pars->repetitionEnd <= pars->depart) {
412  toRemove.push_back(i.first);
413  break;
414  }
415  // only call rand if all other conditions are met
416  if (RandHelper::rand() < (pars->repetitionProbability * TS)) {
417  SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
418  newPars->id = pars->id + "." + toString(pars->repetitionsDone);
419  newPars->depart = pars->depart;
420  for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->stops.begin(); stop != newPars->stops.end(); ++stop) {
421  if (stop->until >= 0) {
422  stop->until += pars->depart - origDepart;
423  }
424  }
425  pars->repetitionsDone++;
426  // try to build the vehicle
428  if (!myKeepVTypeDist) {
429  // fix the type id in case we used a distribution
430  newPars->vtypeid = type->id;
431  }
432  const SUMOTime stopOffset = pars->routeid[0] == '!' ? pars->depart - origDepart : pars->depart;
433  RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id, stopOffset);
434  ROVehicle* veh = new ROVehicle(*newPars, route, type, this, errorHandler);
435  addVehicle(newPars->id, veh);
436  delete newPars;
437  }
438  pars->depart += DELTA_T;
439  }
440  } else {
441  while (pars->repetitionsDone < pars->repetitionNumber) {
442  SUMOTime depart = static_cast<SUMOTime>(pars->depart + pars->repetitionsDone * pars->repetitionOffset);
443  if (myDepartures.find(pars->id) != myDepartures.end()) {
444  depart = myDepartures[pars->id].back();
445  }
446  if (depart >= time + DELTA_T) {
447  break;
448  }
449  if (myDepartures.find(pars->id) != myDepartures.end()) {
450  myDepartures[pars->id].pop_back();
451  }
452  SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
453  newPars->id = pars->id + "." + toString(pars->repetitionsDone);
454  newPars->depart = depart;
455  for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = newPars->stops.begin(); stop != newPars->stops.end(); ++stop) {
456  if (stop->until >= 0) {
457  stop->until += depart - pars->depart;
458  }
459  }
460  pars->repetitionsDone++;
461  // try to build the vehicle
463  if (type == 0) {
465  } else {
466  // fix the type id in case we used a distribution
467  newPars->vtypeid = type->id;
468  }
469  const SUMOTime stopOffset = pars->routeid[0] == '!' ? depart - pars->depart : depart;
470  RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id, stopOffset);
471  ROVehicle* veh = new ROVehicle(*newPars, route, type, this, errorHandler);
472  addVehicle(newPars->id, veh);
473  delete newPars;
474  }
475  if (pars->repetitionsDone == pars->repetitionNumber && (!keepPT || pars->line == "")) {
476  toRemove.push_back(i.first);
477  }
478  }
479  }
480  for (std::vector<std::string>::const_iterator i = toRemove.begin(); i != toRemove.end(); ++i) {
481  myFlows.remove(*i);
482  }
483 }
484 
485 
486 void
487 RONet::createBulkRouteRequests(const RORouterProvider& provider, const SUMOTime time, const bool removeLoops) {
488  std::map<const int, std::vector<RORoutable*> > bulkVehs;
489  for (RoutablesMap::const_iterator i = myRoutables.begin(); i != myRoutables.end(); ++i) {
490  if (i->first >= time) {
491  break;
492  }
493  for (RORoutable* const routable : i->second) {
494  const ROEdge* const depEdge = routable->getDepartEdge();
495  bulkVehs[depEdge->getNumericalID()].push_back(routable);
496  RORoutable* const first = bulkVehs[depEdge->getNumericalID()].front();
497  if (first->getMaxSpeed() != routable->getMaxSpeed()) {
498  WRITE_WARNING("Bulking different maximum speeds ('" + first->getID() + "' and '" + routable->getID() + "') may lead to suboptimal routes.");
499  }
500  if (first->getVClass() != routable->getVClass()) {
501  WRITE_WARNING("Bulking different vehicle classes ('" + first->getID() + "' and '" + routable->getID() + "') may lead to invalid routes.");
502  }
503  }
504  }
505  int workerIndex = 0;
506  for (std::map<const int, std::vector<RORoutable*> >::const_iterator i = bulkVehs.begin(); i != bulkVehs.end(); ++i) {
507 #ifdef HAVE_FOX
508  if (myThreadPool.size() > 0) {
509  RORoutable* const first = i->second.front();
510  myThreadPool.add(new RoutingTask(first, removeLoops, myErrorHandler), workerIndex);
511  myThreadPool.add(new BulkmodeTask(true), workerIndex);
512  for (std::vector<RORoutable*>::const_iterator j = i->second.begin() + 1; j != i->second.end(); ++j) {
513  myThreadPool.add(new RoutingTask(*j, removeLoops, myErrorHandler), workerIndex);
514  }
515  myThreadPool.add(new BulkmodeTask(false), workerIndex);
516  workerIndex++;
517  if (workerIndex == (int)myThreadPool.size()) {
518  workerIndex = 0;
519  }
520  continue;
521  }
522 #endif
523  for (std::vector<RORoutable*>::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
524  (*j)->computeRoute(provider, removeLoops, myErrorHandler);
525  provider.getVehicleRouter().setBulkMode(true);
526  }
527  provider.getVehicleRouter().setBulkMode(false);
528  }
529 }
530 
531 
532 SUMOTime
534  SUMOTime time) {
535  MsgHandler* mh = (options.getBool("ignore-errors") ?
537  checkFlows(time, mh, !provider.getIntermodalRouter().hasNet());
538  SUMOTime lastTime = -1;
539  const bool removeLoops = options.getBool("remove-loops");
540  const int maxNumThreads = options.getInt("routing-threads");
541  if (myRoutables.size() != 0) {
542  if (options.getBool("bulk-routing")) {
543 #ifdef HAVE_FOX
544  while ((int)myThreadPool.size() < maxNumThreads) {
545  new WorkerThread(myThreadPool, provider);
546  }
547 #endif
548  createBulkRouteRequests(provider, time, removeLoops);
549  } else {
550  for (RoutablesMap::const_iterator i = myRoutables.begin(); i != myRoutables.end(); ++i) {
551  if (i->first >= time) {
552  break;
553  }
554  for (RORoutable* const routable : i->second) {
555 #ifdef HAVE_FOX
556  // add task
557  if (maxNumThreads > 0) {
558  const int numThreads = (int)myThreadPool.size();
559  if (numThreads == 0) {
560  // This is the very first routing. Since at least the CHRouter needs initialization
561  // before it gets cloned, we do not do this in parallel
562  routable->computeRoute(provider, removeLoops, myErrorHandler);
563  new WorkerThread(myThreadPool, provider);
564  } else {
565  // add thread if necessary
566  if (numThreads < maxNumThreads && myThreadPool.isFull()) {
567  new WorkerThread(myThreadPool, provider);
568  }
569  myThreadPool.add(new RoutingTask(routable, removeLoops, myErrorHandler));
570  }
571  continue;
572  }
573 #endif
574  routable->computeRoute(provider, removeLoops, myErrorHandler);
575  }
576  }
577  }
578 #ifdef HAVE_FOX
579  myThreadPool.waitAll();
580 #endif
581  }
582  // write all vehicles (and additional structures)
583  while (myRoutables.size() != 0 || myContainers.size() != 0) {
584  // get the next vehicle, person or container
585  RoutablesMap::iterator routables = myRoutables.begin();
586  const SUMOTime routableTime = routables == myRoutables.end() ? SUMOTime_MAX : routables->first;
587  ContainerMap::iterator container = myContainers.begin();
588  const SUMOTime containerTime = container == myContainers.end() ? SUMOTime_MAX : container->first;
589  // check whether it shall not yet be computed
590  if (routableTime >= time && containerTime >= time) {
591  lastTime = MIN2(routableTime, containerTime);
592  break;
593  }
594  const SUMOTime minTime = MIN2(routableTime, containerTime);
595  if (routableTime == minTime) {
596  // check whether to print the output
597  if (lastTime != routableTime && lastTime != -1) {
598  // report writing progress
599  if (options.getInt("stats-period") >= 0 && ((int)routableTime % options.getInt("stats-period")) == 0) {
600  WRITE_MESSAGE("Read: " + toString(myVehIDs.size()) + ", Discarded: " + toString(myDiscardedRouteNo) + ", Written: " + toString(myWrittenRouteNo));
601  }
602  }
603  lastTime = routableTime;
604  for (const RORoutable* const r : routables->second) {
605  // ok, check whether it has been routed
606  if (r->getRoutingSuccess()) {
607  // write the route
610  } else {
612  }
613  // delete routes and the vehicle
614  if (!r->isPublicTransport() || r->isPartOfFlow()) {
615  const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(r);
616  if (veh != 0 && veh->getRouteDefinition()->getID()[0] == '!') {
617  if (!myRoutes.remove(veh->getRouteDefinition()->getID())) {
618  delete veh->getRouteDefinition();
619  }
620  }
621  delete r;
622  }
623  }
624  myRoutables.erase(routables);
625  }
626  if (containerTime == minTime) {
627  myRoutesOutput->writePreformattedTag(container->second);
628  if (myRouteAlternativesOutput != 0) {
630  }
631  myContainers.erase(container);
632  }
633  }
634  return lastTime;
635 }
636 
637 
638 bool
640  return myRoutables.size() > 0 || myFlows.size() > 0 || myContainers.size() > 0;
641 }
642 
643 
644 int
646  return myEdges.size();
647 }
648 
649 
650 int
652  return myNumInternalEdges;
653 }
654 
655 
656 void
658  // add access to all parking areas
659  for (const auto& i : myInstance->myStoppingPlaces[SUMO_TAG_PARKING_AREA]) {
660  router.addAccess(i.first, myInstance->getEdgeForLaneID(i.second->lane), (i.second->startPos + i.second->endPos) / 2., SUMO_TAG_PARKING_AREA);
661  }
662  // add access to all public transport stops
663  for (const auto& stop : myInstance->myStoppingPlaces[SUMO_TAG_BUS_STOP]) {
664  router.addAccess(stop.first, myInstance->getEdgeForLaneID(stop.second->lane), (stop.second->startPos + stop.second->endPos) / 2., SUMO_TAG_BUS_STOP);
665  for (std::multimap<std::string, double>::const_iterator a = stop.second->accessPos.begin(); a != stop.second->accessPos.end(); ++a) {
666  router.addAccess(stop.first, myInstance->getEdgeForLaneID(a->first), a->second, SUMO_TAG_BUS_STOP);
667  }
668  }
669  // fill the public transport router with pre-parsed public transport lines
670  for (const auto& i : myInstance->myFlows) {
671  if (i.second->line != "") {
672  RORouteDef* route = myInstance->getRouteDef(i.second->routeid);
673  const std::vector<SUMOVehicleParameter::Stop>* addStops = 0;
674  if (route != 0 && route->getFirstRoute() != 0) {
675  addStops = &route->getFirstRoute()->getStops();
676  }
677  router.addSchedule(*i.second, addStops);
678  }
679  }
680  for (const RORoutable* const veh : myInstance->myPTVehicles) {
681  // add single vehicles with line attribute which are not part of a flow
682  router.addSchedule(veh->getParameter());
683  }
684 }
685 
686 
687 bool
689  return myHavePermissions;
690 }
691 
692 
693 void
695  myHavePermissions = true;
696 }
697 
698 
699 #ifdef HAVE_FOX
700 // ---------------------------------------------------------------------------
701 // RONet::RoutingTask-methods
702 // ---------------------------------------------------------------------------
703 void
704 RONet::RoutingTask::run(FXWorkerThread* context) {
705  myRoutable->computeRoute(*static_cast<WorkerThread*>(context), myRemoveLoops, myErrorHandler);
706 }
707 #endif
708 
709 
710 /****************************************************************************/
711 
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Definition: MsgHandler.cpp:66
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
Definition: RORoutable.h:109
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:168
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:260
std::map< SumoXMLTag, NamedObjectCont< SUMOVehicleParameter::Stop * > > myStoppingPlaces
Known bus / train / container stops and parking areas.
Definition: RONet.h:469
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
Definition: RONet.h:511
void writeIntermodal(const OptionsCont &options, ROIntermodalRouter &router) const
Writes the intermodal network and weights if requested.
Definition: RONet.cpp:234
bool hasPermissions() const
Definition: RONet.cpp:688
void close()
Closes the device and removes it from the dictionary.
SumoXMLTag
Numbers representing SUMO-XML - element names.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:75
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
Definition: RONet.h:492
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:505
std::string vtypeid
The vehicle&#39;s type id.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
const std::map< SUMOVehicleClass, double > * getRestrictions(const std::string &id) const
Returns the restrictions for an edge type If no restrictions are present, 0 is returned.
Definition: RONet.cpp:127
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
Definition: RONet.h:526
bool getRoutingSuccess() const
Definition: RORoutable.h:160
int myNumInternalEdges
The number of internal edges in the dictionary.
Definition: RONet.h:532
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
Definition: RONet.cpp:304
Structure representing possible vehicle parameter.
static void adaptIntermodalRouter(ROIntermodalRouter &router)
Definition: RONet.cpp:657
void addNode(RONode *node)
Definition: RONet.cpp:190
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:163
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
double repetitionProbability
The probability for emitting a vehicle per second.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:64
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed ...
Definition: OutputDevice.h:306
int repetitionsDone
The number of times the vehicle was already inserted.
weights: time range begin
void writeNetwork(OutputDevice &dev)
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
NamedObjectCont< ROEdge * > myEdges
Known edges.
Definition: RONet.h:466
void writeWeights(OutputDevice &dev)
int myDiscardedRouteNo
The number of discarded routes.
Definition: RONet.h:520
#define TS
Definition: SUMOTime.h:51
std::map< std::string, std::vector< SUMOTime > > myDepartures
Departure times for randomized flows.
Definition: RONet.h:502
std::vector< const RORoutable * > myPTVehicles
vehicles to keep for public transport routing
Definition: RONet.h:499
OutputDevice * myTypesOutput
The file to write the vehicle types into.
Definition: RONet.h:514
const std::string DEFAULT_VTYPE_ID
int myWrittenRouteNo
The number of written routes.
Definition: RONet.h:523
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
Definition: RONet.cpp:329
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition: RONet.cpp:352
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
Definition: RONet.cpp:61
double getMaxSpeed() const
Returns the vehicle&#39;s maximum speed.
Definition: RORoutable.h:120
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
bool add(const std::string &id, T item)
Adds an item.
T get(const std::string &id) const
Retrieves an item.
bool writeHeader(const SumoXMLTag &rootElement)
Definition: OutputDevice.h:192
std::set< std::string > myPersonIDs
Known person ids.
Definition: RONet.h:460
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:61
void openOutput(const OptionsCont &options)
Opens the output for computed routes.
Definition: RONet.cpp:214
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:342
A vehicle as used by router.
Definition: ROVehicle.h:59
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary ...
Definition: RONet.cpp:253
root element of a route file
bool addRouteDef(RORouteDef *def)
Definition: RONet.cpp:208
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
Definition: RONet.cpp:121
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:149
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=0)
void addAccess(const std::string &stopId, const E *stopEdge, const double pos, const SumoXMLTag category)
Adds access edges for stopping places to the intermodal network.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
std::string routeid
The vehicle&#39;s route id.
OutputDevice * myRoutesOutput
The file to write the computed routes into.
Definition: RONet.h:508
#define SUMOTime_MAX
Definition: TraCIDefs.h:52
void addContainer(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:398
RoutablesMap myRoutables
Known routables.
Definition: RONet.h:489
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
Definition: RONet.h:472
SUMOTime depart
The vehicle&#39;s departure time.
ContainerMap myContainers
Definition: RONet.h:496
virtual bool furtherStored()
Returns the information whether further vehicles, persons or containers are stored.
Definition: RONet.cpp:639
bool isPartOfFlow() const
Definition: RORoutable.h:132
T MIN2(T a, T b)
Definition: StdDefs.h:67
A person as used by router.
Definition: ROPerson.h:57
static RONet * myInstance
Unique instance of RONet.
Definition: RONet.h:454
SUMOAbstractRouter< E, V > & getVehicleRouter() const
bool myDefaultVTypeMayBeDeleted
Whether no vehicle type has been loaded yet.
Definition: RONet.h:480
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
Definition: RONet.h:486
void createBulkRouteRequests(const RORouterProvider &provider, const SUMOTime time, const bool removeLoops)
Definition: RONet.cpp:487
const bool myKeepVTypeDist
whether to keep the the vtype distribution in output
Definition: RONet.h:538
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:651
virtual void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)=0
int parametersSet
Information for the router which parameter were set.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
ROEdge * getEdgeForLaneID(const std::string &laneID) const
Retrieves an edge from the network when the lane id is given.
Definition: RONet.h:173
RONet()
Constructor.
Definition: RONet.cpp:69
The router&#39;s network representation.
Definition: RONet.h:74
bool addDistrict(const std::string id, ROEdge *source, ROEdge *sink)
Definition: RONet.cpp:151
Structure representing possible vehicle parameter.
A train stop (alias for bus stop)
virtual void addSuccessor(ROEdge *s, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:106
int myReadRouteNo
The number of read routes.
Definition: RONet.h:517
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:411
void addStoppingPlace(const std::string &id, const SumoXMLTag category, SUMOVehicleParameter::Stop *stop)
Definition: RONet.cpp:199
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
Definition: RONet.h:529
int getEdgeNumber() const
Returns the total number of edges the network contains including internal edges.
Definition: RONet.cpp:645
const std::string DEFAULT_PEDTYPE_ID
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
weights: time range end
const std::string & getID() const
Returns the id of the routable.
Definition: RORoutable.h:100
Definition of vehicle stop (position and duration)
A storage for options typed value containers)
Definition: OptionsCont.h:98
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
Definition: RONet.h:477
Base class for a vehicle&#39;s route definition.
Definition: RORouteDef.h:62
std::string id
The vehicle type&#39;s id.
virtual bool addEdge(ROEdge *edge)
Definition: RONet.cpp:137
an aggreagated-output interval
IntermodalRouter< E, L, N, V > & getIntermodalRouter() const
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
Definition: RORoutable.h:80
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
bool closeTag()
Closes the most recently opened tag.
std::set< std::string > myVehIDs
Known vehicle ids.
Definition: RONet.h:457
virtual ~RONet()
Destructor.
Definition: RONet.cpp:93
const RORoute * getFirstRoute() const
Definition: RORouteDef.h:107
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:277
A thread repeatingly calculating incoming tasks.
MsgHandler * myErrorHandler
handler for ignorable error messages
Definition: RONet.h:535
long long int SUMOTime
Definition: TraCIDefs.h:51
Base class for nodes used by the router.
Definition: RONode.h:52
bool hasNet() const
NamedObjectCont< RONode * > myNodes
Known nodes.
Definition: RONet.h:463
bool isPublicTransport() const
Definition: RORoutable.h:128
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:147
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition: RONet.cpp:372
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:82
bool remove(const std::string &id, const bool del=true)
Removes an item.
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:200
const int VTYPEPARS_VEHICLECLASS_SET
SUMOVehicleClass getVClass() const
Definition: RORoutable.h:114
bool addPerson(ROPerson *person)
Definition: RONet.cpp:386
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition: RONet.h:301
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the list of stops this route contains.
Definition: RORoute.h:190
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, const RORouterProvider &provider, SUMOTime time)
Computes routes described by their definitions and saves them.
Definition: RONet.cpp:533
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
void checkFlows(SUMOTime time, MsgHandler *errorHandler, const bool keepPT)
Definition: RONet.cpp:404
int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:211
std::string id
The vehicle&#39;s id.
bool myDefaultPedTypeMayBeDeleted
Whether no pedestrian type has been loaded yet.
Definition: RONet.h:483
void setPermissionsFound()
Definition: RONet.cpp:694
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
int size() const
Returns the number of stored items within the container.
void setFunction(SumoXMLEdgeFunc func)
Sets the function of the edge.
Definition: ROEdge.h:119