Eclipse SUMO - Simulation of Urban MObility
MSNet.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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
26 // The simulated network and simulation perfomer
27 /****************************************************************************/
28 #include <config.h>
29 
30 #ifdef HAVE_VERSION_H
31 #include <version.h>
32 #endif
33 
34 #include <string>
35 #include <iostream>
36 #include <sstream>
37 #include <typeinfo>
38 #include <algorithm>
39 #include <cassert>
40 #include <vector>
41 #include <ctime>
42 
43 #ifdef HAVE_FOX
45 #endif
47 #include <utils/common/ToString.h>
48 #include <utils/common/SysUtils.h>
63 #include <utils/xml/XMLSubSys.h>
65 #include <libsumo/Simulation.h>
66 #include <mesosim/MELoop.h>
67 #include <mesosim/MESegment.h>
100 #include <utils/router/FareModul.h>
101 
102 #include "MSEdgeControl.h"
103 #include "MSJunctionControl.h"
104 #include "MSInsertionControl.h"
105 #include "MSDynamicShapeUpdater.h"
106 #include "MSEventControl.h"
107 #include "MSEdge.h"
108 #include "MSJunction.h"
109 #include "MSJunctionLogic.h"
110 #include "MSLane.h"
111 #include "MSVehicleControl.h"
112 #include "MSVehicleTransfer.h"
113 #include "MSRoute.h"
114 #include "MSGlobals.h"
115 #include "MSEdgeWeightsStorage.h"
116 #include "MSStateHandler.h"
117 #include "MSFrame.h"
118 #include "MSParkingArea.h"
119 #include "MSStoppingPlace.h"
120 #include "MSNet.h"
121 
122 
123 // ===========================================================================
124 // debug constants
125 // ===========================================================================
126 //#define DEBUG_SIMSTEP
127 
128 
129 // ===========================================================================
130 // static member definitions
131 // ===========================================================================
132 MSNet* MSNet::myInstance = nullptr;
133 
134 const std::string MSNet::STAGE_EVENTS("events");
135 const std::string MSNet::STAGE_MOVEMENTS("move");
136 const std::string MSNet::STAGE_LANECHANGE("laneChange");
137 const std::string MSNet::STAGE_INSERTIONS("insertion");
138 
139 // ===========================================================================
140 // static member method definitions
141 // ===========================================================================
142 double
143 MSNet::getEffort(const MSEdge* const e, const SUMOVehicle* const v, double t) {
144  double value;
145  const MSVehicle* const veh = dynamic_cast<const MSVehicle* const>(v);
146  if (veh != nullptr && veh->getWeightsStorage().retrieveExistingEffort(e, t, value)) {
147  return value;
148  }
149  if (getInstance()->getWeightsStorage().retrieveExistingEffort(e, t, value)) {
150  return value;
151  }
152  return 0;
153 }
154 
155 
156 double
157 MSNet::getTravelTime(const MSEdge* const e, const SUMOVehicle* const v, double t) {
158  double value;
159  const MSVehicle* const veh = dynamic_cast<const MSVehicle* const>(v);
160  if (veh != nullptr && veh->getWeightsStorage().retrieveExistingTravelTime(e, t, value)) {
161  return value;
162  }
164  return value;
165  }
166  return e->getMinimumTravelTime(v);
167 }
168 
169 
170 // ---------------------------------------------------------------------------
171 // MSNet - methods
172 // ---------------------------------------------------------------------------
173 MSNet*
175  if (myInstance != nullptr) {
176  return myInstance;
177  }
178  throw ProcessError("A network was not yet constructed.");
179 }
180 
181 void
183  if (!MSGlobals::gUseMesoSim) {
185  }
186 }
187 
188 void
190  if (!MSGlobals::gUseMesoSim) {
192  }
193 }
194 
195 
196 MSNet::MSNet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
197  MSEventControl* endOfTimestepEvents,
198  MSEventControl* insertionEvents,
199  ShapeContainer* shapeCont):
200  myAmInterrupted(false),
201  myVehiclesMoved(0),
202  myPersonsMoved(0),
203  myHavePermissions(false),
204  myHasInternalLinks(false),
205  myJunctionHigherSpeeds(false),
206  myHasElevation(false),
207  myHasPedestrianNetwork(false),
208  myHasBidiEdges(false),
209  myEdgeDataEndTime(-1),
210  myDynamicShapeUpdater(nullptr) {
211  if (myInstance != nullptr) {
212  throw ProcessError("A network was already constructed.");
213  }
215  myStep = string2time(oc.getString("begin"));
216  myMaxTeleports = oc.getInt("max-num-teleports");
217  myLogExecutionTime = !oc.getBool("no-duration-log");
218  myLogStepNumber = !oc.getBool("no-step-log");
219  myLogStepPeriod = oc.getInt("step-log.period");
220  myInserter = new MSInsertionControl(*vc, string2time(oc.getString("max-depart-delay")), oc.getBool("eager-insert"), oc.getInt("max-num-vehicles"),
221  string2time(oc.getString("random-depart-offset")));
222  myVehicleControl = vc;
224  myEdges = nullptr;
225  myJunctions = nullptr;
226  myRouteLoaders = nullptr;
227  myLogics = nullptr;
228  myPersonControl = nullptr;
229  myContainerControl = nullptr;
230  myEdgeWeights = nullptr;
231  myShapeContainer = shapeCont == nullptr ? new ShapeContainer() : shapeCont;
232 
233  myBeginOfTimestepEvents = beginOfTimestepEvents;
234  myEndOfTimestepEvents = endOfTimestepEvents;
235  myInsertionEvents = insertionEvents;
236  myLanesRTree.first = false;
237 
239  MSGlobals::gMesoNet = new MELoop(string2time(oc.getString("meso-recheck")));
240  }
241  myInstance = this;
242  initStatic();
243 }
244 
245 
246 void
248  SUMORouteLoaderControl* routeLoaders,
249  MSTLLogicControl* tlc,
250  std::vector<SUMOTime> stateDumpTimes,
251  std::vector<std::string> stateDumpFiles,
252  bool hasInternalLinks,
253  bool junctionHigherSpeeds,
254  double version) {
255  myEdges = edges;
256  myJunctions = junctions;
257  myRouteLoaders = routeLoaders;
258  myLogics = tlc;
259  // save the time the network state shall be saved at
260  myStateDumpTimes = stateDumpTimes;
261  myStateDumpFiles = stateDumpFiles;
262  myStateDumpPeriod = string2time(oc.getString("save-state.period"));
263  myStateDumpPrefix = oc.getString("save-state.prefix");
264  myStateDumpSuffix = oc.getString("save-state.suffix");
265 
266  // initialise performance computation
268  myTraCIMillis = 0;
270  myJunctionHigherSpeeds = junctionHigherSpeeds;
274  myVersion = version;
277  throw ProcessError("Option weights.separate-turns is only supported when simulating with internal lanes");
278  }
279 }
280 
281 
283  cleanupStatic();
284  // delete controls
285  delete myJunctions;
286  delete myDetectorControl;
287  // delete mean data
288  delete myEdges;
289  delete myInserter;
290  delete myLogics;
291  delete myRouteLoaders;
292  if (myPersonControl != nullptr) {
293  delete myPersonControl;
294  }
295  if (myContainerControl != nullptr) {
296  delete myContainerControl;
297  }
298  delete myVehicleControl; // must happen after deleting transportables
299  // delete events late so that vehicles can get rid of references first
301  myBeginOfTimestepEvents = nullptr;
302  delete myEndOfTimestepEvents;
303  myEndOfTimestepEvents = nullptr;
304  delete myInsertionEvents;
305  myInsertionEvents = nullptr;
306  delete myShapeContainer;
307  delete myEdgeWeights;
308  for (auto& router : myRouterTT) {
309  delete router.second;
310  }
311  myRouterTT.clear();
312  for (auto& router : myRouterEffort) {
313  delete router.second;
314  }
315  myRouterEffort.clear();
316  for (auto& router : myPedestrianRouter) {
317  delete router.second;
318  }
319  myPedestrianRouter.clear();
320  for (auto& router : myIntermodalRouter) {
321  delete router.second;
322  }
323  myIntermodalRouter.clear();
324  myLanesRTree.second.RemoveAll();
325  clearAll();
327  delete MSGlobals::gMesoNet;
328  }
329  myInstance = nullptr;
330 }
331 
332 
333 void
334 MSNet::addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
335  myRestrictions[id][svc] = speed;
336 }
337 
338 
339 const std::map<SUMOVehicleClass, double>*
340 MSNet::getRestrictions(const std::string& id) const {
341  std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i = myRestrictions.find(id);
342  if (i == myRestrictions.end()) {
343  return nullptr;
344  }
345  return &i->second;
346 }
347 
348 void
349 MSNet::addMesoType(const std::string& typeID, const MESegment::MesoEdgeType& edgeType) {
350  myMesoEdgeTypes[typeID] = edgeType;
351 }
352 
354 MSNet::getMesoType(const std::string& typeID) {
355  if (myMesoEdgeTypes.count(typeID) == 0) {
356  // init defaults
357  const OptionsCont& oc = OptionsCont::getOptions();
358  MESegment::MesoEdgeType edgeType;
359  edgeType.tauff = string2time(oc.getString("meso-tauff"));
360  edgeType.taufj = string2time(oc.getString("meso-taufj"));
361  edgeType.taujf = string2time(oc.getString("meso-taujf"));
362  edgeType.taujj = string2time(oc.getString("meso-taujj"));
363  edgeType.jamThreshold = oc.getFloat("meso-jam-threshold");
364  edgeType.junctionControl = oc.getBool("meso-junction-control");
365  edgeType.tlsPenalty = oc.getFloat("meso-tls-penalty");
366  edgeType.tlsFlowPenalty = oc.getFloat("meso-tls-flow-penalty");
367  edgeType.minorPenalty = string2time(oc.getString("meso-minor-penalty"));
368  edgeType.overtaking = oc.getBool("meso-overtaking");
369  myMesoEdgeTypes[typeID] = edgeType;
370  }
371  return myMesoEdgeTypes[typeID];
372 }
373 
376  // report the begin when wished
377  WRITE_MESSAGE("Simulation version " + std::string(VERSION_STRING) + " started with time: " + time2string(start));
378  // the simulation loop
380  // state loading may have changed the start time so we need to reinit it
381  myStep = start;
382  int numSteps = 0;
383  bool doStepLog = false;
384  while (state == SIMSTATE_RUNNING) {
385  doStepLog = myLogStepNumber && (numSteps % myLogStepPeriod == 0);
386  if (doStepLog) {
388  }
389  simulationStep();
390  if (doStepLog) {
392  }
393  state = adaptToState(simulationState(stop));
394 #ifdef DEBUG_SIMSTEP
395  std::cout << SIMTIME << " MSNet::simulate(" << start << ", " << stop << ")"
396  << "\n simulation state: " << getStateMessage(state)
397  << std::endl;
398 #endif
399  numSteps++;
400  }
401  if (myLogStepNumber && !doStepLog) {
402  // ensure some output on the last step
405  }
406  // exit simulation loop
407  if (myLogStepNumber) {
408  // start new line for final verbose output
409  std::cout << "\n";
410  }
411  closeSimulation(start, getStateMessage(state));
412  return state;
413 }
414 
415 
416 void
419 }
420 
421 
422 const std::string
424  std::ostringstream msg;
425  if (myLogExecutionTime) {
426  long duration = SysUtils::getCurrentMillis() - mySimBeginMillis;
427  // print performance notice
428  msg << "Performance: " << "\n" << " Duration: " << elapsedMs2string(duration) << "\n";
429  if (duration != 0) {
430  if (TraCIServer::getInstance() != nullptr) {
431  msg << " TraCI-Duration: " << elapsedMs2string(myTraCIMillis) << "\n";
432  }
433  msg << " Real time factor: " << (STEPS2TIME(myStep - start) * 1000. / (double)duration) << "\n";
434  msg.setf(std::ios::fixed, std::ios::floatfield); // use decimal format
435  msg.setf(std::ios::showpoint); // print decimal point
436  msg << " UPS: " << ((double)myVehiclesMoved / ((double)duration / 1000)) << "\n";
437  if (myPersonsMoved > 0) {
438  msg << " UPS-Persons: " << ((double)myPersonsMoved / ((double)duration / 1000)) << "\n";
439  }
440  }
441  // print vehicle statistics
442  const std::string discardNotice = ((myVehicleControl->getLoadedVehicleNo() != myVehicleControl->getDepartedVehicleNo()) ?
443  " (Loaded: " + toString(myVehicleControl->getLoadedVehicleNo()) + ")" : "");
444  msg << "Vehicles: " << "\n"
445  << " Inserted: " << myVehicleControl->getDepartedVehicleNo() << discardNotice << "\n"
446  << " Running: " << myVehicleControl->getRunningVehicleNo() << "\n"
447  << " Waiting: " << myInserter->getWaitingVehicleNo() << "\n";
448 
450  // print optional teleport statistics
451  std::vector<std::string> reasons;
452  if (myVehicleControl->getCollisionCount() > 0) {
453  reasons.push_back("Collisions: " + toString(myVehicleControl->getCollisionCount()));
454  }
455  if (myVehicleControl->getTeleportsJam() > 0) {
456  reasons.push_back("Jam: " + toString(myVehicleControl->getTeleportsJam()));
457  }
458  if (myVehicleControl->getTeleportsYield() > 0) {
459  reasons.push_back("Yield: " + toString(myVehicleControl->getTeleportsYield()));
460  }
462  reasons.push_back("Wrong Lane: " + toString(myVehicleControl->getTeleportsWrongLane()));
463  }
464  msg << "Teleports: " << myVehicleControl->getTeleportCount() << " (" << joinToString(reasons, ", ") << ")\n";
465  }
466  if (myVehicleControl->getEmergencyStops() > 0) {
467  msg << "Emergency Stops: " << myVehicleControl->getEmergencyStops() << "\n";
468  }
469  if (myPersonControl != nullptr && myPersonControl->getLoadedNumber() > 0) {
470  msg << "Persons: " << "\n"
471  << " Inserted: " << myPersonControl->getLoadedNumber() << "\n"
472  << " Running: " << myPersonControl->getRunningNumber() << "\n";
473  if (myPersonControl->getJammedNumber() > 0) {
474  msg << " Jammed: " << myPersonControl->getJammedNumber() << "\n";
475  }
476  }
477  if (myContainerControl != nullptr && myContainerControl->getLoadedNumber() > 0) {
478  msg << "Containers: " << "\n"
479  << " Inserted: " << myContainerControl->getLoadedNumber() << "\n"
480  << " Running: " << myContainerControl->getRunningNumber() << "\n";
481  if (myContainerControl->getJammedNumber() > 0) {
482  msg << " Jammed: " << myContainerControl->getJammedNumber() << "\n";
483  }
484  }
485  }
486  if (OptionsCont::getOptions().getBool("duration-log.statistics")) {
488  }
489  return msg.str();
490 }
491 
492 void
494  OutputDevice& od = OutputDevice::getDeviceByOption("collision-output");
495  for (const auto& item : myCollisions) {
496  for (const auto& c : item.second) {
497  od.openTag("collision");
499  od.writeAttr("type", c.type);
500  od.writeAttr("lane", c.lane->getID());
501  od.writeAttr("pos", c.pos);
502  od.writeAttr("collider", item.first);
503  od.writeAttr("victim", c.victim);
504  od.writeAttr("colliderType", c.colliderType);
505  od.writeAttr("victimType", c.victimType);
506  od.writeAttr("colliderSpeed", c.colliderSpeed);
507  od.writeAttr("victimSpeed", c.victimSpeed);
508  od.closeTag();
509  }
510  }
511 
512 }
513 
514 void
516  OutputDevice& od = OutputDevice::getDeviceByOption("statistic-output");
517  od.openTag("vehicles");
521  od.writeAttr("waiting", myInserter->getWaitingVehicleNo());
522  od.closeTag();
523  od.openTag("teleports");
528  od.closeTag();
529  od.openTag("safety");
530  od.writeAttr("collisions", myVehicleControl->getCollisionCount());
531  od.writeAttr("emergencyStops", myVehicleControl->getEmergencyStops());
532  od.closeTag();
533  od.openTag("persons");
534  od.writeAttr("loaded", myPersonControl != nullptr ? myPersonControl->getLoadedNumber() : 0);
535  od.writeAttr("running", myPersonControl != nullptr ? myPersonControl->getRunningNumber() : 0);
536  od.writeAttr("jammed", myPersonControl != nullptr ? myPersonControl->getJammedNumber() : 0);
537  od.closeTag();
538  if (OptionsCont::getOptions().isSet("tripinfo-output") || OptionsCont::getOptions().getBool("duration-log.statistics")) {
540  }
541 
542 }
543 
544 void
545 MSNet::closeSimulation(SUMOTime start, const std::string& reason) {
546  // report the end when wished
547  WRITE_MESSAGE("Simulation ended at time: " + time2string(getCurrentTimeStep()));
548  if (reason != "") {
549  WRITE_MESSAGE("Reason: " + reason);
550  }
552  if (MSStopOut::active() && OptionsCont::getOptions().getBool("stop-output.write-unfinished")) {
554  }
555  if (OptionsCont::getOptions().getBool("vehroute-output.write-unfinished")) {
557  }
558  if (OptionsCont::getOptions().getBool("tripinfo-output.write-unfinished")) {
560  }
561  if (OptionsCont::getOptions().isSet("chargingstations-output")) {
563  }
564  if (OptionsCont::getOptions().isSet("overheadwiresegments-output")) {
566  }
567  if (OptionsCont::getOptions().isSet("substations-output")) {
569  }
570  if (OptionsCont::getOptions().isSet("railsignal-block-output")) {
572  }
573  if (myLogExecutionTime || OptionsCont::getOptions().getBool("duration-log.statistics")) {
575  }
576  if (OptionsCont::getOptions().isSet("statistic-output")) {
577  writeStatistics();
578  }
579 }
580 
581 
582 void
584 #ifdef DEBUG_SIMSTEP
585  std::cout << SIMTIME << ": MSNet::simulationStep() called"
586  << ", myStep = " << myStep
587  << std::endl;
588 #endif
590  if (t != nullptr) {
591  if (myLogExecutionTime) {
593  }
595 #ifdef DEBUG_SIMSTEP
596  bool loadRequested = !TraCI::getLoadArgs().empty();
597  assert(t->getTargetTime() >= myStep || loadRequested || TraCIServer::wasClosed());
598 #endif
599  if (myLogExecutionTime) {
601  }
602  if (TraCIServer::wasClosed()) {
603  return;
604  }
605  }
606 #ifdef DEBUG_SIMSTEP
607  std::cout << SIMTIME << ": TraCI target time: " << t->getTargetTime() << std::endl;
608 #endif
609  // execute beginOfTimestepEvents
610  if (myLogExecutionTime) {
612  }
613  // simulation state output
614  std::vector<SUMOTime>::iterator timeIt = std::find(myStateDumpTimes.begin(), myStateDumpTimes.end(), myStep);
615  if (timeIt != myStateDumpTimes.end()) {
616  const int dist = (int)distance(myStateDumpTimes.begin(), timeIt);
618  }
619  if (myStateDumpPeriod > 0 && myStep % myStateDumpPeriod == 0) {
620  std::string timeStamp = time2string(myStep);
621  std::replace(timeStamp.begin(), timeStamp.end(), ':', '-');
622  const std::string filename = myStateDumpPrefix + "_" + timeStamp + myStateDumpSuffix;
624  myPeriodicStateFiles.push_back(filename);
625  int keep = OptionsCont::getOptions().getInt("save-state.period.keep");
626  if (keep > 0 && (int)myPeriodicStateFiles.size() > keep) {
627  std::remove(myPeriodicStateFiles.front().c_str());
629  }
630  }
633 #ifdef HAVE_FOX
634  MSRoutingEngine::waitForAll();
635 #endif
638  }
639  // check whether the tls programs need to be switched
641 
645  } else {
646  // assure all lanes with vehicles are 'active'
648 
649  // compute safe velocities for all vehicles for the next few lanes
650  // also register ApproachingVehicleInformation for all links
652 
653  // register junction approaches based on planned velocities as basis for right-of-way decision
655 
656  // decide right-of-way and execute movements
660  }
661 
662  // vehicles may change lanes
664 
667  }
668  }
669  loadRoutes();
670 
671  // persons
672  if (myPersonControl != nullptr && myPersonControl->hasTransportables()) {
674  }
675  // containers
678  }
679  // insert vehicles
682 #ifdef HAVE_FOX
683  MSRoutingEngine::waitForAll();
684 #endif
687  //myEdges->patchActiveLanes(); // @note required to detect collisions on lanes that were empty before insertion. wasteful?
689  }
691 
692  // execute endOfTimestepEvents
694 
695  if (myLogExecutionTime) {
697  }
699  if (myLogExecutionTime) {
702  }
704  // collisions from the previous step were kept to avoid duplicate
705  // warnings. we must remove them now to ensure correct output.
707  }
708  // update and write (if needed) detector values
709  writeOutput();
710 
711  if (myLogExecutionTime) {
714  if (myPersonControl != nullptr) {
716  }
717  }
718  myStep += DELTA_T;
719 }
720 
721 
724  if (TraCIServer::wasClosed()) {
726  }
727  if (TraCIServer::getInstance() != nullptr && !TraCIServer::getInstance()->getLoadArgs().empty()) {
728  return SIMSTATE_LOADING;
729  }
730  if ((stopTime < 0 || myStep > stopTime) && TraCIServer::getInstance() == nullptr && (stopTime > 0 || myStep > myEdgeDataEndTime)) {
732  && (myInserter->getPendingFlowCount() == 0)
733  && (myPersonControl == nullptr || !myPersonControl->hasNonWaiting())
737  }
738  }
739  if (stopTime >= 0 && myStep >= stopTime) {
741  }
744  }
745  if (myAmInterrupted) {
746  return SIMSTATE_INTERRUPTED;
747  }
748  return SIMSTATE_RUNNING;
749 }
750 
751 
754  if (state == SIMSTATE_LOADING) {
757  } else if (state != SIMSTATE_RUNNING && TraCIServer::getInstance() != nullptr && !TraCIServer::wasClosed()) {
758  // overrides SIMSTATE_END_STEP_REACHED, e.g. (TraCI ignore SUMO's --end option)
759  return SIMSTATE_RUNNING;
760  } else if (state == SIMSTATE_NO_FURTHER_VEHICLES) {
761  if (myPersonControl != nullptr) {
763  }
764  if (myContainerControl != nullptr) {
766  }
768  }
769  return state;
770 }
771 
772 
773 std::string
775  switch (state) {
777  return "";
779  return "The final simulation step has been reached.";
781  return "All vehicles have left the simulation.";
783  return "TraCI requested termination.";
785  return "An error occurred (see log).";
787  return "Interrupted.";
789  return "Too many teleports.";
791  return "TraCI issued load command.";
792  default:
793  return "Unknown reason.";
794  }
795 }
796 
797 
798 void
800  // clear container
801  MSEdge::clear();
802  MSLane::clear();
803  MSRoute::clear();
815  if (t != nullptr) {
816  t->cleanup();
817  }
820 }
821 
822 
823 void
825  MSGlobals::gClearState = true;
828  for (int i = 0; i < MSEdge::dictSize(); i++) {
829  for (MESegment* s = MSGlobals::gMesoNet->getSegmentForEdge(*MSEdge::getAllEdges()[i]); s != nullptr; s = s->getNextSegment()) {
830  s->clearState();
831  }
832  }
833  } else {
834  for (int i = 0; i < MSEdge::dictSize(); i++) {
835  const std::vector<MSLane*>& lanes = MSEdge::getAllEdges()[i]->getLanes();
836  for (MSLane* lane : lanes) {
837  lane->getVehiclesSecure();
838  lane->clearState();
839  lane->releaseVehicles();
840  }
841  }
842  }
846  MSRoute::dict_clearState(); // delete all routes after vehicles are deleted
847  myLogics->clearState();
851  for (auto& item : myStoppingPlaces) {
852  for (auto& item2 : item.second) {
853  item2.second->clearState();
854  }
855  }
860  if (myPersonControl != nullptr) {
862  }
863  if (myContainerControl != nullptr) {
865  }
866  myStep = step;
867  MSGlobals::gClearState = false;
868 }
869 
870 
871 void
873  // update detector values
875  const OptionsCont& oc = OptionsCont::getOptions();
876 
877  // check state dumps
878  if (oc.isSet("netstate-dump")) {
880  oc.getInt("netstate-dump.precision"));
881  }
882 
883  // check fcd dumps
884  if (OptionsCont::getOptions().isSet("fcd-output")) {
886  }
887 
888  // check emission dumps
889  if (OptionsCont::getOptions().isSet("emission-output")) {
891  oc.getInt("emission-output.precision"));
892  }
893 
894  // battery dumps
895  if (OptionsCont::getOptions().isSet("battery-output")) {
897  oc.getInt("battery-output.precision"));
898  }
899 
900  // elecHybrid dumps
901  if (OptionsCont::getOptions().isSet("elechybrid-output")) {
902  std::string output = OptionsCont::getOptions().getString("elechybrid-output");
903 
904  if (oc.getBool("elechybrid-output.aggregated")) {
905  // build a xml file with aggregated device.elechybrid output
907  oc.getInt("elechybrid-output.precision"));
908  } else {
909  // build a separate xml file for each vehicle equipped with device.elechybrid
910  // RICE_TODO: Does this have to be placed here in MSNet.cpp ?
912  for (MSVehicleControl::constVehIt it = vc.loadedVehBegin(); it != vc.loadedVehEnd(); ++it) {
913  const SUMOVehicle* veh = it->second;
914  if (!veh->isOnRoad()) {
915  continue;
916  }
917  if (static_cast<MSDevice_ElecHybrid*>(veh->getDevice(typeid(MSDevice_ElecHybrid))) != nullptr) {
918  std::string vehID = veh->getID();
919  std::string filename2 = output + "_" + vehID + ".xml";
920  OutputDevice& dev = OutputDevice::getDevice(filename2);
921  std::map<SumoXMLAttr, std::string> attrs;
922  attrs[SUMO_ATTR_VEHICLE] = vehID;
925  dev.writeXMLHeader("elecHybrid-export", "", attrs);
926  MSElecHybridExport::write(OutputDevice::getDevice(filename2), veh, myStep, oc.getInt("elechybrid-output.precision"));
927  }
928  }
929  }
930  }
931 
932 
933  // check full dumps
934  if (OptionsCont::getOptions().isSet("full-output")) {
936  }
937 
938  // check queue dumps
939  if (OptionsCont::getOptions().isSet("queue-output")) {
941  }
942 
943  // check amitran dumps
944  if (OptionsCont::getOptions().isSet("amitran-output")) {
946  }
947 
948  // check vtk dumps
949  if (OptionsCont::getOptions().isSet("vtk-output")) {
950 
951  if (MSNet::getInstance()->getVehicleControl().getRunningVehicleNo() > 0) {
952  std::string timestep = time2string(myStep);
953  timestep = timestep.substr(0, timestep.length() - 3);
954  std::string output = OptionsCont::getOptions().getString("vtk-output");
955  std::string filename = output + "_" + timestep + ".vtp";
956 
957  OutputDevice_File dev(filename, false);
958 
959  //build a huge mass of xml files
961 
962  }
963 
964  }
965 
966  // summary output
967  if (OptionsCont::getOptions().isSet("summary-output")) {
968  OutputDevice& od = OutputDevice::getDeviceByOption("summary-output");
969  int departedVehiclesNumber = myVehicleControl->getDepartedVehicleNo();
970  const double meanWaitingTime = departedVehiclesNumber != 0 ? myVehicleControl->getTotalDepartureDelay() / (double) departedVehiclesNumber : -1.;
971  int endedVehicleNumber = myVehicleControl->getEndedVehicleNo();
972  const double meanTravelTime = endedVehicleNumber != 0 ? myVehicleControl->getTotalTravelTime() / (double) endedVehicleNumber : -1.;
973  od.openTag("step");
974  od.writeAttr("time", time2string(myStep));
978  od.writeAttr("waiting", myInserter->getWaitingVehicleNo());
981  od.writeAttr("collisions", myVehicleControl->getCollisionCount());
982  od.writeAttr("teleports", myVehicleControl->getTeleportCount());
985  od.writeAttr("meanWaitingTime", meanWaitingTime);
986  od.writeAttr("meanTravelTime", meanTravelTime);
987  std::pair<double, double> meanSpeed = myVehicleControl->getVehicleMeanSpeeds();
988  od.writeAttr("meanSpeed", meanSpeed.first);
989  od.writeAttr("meanSpeedRelative", meanSpeed.second);
990  if (myLogExecutionTime) {
991  od.writeAttr("duration", mySimStepDuration);
992  }
993  od.closeTag();
994  }
995  if (OptionsCont::getOptions().isSet("person-summary-output")) {
996  OutputDevice& od = OutputDevice::getDeviceByOption("person-summary-output");
998  od.openTag("step");
999  od.writeAttr("time", time2string(myStep));
1000  od.writeAttr("loaded", pc.getLoadedNumber());
1001  od.writeAttr("inserted", pc.getDepartedNumber());
1002  od.writeAttr("walking", pc.getMovingNumber());
1003  od.writeAttr("waitingForRide", pc.getWaitingForVehicleNumber());
1004  od.writeAttr("riding", pc.getRidingNumber());
1005  od.writeAttr("stopping", pc.getWaitingUntilNumber());
1006  od.writeAttr("jammed", pc.getJammedNumber());
1007  od.writeAttr("ended", pc.getEndedNumber());
1008  od.writeAttr("arrived", pc.getArrivedNumber());
1009  if (myLogExecutionTime) {
1010  od.writeAttr("duration", mySimStepDuration);
1011  }
1012  od.closeTag();
1013 
1014  }
1015 
1016  // write detector values
1018 
1019  // write link states
1020  if (OptionsCont::getOptions().isSet("link-output")) {
1021  OutputDevice& od = OutputDevice::getDeviceByOption("link-output");
1022  od.openTag("timestep");
1024  for (const MSEdge* const edge : myEdges->getEdges()) {
1025  for (const MSLane* const lane : edge->getLanes()) {
1026  for (const MSLink* const link : lane->getLinkCont()) {
1027  link->writeApproaching(od, lane->getID());
1028  }
1029  }
1030  }
1031  od.closeTag();
1032  }
1033 
1034  // write SSM output
1035  for (MSDevice_SSM* dev : MSDevice_SSM::getInstances()) {
1036  dev->updateAndWriteOutput();
1037  }
1038 
1039  // write ToC output
1040  for (MSDevice_ToC* dev : MSDevice_ToC::getInstances()) {
1041  if (dev->generatesOutput()) {
1042  dev->writeOutput();
1043  }
1044  }
1045 
1046  if (OptionsCont::getOptions().isSet("collision-output")) {
1047  writeCollisions();
1048  }
1049 }
1050 
1051 
1052 bool
1054  return myLogExecutionTime;
1055 }
1056 
1057 
1060  if (myPersonControl == nullptr) {
1062  }
1063  return *myPersonControl;
1064 }
1065 
1066 
1069  if (myContainerControl == nullptr) {
1071  }
1072  return *myContainerControl;
1073 }
1074 
1077  myDynamicShapeUpdater = std::unique_ptr<MSDynamicShapeUpdater> (new MSDynamicShapeUpdater(*myShapeContainer));
1078  return myDynamicShapeUpdater.get();
1079 }
1080 
1083  if (myEdgeWeights == nullptr) {
1085  }
1086  return *myEdgeWeights;
1087 }
1088 
1089 
1090 void
1092  std::cout << "Step #" << time2string(myStep);
1093 }
1094 
1095 
1096 void
1098  if (myLogExecutionTime) {
1099  std::ostringstream oss;
1100  oss.setf(std::ios::fixed, std::ios::floatfield); // use decimal format
1101  oss.setf(std::ios::showpoint); // print decimal point
1102  oss << std::setprecision(gPrecision);
1103  if (mySimStepDuration != 0) {
1104  const double durationSec = (double)mySimStepDuration / 1000.;
1105  oss << " (" << mySimStepDuration << "ms ~= "
1106  << (TS / durationSec) << "*RT, ~"
1107  << ((double) myVehicleControl->getRunningVehicleNo() / durationSec);
1108  } else {
1109  oss << " (0ms ?*RT. ?";
1110  }
1111  oss << "UPS, ";
1112  if (TraCIServer::getInstance() != nullptr) {
1113  oss << "TraCI: " << myTraCIStepDuration << "ms, ";
1114  }
1115  oss << "vehicles TOT " << myVehicleControl->getDepartedVehicleNo()
1116  << " ACT " << myVehicleControl->getRunningVehicleNo()
1117  << " BUF " << myInserter->getWaitingVehicleNo()
1118  << ") ";
1119  std::string prev = "Step #" + time2string(myStep - DELTA_T);
1120  std::cout << oss.str().substr(0, 90 - prev.length());
1121  }
1122  std::cout << '\r';
1123 }
1124 
1125 
1126 void
1128  if (find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener) == myVehicleStateListeners.end()) {
1129  myVehicleStateListeners.push_back(listener);
1130  }
1131 }
1132 
1133 
1134 void
1136  std::vector<VehicleStateListener*>::iterator i = std::find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener);
1137  if (i != myVehicleStateListeners.end()) {
1138  myVehicleStateListeners.erase(i);
1139  }
1140 }
1141 
1142 
1143 void
1144 MSNet::informVehicleStateListener(const SUMOVehicle* const vehicle, VehicleState to, const std::string& info) {
1145 #ifdef HAVE_FOX
1146  ScopedLocker<> lock(myVehicleStateListenerMutex, MSGlobals::gNumThreads > 1);
1147 #endif
1148  for (VehicleStateListener* const listener : myVehicleStateListeners) {
1149  listener->vehicleStateChanged(vehicle, to, info);
1150  }
1151 }
1152 
1153 
1154 void
1157  myTransportableStateListeners.push_back(listener);
1158  }
1159 }
1160 
1161 
1162 void
1164  std::vector<TransportableStateListener*>::iterator i = std::find(myTransportableStateListeners.begin(), myTransportableStateListeners.end(), listener);
1165  if (i != myTransportableStateListeners.end()) {
1167  }
1168 }
1169 
1170 
1171 void
1172 MSNet::informTransportableStateListener(const MSTransportable* const transportable, TransportableState to, const std::string& info) {
1173 #ifdef HAVE_FOX
1174  ScopedLocker<> lock(myTransportableStateListenerMutex, MSGlobals::gNumThreads > 1);
1175 #endif
1177  listener->transportableStateChanged(transportable, to, info);
1178  }
1179 }
1180 
1181 
1182 bool
1183 MSNet::registerCollision(const SUMOTrafficObject* collider, const SUMOTrafficObject* victim, const std::string& collisionType, const MSLane* lane, double pos) {
1184  auto it = myCollisions.find(collider->getID());
1185  if (it != myCollisions.end()) {
1186  for (Collision& old : it->second) {
1187  if (old.victim == victim->getID()) {
1188  // collision from previous step continues
1189  old.colliderSpeed = collider->getSpeed();
1190  old.victimSpeed = victim->getSpeed();
1191  old.type = collisionType;
1192  old.lane = lane;
1193  old.pos = pos;
1194  old.time = myStep;
1195  return false;
1196  }
1197  }
1198  }
1199  Collision c;
1200  c.victim = victim->getID();
1201  c.colliderType = collider->getVehicleType().getID();
1202  c.victimType = victim->getVehicleType().getID();
1203  c.colliderSpeed = collider->getSpeed();
1204  c.victimSpeed = victim->getSpeed();
1205  c.type = collisionType;
1206  c.lane = lane;
1207  c.pos = pos;
1208  c.time = myStep;
1209  myCollisions[collider->getID()].push_back(c);
1210  return true;
1211 }
1212 
1213 
1214 void
1216  for (auto it = myCollisions.begin(); it != myCollisions.end();) {
1217  for (auto it2 = it->second.begin(); it2 != it->second.end();) {
1218  if (it2->time != myStep) {
1219  it2 = it->second.erase(it2);
1220  } else {
1221  it2++;
1222  }
1223  }
1224  if (it->second.size() == 0) {
1225  it = myCollisions.erase(it);
1226  } else {
1227  it++;
1228  }
1229  }
1230 }
1231 
1232 
1233 bool
1235  return myStoppingPlaces[category == SUMO_TAG_TRAIN_STOP ? SUMO_TAG_BUS_STOP : category].add(stop->getID(), stop);
1236 }
1237 
1238 
1239 bool
1241  if (find(myTractionSubstations.begin(), myTractionSubstations.end(), substation) == myTractionSubstations.end()) {
1242  myTractionSubstations.push_back(substation);
1243  return true;
1244  }
1245  return false;
1246 }
1247 
1248 
1250 MSNet::getStoppingPlace(const std::string& id, const SumoXMLTag category) const {
1251  if (myStoppingPlaces.count(category) > 0) {
1252  return myStoppingPlaces.find(category)->second.get(id);
1253  }
1254  return nullptr;
1255 }
1256 
1257 
1258 std::string
1259 MSNet::getStoppingPlaceID(const MSLane* lane, const double pos, const SumoXMLTag category) const {
1260  if (myStoppingPlaces.count(category) > 0) {
1261  for (const auto& it : myStoppingPlaces.find(category)->second) {
1262  MSStoppingPlace* stop = it.second;
1263  if (&stop->getLane() == lane && stop->getBeginLanePosition() - POSITION_EPS <= pos && stop->getEndLanePosition() + POSITION_EPS >= pos) {
1264  return stop->getID();
1265  }
1266  }
1267  }
1268  return "";
1269 }
1270 
1271 
1274  auto it = myStoppingPlaces.find(category);
1275  if (it != myStoppingPlaces.end()) {
1276  return it->second;
1277  } else {
1278  throw ProcessError("No stoppingPlace of type '" + toString(category) + "' found");
1279  }
1280 }
1281 
1282 
1283 void
1286  OutputDevice& output = OutputDevice::getDeviceByOption("chargingstations-output");
1287  for (const auto& it : myStoppingPlaces.find(SUMO_TAG_CHARGING_STATION)->second) {
1288  static_cast<MSChargingStation*>(it.second)->writeChargingStationOutput(output);
1289  }
1290  }
1291 }
1292 
1293 
1294 void
1296  OutputDevice& output = OutputDevice::getDeviceByOption("railsignal-block-output");
1297  for (auto tls : myLogics->getAllLogics()) {
1298  MSRailSignal* rs = dynamic_cast<MSRailSignal*>(tls);
1299  if (rs != nullptr) {
1300  rs->writeBlocks(output);
1301  }
1302  }
1303 }
1304 
1305 
1306 void
1309  OutputDevice& output = OutputDevice::getDeviceByOption("overheadwiresegments-output");
1310  for (const auto& it : myStoppingPlaces.find(SUMO_TAG_OVERHEAD_WIRE_SEGMENT)->second) {
1311  static_cast<MSOverheadWire*>(it.second)->writeOverheadWireSegmentOutput(output);
1312  }
1313  }
1314 }
1315 
1316 
1317 void
1319  if (myTractionSubstations.size() > 0) {
1320  OutputDevice& output = OutputDevice::getDeviceByOption("substations-output");
1321  output.setPrecision(OptionsCont::getOptions().getInt("substations-output.precision"));
1322  for (auto& it : myTractionSubstations) {
1323  it->writeTractionSubstationOutput(output);
1324  }
1325  }
1326 }
1327 
1328 
1330 MSNet::findTractionSubstation(const std::string& substationId) {
1331  for (std::vector<MSTractionSubstation*>::iterator it = myTractionSubstations.begin(); it != myTractionSubstations.end(); ++it) {
1332  if ((*it)->getID() == substationId) {
1333  return *it;
1334  }
1335  }
1336  return nullptr;
1337 }
1338 
1339 
1340 bool
1341 MSNet::existTractionSubstation(const std::string& substationId) {
1342  for (std::vector<MSTractionSubstation*>::iterator it = myTractionSubstations.begin(); it != myTractionSubstations.end(); ++it) {
1343  if ((*it)->getID() == substationId) {
1344  return true;
1345  }
1346  }
1347  return false;
1348 }
1349 
1350 
1352 MSNet::getRouterTT(const int rngIndex, const MSEdgeVector& prohibited) const {
1353  if (myRouterTT.count(rngIndex) == 0) {
1354  const std::string routingAlgorithm = OptionsCont::getOptions().getString("routing-algorithm");
1355  if (routingAlgorithm == "dijkstra") {
1356  myRouterTT[rngIndex] = new DijkstraRouter<MSEdge, SUMOVehicle>(MSEdge::getAllEdges(), true, &MSNet::getTravelTime, nullptr, false, nullptr, true);
1357  } else {
1358  if (routingAlgorithm != "astar") {
1359  WRITE_WARNING("TraCI and Triggers cannot use routing algorithm '" + routingAlgorithm + "'. using 'astar' instead.");
1360  }
1361  myRouterTT[rngIndex] = new AStarRouter<MSEdge, SUMOVehicle>(MSEdge::getAllEdges(), true, &MSNet::getTravelTime, nullptr, true);
1362  }
1363  }
1364  myRouterTT[rngIndex]->prohibit(prohibited);
1365  return *myRouterTT[rngIndex];
1366 }
1367 
1368 
1370 MSNet::getRouterEffort(const int rngIndex, const MSEdgeVector& prohibited) const {
1371  if (myRouterEffort.count(rngIndex) == 0) {
1373  }
1374  myRouterEffort[rngIndex]->prohibit(prohibited);
1375  return *myRouterEffort[rngIndex];
1376 }
1377 
1378 
1380 MSNet::getPedestrianRouter(const int rngIndex, const MSEdgeVector& prohibited) const {
1381  if (myPedestrianRouter.count(rngIndex) == 0) {
1382  myPedestrianRouter[rngIndex] = new MSPedestrianRouter();
1383  }
1384  myPedestrianRouter[rngIndex]->prohibit(prohibited);
1385  return *myPedestrianRouter[rngIndex];
1386 }
1387 
1388 
1390 MSNet::getIntermodalRouter(const int rngIndex, const int routingMode, const MSEdgeVector& prohibited) const {
1391  const OptionsCont& oc = OptionsCont::getOptions();
1392  const int key = rngIndex * oc.getInt("thread-rngs") + routingMode;
1393  if (myIntermodalRouter.count(key) == 0) {
1394  int carWalk = 0;
1395  for (const std::string& opt : oc.getStringVector("persontrip.transfer.car-walk")) {
1396  if (opt == "parkingAreas") {
1398  } else if (opt == "ptStops") {
1400  } else if (opt == "allJunctions") {
1402  }
1403  }
1404  // XXX there is currently no reason to combine multiple values, thus getValueString rather than getStringVector
1405  const std::string& taxiDropoff = oc.getValueString("persontrip.transfer.taxi-walk");
1406  const std::string& taxiPickup = oc.getValueString("persontrip.transfer.walk-taxi");
1407  if (taxiDropoff == "") {
1408  if (MSDevice_Taxi::getTaxi() != nullptr) {
1410  }
1411  } else if (taxiDropoff == "ptStops") {
1413  } else if (taxiDropoff == "allJunctions") {
1415  }
1416  if (taxiPickup == "") {
1417  if (MSDevice_Taxi::getTaxi() != nullptr) {
1419  }
1420  } else if (taxiPickup == "ptStops") {
1422  } else if (taxiPickup == "allJunctions") {
1424  }
1425  const std::string routingAlgorithm = OptionsCont::getOptions().getString("routing-algorithm");
1426  double taxiWait = STEPS2TIME(string2time(OptionsCont::getOptions().getString("persontrip.taxi.waiting-time")));
1427  if (routingMode == libsumo::ROUTING_MODE_COMBINED) {
1428  myIntermodalRouter[key] = new MSIntermodalRouter(MSNet::adaptIntermodalRouter, carWalk, taxiWait, routingAlgorithm, routingMode, new FareModul());
1429  } else {
1430  myIntermodalRouter[key] = new MSIntermodalRouter(MSNet::adaptIntermodalRouter, carWalk, taxiWait, routingAlgorithm, routingMode);
1431  }
1432  }
1433  myIntermodalRouter[key]->prohibit(prohibited);
1434  return *myIntermodalRouter[key];
1435 }
1436 
1437 
1438 void
1440  double taxiWait = STEPS2TIME(string2time(OptionsCont::getOptions().getString("persontrip.taxi.waiting-time")));
1441  // add access to all parking areas
1442  EffortCalculator* const external = router.getExternalEffort();
1443  for (const auto& stopType : myInstance->myStoppingPlaces) {
1444  // add access to all stopping places
1445  const SumoXMLTag element = stopType.first;
1446  for (const auto& i : stopType.second) {
1447  const MSEdge* const edge = &i.second->getLane().getEdge();
1448  router.getNetwork()->addAccess(i.first, edge, i.second->getBeginLanePosition(), i.second->getEndLanePosition(),
1449  i.second->getAccessDistance(edge), element, false, taxiWait);
1450  if (element == SUMO_TAG_BUS_STOP) {
1451  // add access to all public transport stops
1452  for (const auto& a : i.second->getAllAccessPos()) {
1453  router.getNetwork()->addAccess(i.first, &std::get<0>(a)->getEdge(), std::get<1>(a), std::get<1>(a), std::get<2>(a), element, true, taxiWait);
1454  }
1455  if (external != nullptr) {
1456  external->addStop(router.getNetwork()->getStopEdge(i.first)->getNumericalID(), *i.second);
1457  }
1458  }
1459  }
1460  }
1463  // add access to transfer from walking to taxi-use
1465  for (MSEdge* edge : myInstance->getEdgeControl().getEdges()) {
1466  if ((edge->getPermissions() & SVC_PEDESTRIAN) != 0 && (edge->getPermissions() & SVC_TAXI) != 0) {
1467  router.getNetwork()->addCarAccess(edge, SVC_TAXI, taxiWait);
1468  }
1469  }
1470  }
1471 }
1472 
1473 
1474 bool
1476  const MSEdgeVector& edges = myEdges->getEdges();
1477  for (MSEdgeVector::const_iterator e = edges.begin(); e != edges.end(); ++e) {
1478  for (std::vector<MSLane*>::const_iterator i = (*e)->getLanes().begin(); i != (*e)->getLanes().end(); ++i) {
1479  if ((*i)->getShape().hasElevation()) {
1480  return true;
1481  }
1482  }
1483  }
1484  return false;
1485 }
1486 
1487 
1488 bool
1490  for (const MSEdge* e : myEdges->getEdges()) {
1491  if (e->getFunction() == SumoXMLEdgeFunc::WALKINGAREA) {
1492  return true;
1493  }
1494  }
1495  return false;
1496 }
1497 
1498 
1499 bool
1501  for (const MSEdge* e : myEdges->getEdges()) {
1502  if (e->getBidiEdge() != nullptr) {
1503  return true;
1504  }
1505  }
1506  return false;
1507 }
1508 
1509 bool
1510 MSNet::warnOnce(const std::string& typeAndID) {
1511  if (myWarnedOnce.find(typeAndID) == myWarnedOnce.end()) {
1512  myWarnedOnce[typeAndID] = true;
1513  return true;
1514  }
1515  return false;
1516 }
1517 
1518 
1519 /****************************************************************************/
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:73
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:282
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
std::string elapsedMs2string(long long int t)
convert ms to string for log output
Definition: SUMOTime.cpp:110
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define TS
Definition: SUMOTime.h:40
#define SIMTIME
Definition: SUMOTime.h:60
long long int SUMOTime
Definition: SUMOTime.h:32
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_TAXI
vehicle is a taxi
@ SVC_PEDESTRIAN
pedestrian
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
@ SUMO_ATTR_MAXIMUMBATTERYCAPACITY
Maxium battery capacity.
@ SUMO_ATTR_VEHICLE
@ SUMO_ATTR_RECUPERATIONENABLE
@ SUMO_ATTR_ID
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:25
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:269
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
Computes the shortest path through a network using the A* algorithm.
Definition: AStarRouter.h:76
Computes the shortest path through a network using the Dijkstra algorithm.
the effort calculator interface
virtual void addStop(const int stopEdge, const Parameterised &params)=0
int getNumericalID() const
void addCarAccess(const E *edge, SUMOVehicleClass svc, double traveltime)
Adds access edges for transfering from walking to vehicle use.
void addAccess(const std::string &stopId, const E *stopEdge, const double startPos, const double endPos, const double length, const SumoXMLTag category, bool isAccess, double taxiWait)
Adds access edges for stopping places to the intermodal network.
_IntermodalEdge * getStopEdge(const std::string &stopId) const
Returns the associated stop edge.
@ TAXI_PICKUP_ANYWHERE
taxi customer may be picked up anywhere
@ TAXI_DROPOFF_ANYWHERE
taxi customer may exit anywhere
@ PARKING_AREAS
parking areas
@ ALL_JUNCTIONS
junctions with edges allowing the additional mode
@ TAXI_PICKUP_PT
taxi customer may be picked up at public transport stop
@ PT_STOPS
public transport stops and access
@ TAXI_DROPOFF_PT
taxi customer may be picked up at public transport stop
EffortCalculator * getExternalEffort() const
Network * getNetwork() const
int getCarWalkTransfer() const
The main mesocopic simulation loop.
Definition: MELoop.h:47
void simulate(SUMOTime tMax)
Perform simulation up to the given time.
Definition: MELoop.cpp:61
void clearState()
Remove all vehicles before quick-loading state.
Definition: MELoop.cpp:219
A single mesoscopic segment (cell)
Definition: MESegment.h:49
static void write(OutputDevice &of, const SUMOTime timestep)
Writes the complete network state into the given device.
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
static void write(OutputDevice &of, SUMOTime timestep, int precision)
Writes the complete network state of the given edges into the given device.
static void cleanup()
cleanup remaining data structures
Detectors container; responsible for string and output generation.
void writeOutput(SUMOTime step, bool closing)
Writes the output to be generated within the given time step.
void clearState()
Remove all vehicles before quick-loading state.
void updateDetectors(const SUMOTime step)
Computes detector values.
void close(SUMOTime step)
Closes the detector outputs.
static void cleanup()
removes remaining vehicleInformation in sVehicles
A device which collects info on the vehicle trip (mainly on departure and arrival)
double getMaximumBatteryCapacity() const
Get the total vehicle's Battery Capacity in kWh.
A device which collects info on the vehicle trip (mainly on departure and arrival)
Definition: MSDevice_SSM.h:55
static const std::set< MSDevice_SSM *, ComparatorNumericalIdLess > & getInstances()
returns all currently existing SSM devices
static void cleanup()
Clean up remaining devices instances.
static bool hasServableReservations()
check whether there are still (servable) reservations in the system
static SUMOVehicle * getTaxi()
returns a taxi if any exist or nullptr
The ToC Device controls transition of control between automated and manual driving.
Definition: MSDevice_ToC.h:52
static void cleanup()
Closes root tags of output files.
static const std::set< MSDevice_ToC *, ComparatorNumericalIdLess > & getInstances()
returns all currently existing ToC devices
Definition: MSDevice_ToC.h:91
static void writeStatistics(OutputDevice &od)
write statistic output to (xml) file
static std::string printStatistics()
get statistics for printing to stdout
static void generateOutputForUnfinished()
generate output for vehicles which are still in the network
static void generateOutputForUnfinished()
generate vehroute output for vehicles which are still in the network
static void cleanupAll()
perform cleanup for all devices
Definition: MSDevice.cpp:129
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:81
void patchActiveLanes()
Resets information whether a lane is active for all lanes.
void detectCollisions(SUMOTime timestep, const std::string &stage)
Detect collisions.
const MSEdgeVector & getEdges() const
Returns loaded edges.
void setJunctionApproaches(SUMOTime t)
Register junction approaches for all vehicles after velocities have been planned. This is a prerequis...
void executeMovements(SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
void planMovements(SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step....
void changeLanes(const SUMOTime t)
Moves (precomputes) critical vehicles.
A road/street connecting two junctions.
Definition: MSEdge.h:77
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:918
static void clear()
Clears the dictionary.
Definition: MSEdge.cpp:924
static int dictSize()
Returns the number of edges.
Definition: MSEdge.cpp:912
double getMinimumTravelTime(const SUMOVehicle *const veh) const
returns the minimum travel time for the given vehicle
Definition: MSEdge.h:459
A storage for edge travel times and efforts.
bool retrieveExistingTravelTime(const MSEdge *const e, const double t, double &value) const
Returns a travel time for an edge and time if stored.
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
static void writeAggregated(OutputDevice &of, SUMOTime timestep, int precision)
static void write(OutputDevice &of, const SUMOVehicle *veh, SUMOTime timestep, int precision)
Writes the complete network state of the given edges into the given device.
static void write(OutputDevice &of, SUMOTime timestep, int precision)
Writes the complete network state of the given edges into the given device.
Stores time-dependant events and executes them at the proper time.
virtual void execute(SUMOTime time)
Executes time-dependant commands.
void clearState(SUMOTime currentTime, SUMOTime newTime)
Remove all events before quick-loading state.
static void write(OutputDevice &of, SUMOTime timestep, bool elevation)
Writes the position and the angle of each vehicle into the given device.
Definition: MSFCDExport.cpp:49
static void write(OutputDevice &of, SUMOTime timestep)
Dumping a hugh List of Parameters available in the Simulation.
static bool gUseMesoSim
Definition: MSGlobals.h:94
static double gWeightsSeparateTurns
Whether turning specific weights are estimated (and how much)
Definition: MSGlobals.h:160
static bool gOverheadWireRecuperation
Definition: MSGlobals.h:112
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:100
static bool gCheck4Accidents
Definition: MSGlobals.h:79
static bool gClearState
whether the simulation is in the process of clearing state (MSNet::clearState)
Definition: MSGlobals.h:130
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:72
static int gNumThreads
how many threads to use
Definition: MSGlobals.h:136
Inserts vehicles into the network when their departure time is reached.
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
int emitVehicles(SUMOTime time)
Emits vehicles that want to depart at the given time.
void determineCandidates(SUMOTime time)
Checks for all vehicles whether they can be emitted.
int getPendingFlowCount() const
Returns the number of flows that are still active.
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
void clearState()
Remove all vehicles before quick-loading state.
Container for junctions; performs operations on all stored junctions.
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:2014
Interface for objects listening to transportable state changes.
Definition: MSNet.h:686
Interface for objects listening to vehicle state changes.
Definition: MSNet.h:627
The simulated network and simulation perfomer.
Definition: MSNet.h:88
std::map< SumoXMLTag, NamedObjectCont< MSStoppingPlace * > > myStoppingPlaces
Dictionary of bus / container stops.
Definition: MSNet.h:963
long myTraCIMillis
The overall time spent waiting for traci operations including.
Definition: MSNet.h:902
static double getEffort(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the effort to pass an edge.
Definition: MSNet.cpp:143
bool warnOnce(const std::string &typeAndID)
return whether a warning regarding the given object shall be issued
Definition: MSNet.cpp:1510
std::map< int, SUMOAbstractRouter< MSEdge, SUMOVehicle > * > myRouterEffort
Definition: MSNet.h:994
MSIntermodalRouter & getIntermodalRouter(const int rngIndex, const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1390
bool myLogExecutionTime
Information whether the simulation duration shall be logged.
Definition: MSNet.h:888
MSTransportableControl * myPersonControl
Controls person building and deletion;.
Definition: MSNet.h:857
void removeVehicleStateListener(VehicleStateListener *listener)
Removes a vehicle states listener.
Definition: MSNet.cpp:1135
SUMORouteLoaderControl * myRouteLoaders
Route loader for dynamic loading of routes.
Definition: MSNet.h:838
bool addStoppingPlace(const SumoXMLTag category, MSStoppingPlace *stop)
Adds a stopping place.
Definition: MSNet.cpp:1234
void informTransportableStateListener(const MSTransportable *const transportable, TransportableState to, const std::string &info="")
Informs all added listeners about a transportable's state change.
Definition: MSNet.cpp:1172
SUMOTime myStateDumpPeriod
The period for writing state.
Definition: MSNet.h:921
const std::string generateStatistics(SUMOTime start)
Writes performance output and running vehicle stats.
Definition: MSNet.cpp:423
void writeOverheadWireSegmentOutput() const
write the output generated by an overhead wire segment
Definition: MSNet.cpp:1307
void writeChargingStationOutput() const
write charging station output
Definition: MSNet.cpp:1284
std::pair< bool, NamedRTree > myLanesRTree
An RTree structure holding lane IDs.
Definition: MSNet.h:999
bool checkBidiEdges()
check wether bidirectional edges occur in the network
Definition: MSNet.cpp:1500
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:594
int myLogStepPeriod
Period between successive step-log outputs.
Definition: MSNet.h:893
SUMOTime myStep
Current time step.
Definition: MSNet.h:841
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
bool myHasBidiEdges
Whether the network contains bidirectional rail edges.
Definition: MSNet.h:951
MSEventControl * myBeginOfTimestepEvents
Controls events executed at the begin of a time step;.
Definition: MSNet.h:871
bool addTractionSubstation(MSTractionSubstation *substation)
Adds a traction substation.
Definition: MSNet.cpp:1240
std::map< std::string, bool > myWarnedOnce
container to record warnings that shall only be issued once
Definition: MSNet.h:986
static void initStatic()
Place for static initializations of simulation components (called after successful net build)
Definition: MSNet.cpp:182
void removeOutdatedCollisions()
remove collisions from the previous simulation step
Definition: MSNet.cpp:1215
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
Definition: MSNet.h:863
std::vector< std::string > myPeriodicStateFiles
The names of the last K periodic state files (only only K shall be kept)
Definition: MSNet.h:919
ShapeContainer * myShapeContainer
A container for geometrical shapes;.
Definition: MSNet.h:877
double myVersion
the network version
Definition: MSNet.h:957
std::string myStateDumpSuffix
Definition: MSNet.h:924
bool checkElevation()
check all lanes for elevation data
Definition: MSNet.cpp:1475
bool existTractionSubstation(const std::string &substationId)
return whether given electrical substation exists in the network
Definition: MSNet.cpp:1341
void removeTransportableStateListener(TransportableStateListener *listener)
Removes a transportable states listener.
Definition: MSNet.cpp:1163
bool myLogStepNumber
Information whether the number of the simulation step shall be logged.
Definition: MSNet.h:891
MSEventControl * myInsertionEvents
Controls insertion events;.
Definition: MSNet.h:875
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:1068
void closeBuilding(const OptionsCont &oc, MSEdgeControl *edges, MSJunctionControl *junctions, SUMORouteLoaderControl *routeLoaders, MSTLLogicControl *tlc, std::vector< SUMOTime > stateDumpTimes, std::vector< std::string > stateDumpFiles, bool hasInternalLinks, bool junctionHigherSpeeds, double version)
Closes the network's building process.
Definition: MSNet.cpp:247
SimulationState
Possible states of a simulation - running or stopped with different reasons.
Definition: MSNet.h:93
@ SIMSTATE_TOO_MANY_TELEPORTS
The simulation had too many teleports.
Definition: MSNet.h:109
@ SIMSTATE_NO_FURTHER_VEHICLES
The simulation does not contain further vehicles.
Definition: MSNet.h:101
@ SIMSTATE_LOADING
The simulation is loading.
Definition: MSNet.h:95
@ SIMSTATE_ERROR_IN_SIM
An error occurred during the simulation step.
Definition: MSNet.h:105
@ SIMSTATE_CONNECTION_CLOSED
The connection to a client was closed by the client.
Definition: MSNet.h:103
@ SIMSTATE_INTERRUPTED
An external interrupt occured.
Definition: MSNet.h:107
@ SIMSTATE_RUNNING
The simulation is running.
Definition: MSNet.h:97
@ SIMSTATE_END_STEP_REACHED
The final simulation step has been performed.
Definition: MSNet.h:99
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1352
std::map< int, MSPedestrianRouter * > myPedestrianRouter
Definition: MSNet.h:995
static const std::string STAGE_MOVEMENTS
Definition: MSNet.h:816
int myMaxTeleports
Maximum number of teleports.
Definition: MSNet.h:844
long mySimStepDuration
Definition: MSNet.h:896
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:376
PedestrianRouter< MSEdge, MSLane, MSJunction, MSVehicle > MSPedestrianRouter
Definition: MSNet.h:112
MSEventControl * myEndOfTimestepEvents
Controls events executed at the end of a time step;.
Definition: MSNet.h:873
static std::string getStateMessage(SimulationState state)
Returns the message to show if a certain state occurs.
Definition: MSNet.cpp:774
std::string getStoppingPlaceID(const MSLane *lane, const double pos, const SumoXMLTag category) const
Returns the stop of the given category close to the given position.
Definition: MSNet.cpp:1259
bool myHasInternalLinks
Whether the network contains internal links/lanes/edges.
Definition: MSNet.h:939
SimulationState adaptToState(const SimulationState state) const
Called after a simulation step, this method adapts the current simulation state if necessary.
Definition: MSNet.cpp:753
void writeSubstationOutput() const
write electrical substation output
Definition: MSNet.cpp:1318
static const std::string STAGE_INSERTIONS
Definition: MSNet.h:818
long long int myPersonsMoved
Definition: MSNet.h:906
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
Definition: MSNet.h:855
static void clearAll()
Clears all dictionaries.
Definition: MSNet.cpp:799
static void cleanupStatic()
Place for static initializations of simulation components (called after successful net build)
Definition: MSNet.cpp:189
IntermodalRouter< MSEdge, MSLane, MSJunction, SUMOVehicle > MSIntermodalRouter
Definition: MSNet.h:113
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:318
MSEdgeControl * myEdges
Controls edges, performs vehicle movement;.
Definition: MSNet.h:861
std::unique_ptr< MSDynamicShapeUpdater > myDynamicShapeUpdater
Updater for dynamic shapes that are tracking traffic objects (ensures removal of shape dynamics when ...
Definition: MSNet.h:1004
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: MSNet.cpp:340
void closeSimulation(SUMOTime start, const std::string &reason="")
Closes the simulation (all files, connections, etc.)
Definition: MSNet.cpp:545
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:1250
void simulationStep()
Performs a single simulation step.
Definition: MSNet.cpp:583
bool myHasElevation
Whether the network contains elevation data.
Definition: MSNet.h:945
static double getTravelTime(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the travel time to pass an edge.
Definition: MSNet.cpp:157
MSTransportableControl * myContainerControl
Controls container building and deletion;.
Definition: MSNet.h:859
std::vector< TransportableStateListener * > myTransportableStateListeners
Container for transportable state listener.
Definition: MSNet.h:972
void writeOutput()
Write netstate, summary and detector output.
Definition: MSNet.cpp:872
bool myAmInterrupted
whether an interrupt occured
Definition: MSNet.h:847
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition: MSNet.cpp:1127
void preSimStepOutput() const
Prints the current step number.
Definition: MSNet.cpp:1091
void writeCollisions() const
write collision output to (xml) file
Definition: MSNet.cpp:493
MSEdgeControl & getEdgeControl()
Returns the edge control.
Definition: MSNet.h:419
std::vector< SUMOTime > myStateDumpTimes
Times at which a state shall be written.
Definition: MSNet.h:915
void addTransportableStateListener(TransportableStateListener *listener)
Adds a transportable states listener.
Definition: MSNet.cpp:1155
std::vector< MSTractionSubstation * > myTractionSubstations
Dictionary of traction substations.
Definition: MSNet.h:966
SUMOTime myEdgeDataEndTime
end of loaded edgeData
Definition: MSNet.h:960
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net's internal edge travel times/efforts container.
Definition: MSNet.cpp:1082
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
Definition: MSNet.h:933
std::vector< std::string > myStateDumpFiles
The names for the state files.
Definition: MSNet.h:917
void addMesoType(const std::string &typeID, const MESegment::MesoEdgeType &edgeType)
Adds edge type specific meso parameters.
Definition: MSNet.cpp:349
void writeRailSignalBlocks() const
write rail signal block output
Definition: MSNet.cpp:1295
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:429
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
Definition: MSNet.h:865
bool logSimulationDuration() const
Returns whether duration shall be logged.
Definition: MSNet.cpp:1053
long long int myVehiclesMoved
The overall number of vehicle movements.
Definition: MSNet.h:905
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
Definition: MSNet.cpp:1144
std::vector< VehicleStateListener * > myVehicleStateListeners
Container for vehicle state listener.
Definition: MSNet.h:969
SimulationState simulationState(SUMOTime stopTime) const
This method returns the current simulation state. It should not modify status.
Definition: MSNet.cpp:723
long myTraCIStepDuration
The last simulation step duration.
Definition: MSNet.h:896
TransportableState
Definition of a transportable state.
Definition: MSNet.h:671
MSDetectorControl * myDetectorControl
Controls detectors;.
Definition: MSNet.h:869
static const std::string STAGE_LANECHANGE
Definition: MSNet.h:817
MSNet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents, ShapeContainer *shapeCont=0)
Constructor.
Definition: MSNet.cpp:196
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
Definition: MSNet.cpp:334
std::map< int, SUMOAbstractRouter< MSEdge, SUMOVehicle > * > myRouterTT
Definition: MSNet.h:993
std::map< std::string, MESegment::MesoEdgeType > myMesoEdgeTypes
The edge type specific meso parameters.
Definition: MSNet.h:936
static void adaptIntermodalRouter(MSIntermodalRouter &router)
Definition: MSNet.cpp:1439
MSEdgeWeightsStorage * myEdgeWeights
The net's knowledge about edge efforts/travel times;.
Definition: MSNet.h:879
MSDynamicShapeUpdater * makeDynamicShapeUpdater()
Creates and returns a dynamic shapes updater.
Definition: MSNet.cpp:1076
std::map< int, MSIntermodalRouter * > myIntermodalRouter
Definition: MSNet.h:996
virtual ~MSNet()
Destructor.
Definition: MSNet.cpp:282
MSPedestrianRouter & getPedestrianRouter(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1380
MSTractionSubstation * findTractionSubstation(const std::string &substationId)
find electrical substation by its id
Definition: MSNet.cpp:1330
static MSNet * myInstance
Unique instance of MSNet.
Definition: MSNet.h:835
MSInsertionControl * myInserter
Controls vehicle insertion;.
Definition: MSNet.h:867
void postSimStepOutput() const
Prints the statistics of the step at its end.
Definition: MSNet.cpp:1097
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:1059
bool registerCollision(const SUMOTrafficObject *collider, const SUMOTrafficObject *victim, const std::string &collisionType, const MSLane *lane, double pos)
register collision and return whether it was the first one involving these vehicles
Definition: MSNet.cpp:1183
static const std::string STAGE_EVENTS
string constants for simstep stages
Definition: MSNet.h:815
void loadRoutes()
loads routes for the next few steps
Definition: MSNet.cpp:417
std::string myStateDumpPrefix
name components for periodic state
Definition: MSNet.h:923
void clearState(const SUMOTime step)
Resets events when quick-loading state.
Definition: MSNet.cpp:824
bool myJunctionHigherSpeeds
Whether the network was built with higher speed on junctions.
Definition: MSNet.h:942
long mySimBeginMillis
The overall simulation duration.
Definition: MSNet.h:899
bool myHasPedestrianNetwork
Whether the network contains pedestrian network elements.
Definition: MSNet.h:948
const MESegment::MesoEdgeType & getMesoType(const std::string &typeID)
Returns edge type specific meso parameters if no type specific parameters have been loaded,...
Definition: MSNet.cpp:354
void writeStatistics() const
write statistic output to (xml) file
Definition: MSNet.cpp:515
bool hasInternalLinks() const
return whether the network contains internal links
Definition: MSNet.h:768
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterEffort(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1370
bool checkWalkingarea()
check all lanes for type walkingArea
Definition: MSNet.cpp:1489
CollisionMap myCollisions
collisions in the current time step
Definition: MSNet.h:975
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition: MSNet.cpp:1273
SimulationState simulate(SUMOTime start, SUMOTime stop)
Simulates from timestep start to stop.
Definition: MSNet.cpp:375
Definition of overhead wire segment.
static void write(OutputDevice &of, SUMOTime timestep)
Export the queueing length in front of a junction (very experimental!)
static void cleanup()
clean up state
A signal for rails.
Definition: MSRailSignal.h:46
void writeBlocks(OutputDevice &od) const
write rail signal block output for all links and driveways
static void recheckGreen()
final check for driveway compatibility of signals that switched green in this step
static void dict_clearState()
Decrement all route references before quick-loading state.
Definition: MSRoute.cpp:278
static void clear()
Clears the dictionary (delete all known routes, too)
Definition: MSRoute.cpp:178
static void saveState(const std::string &file, SUMOTime step)
Saves the current state.
static MSStopOut * getInstance()
Definition: MSStopOut.h:60
static bool active()
Definition: MSStopOut.h:54
static void cleanup()
Definition: MSStopOut.cpp:50
void generateOutputForUnfinished()
generate output for vehicles which are still stopped at simulation end
Definition: MSStopOut.cpp:169
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
A class that stores and controls tls and switching of their programs.
std::vector< MSTrafficLightLogic * > getAllLogics() const
Returns a vector which contains all logics.
void clearState()
Clear all tls states before quick-loading state.
void check2Switch(SUMOTime step)
Checks whether any WAUT is trying to switch a tls into another program.
Traction substaction powering one or more overhead wire sections.
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
bool hasTransportables() const
checks whether any transportable waits to finish her plan
int getWaitingForVehicleNumber() const
Returns the number of transportables waiting for a ride.
int getEndedNumber() const
Returns the number of transportables that exited the simulation.
void checkWaiting(MSNet *net, const SUMOTime time)
checks whether any transportables waiting time is over
int getArrivedNumber() const
Returns the number of transportables that arrived at their destination.
int getLoadedNumber() const
Returns the number of build transportables.
int getWaitingUntilNumber() const
Returns the number of transportables waiting for a specified amount of time.
void abortAnyWaitingForVehicle()
aborts the plan for any transportable that is still waiting for a ride
bool hasNonWaiting() const
checks whether any transportable is still engaged in walking / stopping
int getMovingNumber() const
Returns the number of transportables moving by themselvs (i.e. walking)
int getJammedNumber() const
Returns the number of times a transportables was jammed.
void clearState()
Resets transportables when quick-loading state.
int getRidingNumber() const
Returns the number of transportables riding a vehicle.
static void cleanup()
properly deletes all trigger instances
Definition: MSTrigger.cpp:44
static void write(OutputDevice &of, SUMOTime timestep)
Produce a VTK output to use with Tools like ParaView.
Definition: MSVTKExport.cpp:41
static void init()
Static initalization.
Definition: MSVehicle.cpp:382
static void cleanup()
Static cleanup.
Definition: MSVehicle.cpp:387
The class responsible for building and deletion of vehicles.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
int getRunningVehicleNo() const
Returns the number of build and inserted, but not yet deleted vehicles.
void removePending()
Removes a vehicle after it has ended.
double getTotalTravelTime() const
Returns the total travel time.
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
int getLoadedVehicleNo() const
Returns the number of build vehicles.
int getCollisionCount() const
return the number of collisions
int getTeleportsWrongLane() const
return the number of teleports due to vehicles stuck on the wrong lane
int getStoppedVehiclesCount() const
return the number of vehicles that are currently stopped
int getTeleportsYield() const
return the number of teleports due to vehicles stuck on a minor road
void clearState(const bool reinit)
Remove all vehicles before quick-loading state.
int getEmergencyStops() const
return the number of emergency stops
double getTotalDepartureDelay() const
Returns the total departure delay.
virtual std::pair< double, double > getVehicleMeanSpeeds() const
get current absolute and relative mean vehicle speed in the network
int getDepartedVehicleNo() const
Returns the number of inserted vehicles.
int getArrivedVehicleNo() const
Returns the number of arrived vehicles.
int getActiveVehicleCount() const
Returns the number of build vehicles that have not been removed or need to wait for a passenger or a ...
int getTeleportsJam() const
return the number of teleports due to jamming
int getEndedVehicleNo() const
Returns the number of removed vehicles.
virtual int getHaltingVehicleNo() const
Returns the number of halting vehicles.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
int getTeleportCount() const
return the number of teleports (including collisions)
void abortWaiting()
informes about all waiting vehicles (deletion in destructor)
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:75
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
void checkInsertions(SUMOTime time)
Checks "movement" of stored vehicles.
void clearState()
Remove all vehicles before quick-loading state.
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:90
static void write(OutputDevice &of, const MSEdgeControl &ec, SUMOTime timestep, int precision)
Writes the complete network state of the given edges into the given device.
Definition: MSXMLRawOut.cpp:47
const std::string & getID() const
Returns the id.
Definition: Named.h:74
A map of named object pointers.
A storage for options typed value containers)
Definition: OptionsCont.h:89
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
std::string getValueString(const std::string &name) const
Returns the string-value of the named option (all options)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
Definition: OptionsIO.cpp:58
An output device that encapsulates an ofstream.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:248
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setPrecision(int precision=gPrecision)
Sets the precision or resets it to default.
static void closeAll(bool keepErrorRetrievers=false)
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >(), bool includeConfig=true)
Writes an XML header with optional configuration.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
void loadNext(SUMOTime step)
loads the next routes up to and including the given time step
Representation of a vehicle, person, or container.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
virtual MSVehicleDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
A scoped lock which only triggers on condition.
Definition: ScopedLocker.h:40
Storage for geometrical objects.
void clearState()
Remove all dynamics before quick-loading state.
static long getCurrentMillis()
Returns the current time in milliseconds.
Definition: SysUtils.cpp:39
TraCI server used to control sumo by a remote TraCI client.
Definition: TraCIServer.h:59
static bool wasClosed()
check whether close was requested
SUMOTime getTargetTime() const
Definition: TraCIServer.h:64
std::vector< std::string > & getLoadArgs()
Definition: TraCIServer.h:258
void cleanup()
clean up subscriptions
void processCommandsUntilSimStep(SUMOTime step)
process all commands until the next SUMO simulation step. It is guaranteed that t->getTargetTime() >=...
static TraCIServer * getInstance()
Definition: TraCIServer.h:68
static void postProcessRemoteControl()
Definition: Helper.cpp:1348
static void cleanup()
Definition: Helper.cpp:674
TRACI_CONST int ROUTING_MODE_COMBINED
edge type specific meso parameters
Definition: MESegment.h:55
collision tracking
Definition: MSNet.h:116
double victimSpeed
Definition: MSNet.h:121
const MSLane * lane
Definition: MSNet.h:123
std::string victimType
Definition: MSNet.h:119
double pos
Definition: MSNet.h:124
std::string type
Definition: MSNet.h:122
std::string colliderType
Definition: MSNet.h:118
std::string victim
Definition: MSNet.h:117
double colliderSpeed
Definition: MSNet.h:120
SUMOTime time
Definition: MSNet.h:125