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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
23 // The simulated network and simulation perfomer
24 /****************************************************************************/
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #include <config.h>
31 
32 #include <string>
33 #include <iostream>
34 #include <sstream>
35 #include <typeinfo>
36 #include <algorithm>
37 #include <cassert>
38 #include <vector>
39 #include <ctime>
40 
41 #include "trigger/MSTrigger.h"
42 #include "trigger/MSCalibrator.h"
44 #include "MSVehicleControl.h"
46 #include <utils/common/ToString.h>
47 #include <utils/common/SysUtils.h>
62 #include <utils/xml/XMLSubSys.h>
64 #include <libsumo/Simulation.h>
65 #include <mesosim/MELoop.h>
87 
88 #include "MSTransportableControl.h"
89 #include "MSEdgeControl.h"
90 #include "MSJunctionControl.h"
91 #include "MSInsertionControl.h"
92 #include "MSEventControl.h"
93 #include "MSEdge.h"
94 #include "MSJunction.h"
95 #include "MSJunctionLogic.h"
96 #include "MSLane.h"
97 #include "MSVehicleTransfer.h"
98 #include "MSRoute.h"
99 #include "MSGlobals.h"
100 #include "MSContainer.h"
101 #include "MSEdgeWeightsStorage.h"
102 #include "MSStateHandler.h"
103 #include "MSFrame.h"
104 #include "MSParkingArea.h"
105 #include "MSStoppingPlace.h"
106 #include "MSNet.h"
107 
108 
109 // ===========================================================================
110 // debug constants
111 // ===========================================================================
112 //#define DEBUG_SIMSTEP
113 
114 
115 // ===========================================================================
116 // static member definitions
117 // ===========================================================================
118 MSNet* MSNet::myInstance = nullptr;
119 
120 const std::string MSNet::STAGE_EVENTS("events");
121 const std::string MSNet::STAGE_MOVEMENTS("move");
122 const std::string MSNet::STAGE_LANECHANGE("laneChange");
123 const std::string MSNet::STAGE_INSERTIONS("insertion");
124 
125 // ===========================================================================
126 // static member method definitions
127 // ===========================================================================
128 double
129 MSNet::getEffort(const MSEdge* const e, const SUMOVehicle* const v, double t) {
130  double value;
131  const MSVehicle* const veh = dynamic_cast<const MSVehicle* const>(v);
132  if (veh != 0 && veh->getWeightsStorage().retrieveExistingEffort(e, t, value)) {
133  return value;
134  }
135  if (getInstance()->getWeightsStorage().retrieveExistingEffort(e, t, value)) {
136  return value;
137  }
138  return 0;
139 }
140 
141 
142 double
143 MSNet::getTravelTime(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 != 0 && veh->getWeightsStorage().retrieveExistingTravelTime(e, t, value)) {
147  return value;
148  }
150  return value;
151  }
152  return e->getMinimumTravelTime(v);
153 }
154 
155 
156 // ---------------------------------------------------------------------------
157 // MSNet - methods
158 // ---------------------------------------------------------------------------
159 MSNet*
161  if (myInstance != nullptr) {
162  return myInstance;
163  }
164  throw ProcessError("A network was not yet constructed.");
165 }
166 
167 
168 MSNet::MSNet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
169  MSEventControl* endOfTimestepEvents,
170  MSEventControl* insertionEvents,
171  ShapeContainer* shapeCont):
172  myVehiclesMoved(0),
173  myHavePermissions(false),
174  myHasInternalLinks(false),
175  myHasElevation(false),
176  myRouterTT(0),
177  myRouterEffort(0),
178  myPedestrianRouter(0) {
179  if (myInstance != 0) {
180  throw ProcessError("A network was already constructed.");
181  }
183  myStep = string2time(oc.getString("begin"));
184  myMaxTeleports = oc.getInt("max-num-teleports");
185  myLogExecutionTime = !oc.getBool("no-duration-log");
186  myLogStepNumber = !oc.getBool("no-step-log");
187  myInserter = new MSInsertionControl(*vc, string2time(oc.getString("max-depart-delay")), oc.getBool("eager-insert"), oc.getInt("max-num-vehicles"),
188  string2time(oc.getString("random-depart-offset")));
189  myVehicleControl = vc;
191  myEdges = 0;
192  myJunctions = 0;
193  myRouteLoaders = 0;
194  myLogics = 0;
195  myPersonControl = 0;
196  myContainerControl = 0;
197  myEdgeWeights = 0;
198  myShapeContainer = shapeCont == 0 ? new ShapeContainer() : shapeCont;
199 
200  myBeginOfTimestepEvents = beginOfTimestepEvents;
201  myEndOfTimestepEvents = endOfTimestepEvents;
202  myInsertionEvents = insertionEvents;
203  myLanesRTree.first = false;
204 
206  MSGlobals::gMesoNet = new MELoop(string2time(oc.getString("meso-recheck")));
207  }
208  myInstance = this;
209 }
210 
211 
212 void
214  SUMORouteLoaderControl* routeLoaders,
215  MSTLLogicControl* tlc,
216  std::vector<SUMOTime> stateDumpTimes,
217  std::vector<std::string> stateDumpFiles,
218  bool hasInternalLinks,
219  bool hasNeighs,
220  bool lefthand,
221  double version) {
222  myEdges = edges;
223  myJunctions = junctions;
224  myRouteLoaders = routeLoaders;
225  myLogics = tlc;
226  // save the time the network state shall be saved at
227  myStateDumpTimes = stateDumpTimes;
228  myStateDumpFiles = stateDumpFiles;
229  myStateDumpPeriod = string2time(oc.getString("save-state.period"));
230  myStateDumpPrefix = oc.getString("save-state.prefix");
231  myStateDumpSuffix = oc.getString("save-state.suffix");
232 
233  // set requests/responses
235 
236  // initialise performance computation
237  if (myLogExecutionTime) {
239  }
241  if (hasNeighs && MSGlobals::gLateralResolution > 0) {
242  WRITE_WARNING("Opposite direction driving does not work together with the sublane model.");
243  }
246  myVersion = version;
247 }
248 
249 
251  // delete controls
252  delete myJunctions;
253  delete myDetectorControl;
254  // delete mean data
255  delete myEdges;
256  delete myInserter;
257  delete myLogics;
258  delete myRouteLoaders;
259  if (myPersonControl != nullptr) {
260  delete myPersonControl;
261  }
262  if (myContainerControl != nullptr) {
263  delete myContainerControl;
264  }
265  delete myVehicleControl; // must happen after deleting transportables
266  // delete events late so that vehicles can get rid of references first
268  myBeginOfTimestepEvents = nullptr;
269  delete myEndOfTimestepEvents;
270  myEndOfTimestepEvents = nullptr;
271  delete myInsertionEvents;
272  myInsertionEvents = nullptr;
273  delete myShapeContainer;
274  delete myEdgeWeights;
275  delete myRouterTT;
276  delete myRouterEffort;
277  delete myPedestrianRouter;
278  for (auto& router : myIntermodalRouter) {
279  delete router.second;
280  }
281  myIntermodalRouter.clear();
282  myLanesRTree.second.RemoveAll();
283  clearAll();
285  delete MSGlobals::gMesoNet;
286  }
287  myInstance = nullptr;
288 }
289 
290 
291 void
292 MSNet::addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
293  myRestrictions[id][svc] = speed;
294 }
295 
296 
297 const std::map<SUMOVehicleClass, double>*
298 MSNet::getRestrictions(const std::string& id) const {
299  std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i = myRestrictions.find(id);
300  if (i == myRestrictions.end()) {
301  return 0;
302  }
303  return &i->second;
304 }
305 
306 
309  // report the begin when wished
310  WRITE_MESSAGE("Simulation started with time: " + time2string(start));
311  // the simulation loop
313  // state loading may have changed the start time so we need to reinit it
314  myStep = start;
315 #ifdef HAVE_PYTHON
316  if (OptionsCont::getOptions().isSet("python-script")) {
317  TraCIServer::runEmbedded(OptionsCont::getOptions().getString("python-script"));
318  closeSimulation(start);
319  WRITE_MESSAGE("Simulation ended at time: " + time2string(getCurrentTimeStep()));
320  WRITE_MESSAGE("Reason: Script ended");
321  return state;
322  }
323 #endif
324  while (state == SIMSTATE_RUNNING) {
325  if (myLogStepNumber) {
327  }
328  simulationStep();
329  if (myLogStepNumber) {
331  }
332  state = simulationState(stop);
333 #ifdef DEBUG_SIMSTEP
334  std::cout << SIMTIME << " MSNet::simulate(" << start << ", " << stop << ")"
335  << "\n simulation state: " << getStateMessage(state)
336  << std::endl;
337 #endif
338  if (state == SIMSTATE_LOADING) {
341  } else if (state != SIMSTATE_RUNNING) {
343  // overrides SIMSTATE_END_STEP_REACHED, e.g. (TraCI ignore SUMO's --end option)
344  state = SIMSTATE_RUNNING;
345  }
346  }
347  }
348  // report the end when wished
349  WRITE_MESSAGE("Simulation ended at time: " + time2string(getCurrentTimeStep()));
350  WRITE_MESSAGE("Reason: " + getStateMessage(state));
351  // exit simulation loop
352  closeSimulation(start);
353  return state;
354 }
355 
356 void
359 }
360 
361 
362 void
365  if (OptionsCont::getOptions().getBool("vehroute-output.write-unfinished")) {
367  }
368  if (OptionsCont::getOptions().getBool("tripinfo-output.write-unfinished")) {
370  }
371  if (OptionsCont::getOptions().isSet("chargingstations-output")) {
373  }
374  if (myLogExecutionTime) {
375  long duration = SysUtils::getCurrentMillis() - mySimBeginMillis;
376  std::ostringstream msg;
377  // print performance notice
378  msg << "Performance: " << "\n" << " Duration: " << duration << "ms" << "\n";
379  if (duration != 0) {
380  msg << " Real time factor: " << (STEPS2TIME(myStep - start) * 1000. / (double)duration) << "\n";
381  msg.setf(std::ios::fixed , std::ios::floatfield); // use decimal format
382  msg.setf(std::ios::showpoint); // print decimal point
383  msg << " UPS: " << ((double)myVehiclesMoved / ((double)duration / 1000)) << "\n";
384  }
385  // print vehicle statistics
386  const std::string discardNotice = ((myVehicleControl->getLoadedVehicleNo() != myVehicleControl->getDepartedVehicleNo()) ?
387  " (Loaded: " + toString(myVehicleControl->getLoadedVehicleNo()) + ")" : "");
388  msg << "Vehicles: " << "\n"
389  << " Inserted: " << myVehicleControl->getDepartedVehicleNo() << discardNotice << "\n"
390  << " Running: " << myVehicleControl->getRunningVehicleNo() << "\n"
391  << " Waiting: " << myInserter->getWaitingVehicleNo() << "\n";
392 
394  // print optional teleport statistics
395  std::vector<std::string> reasons;
396  if (myVehicleControl->getCollisionCount() > 0) {
397  reasons.push_back("Collisions: " + toString(myVehicleControl->getCollisionCount()));
398  }
399  if (myVehicleControl->getTeleportsJam() > 0) {
400  reasons.push_back("Jam: " + toString(myVehicleControl->getTeleportsJam()));
401  }
402  if (myVehicleControl->getTeleportsYield() > 0) {
403  reasons.push_back("Yield: " + toString(myVehicleControl->getTeleportsYield()));
404  }
406  reasons.push_back("Wrong Lane: " + toString(myVehicleControl->getTeleportsWrongLane()));
407  }
408  msg << "Teleports: " << myVehicleControl->getTeleportCount() << " (" << joinToString(reasons, ", ") << ")\n";
409  }
410  if (myVehicleControl->getEmergencyStops() > 0) {
411  msg << "Emergency Stops: " << myVehicleControl->getEmergencyStops() << "\n";
412  }
413  if (myPersonControl != 0 && myPersonControl->getLoadedNumber() > 0) {
414  msg << "Persons: " << "\n"
415  << " Inserted: " << myPersonControl->getLoadedNumber() << "\n"
416  << " Running: " << myPersonControl->getRunningNumber() << "\n";
417  if (myPersonControl->getJammedNumber() > 0) {
418  msg << " Jammed: " << myPersonControl->getJammedNumber() << "\n";
419  }
420  }
421  if (OptionsCont::getOptions().getBool("duration-log.statistics")) {
423  }
424  WRITE_MESSAGE(msg.str());
425  }
426 }
427 
428 
429 void
431 #ifdef DEBUG_SIMSTEP
432  std::cout << SIMTIME << ": MSNet::simulationStep() called"
433  << ", myStep = " << myStep
434  << std::endl;
435 #endif
436  if (myLogExecutionTime) {
438  }
440  if (t != 0 && !t->isEmbedded()) {
442 #ifdef DEBUG_SIMSTEP
443  bool loadRequested = !TraCI::getLoadArgs().empty();
444  bool closed = TraCIServer::wasClosed();
445  assert(t->getTargetTime() >= myStep || loadRequested || closed);
446 #endif
447  }
448  if (myLogExecutionTime) {
450  }
451 #ifdef DEBUG_SIMSTEP
452  std::cout << SIMTIME << ": TraCI target time: " << t->getTargetTime() << std::endl;
453 #endif
454  // execute beginOfTimestepEvents
455  if (myLogExecutionTime) {
457  }
458  // simulation state output
459  std::vector<SUMOTime>::iterator timeIt = find(myStateDumpTimes.begin(), myStateDumpTimes.end(), myStep);
460  if (timeIt != myStateDumpTimes.end()) {
461  const int dist = (int)distance(myStateDumpTimes.begin(), timeIt);
463  }
464  if (myStateDumpPeriod > 0 && myStep % myStateDumpPeriod == 0) {
466  }
468 #ifdef HAVE_FOX
469  MSDevice_Routing::waitForAll();
470 #endif
473  }
474  // check whether the tls programs need to be switched
476 
479  } else {
480  // assure all lanes with vehicles are 'active'
482 
483  // compute safe velocities for all vehicles for the next few lanes
484  // also register ApproachingVehicleInformation for all links
486 
487  // decide right-of-way and execute movements
491  }
492 
493  // vehicles may change lanes
495 
498  }
499  }
500  loadRoutes();
501 
502  // persons
505  }
506  // containers
509  }
510  // insert vehicles
513 #ifdef HAVE_FOX
514  MSDevice_Routing::waitForAll();
515 #endif
518  //myEdges->patchActiveLanes(); // @note required to detect collisions on lanes that were empty before insertion. wasteful?
520  }
522 
523  // execute endOfTimestepEvents
525 
526  if (myLogExecutionTime) {
528  }
530  if (myLogExecutionTime) {
532  }
533  // update and write (if needed) detector values
534  writeOutput();
535 
536  if (myLogExecutionTime) {
539  }
540  myStep += DELTA_T;
541 }
542 
543 
546  if (TraCIServer::wasClosed()) {
548  }
549  if (TraCIServer::getInstance() != 0 && !TraCIServer::getInstance()->getLoadArgs().empty()) {
550  return SIMSTATE_LOADING;
551  }
552  if ((stopTime < 0 || myStep > stopTime) && TraCIServer::getInstance() == 0) {
554  && (myInserter->getPendingFlowCount() == 0)
557  if (myPersonControl) {
559  }
560  if (myContainerControl) {
562  }
565  }
566  }
567  if (stopTime >= 0 && myStep >= stopTime) {
569  }
572  }
573  return SIMSTATE_RUNNING;
574 }
575 
576 
577 std::string
579  switch (state) {
581  return "";
583  return "The final simulation step has been reached.";
585  return "All vehicles have left the simulation.";
587  return "TraCI requested termination.";
589  return "An error occurred (see log).";
591  return "Too many teleports.";
593  return "TraCI issued load command.";
594  default:
595  return "Unknown reason.";
596  }
597 }
598 
599 
600 void
602  // clear container
603  MSEdge::clear();
604  MSLane::clear();
605  MSRoute::clear();
616  if (t != 0) {
617  t->cleanup();
618  }
621 }
622 
623 
624 void
626  // update detector values
628  const OptionsCont& oc = OptionsCont::getOptions();
629 
630  // check state dumps
631  if (oc.isSet("netstate-dump")) {
633  oc.getInt("netstate-dump.precision"));
634  }
635 
636  // check fcd dumps
637  if (OptionsCont::getOptions().isSet("fcd-output")) {
639  }
640 
641  // check emission dumps
642  if (OptionsCont::getOptions().isSet("emission-output")) {
644  oc.getInt("emission-output.precision"));
645  }
646 
647  // battery dumps
648  if (OptionsCont::getOptions().isSet("battery-output")) {
650  oc.getInt("battery-output.precision"));
651  }
652 
653  // check full dumps
654  if (OptionsCont::getOptions().isSet("full-output")) {
656  }
657 
658  // check queue dumps
659  if (OptionsCont::getOptions().isSet("queue-output")) {
661  }
662 
663  // check amitran dumps
664  if (OptionsCont::getOptions().isSet("amitran-output")) {
666  }
667 
668  // check vtk dumps
669  if (OptionsCont::getOptions().isSet("vtk-output")) {
670 
671  if (MSNet::getInstance()->getVehicleControl().getRunningVehicleNo() > 0) {
672  std::string timestep = time2string(myStep);
673  timestep = timestep.substr(0, timestep.length() - 3);
674  std::string output = OptionsCont::getOptions().getString("vtk-output");
675  std::string filename = output + "_" + timestep + ".vtp";
676 
677  OutputDevice_File dev = OutputDevice_File(filename, false);
678 
679  //build a huge mass of xml files
681 
682  }
683 
684  }
685 
686  // summary output
687  if (OptionsCont::getOptions().isSet("summary-output")) {
688  OutputDevice& od = OutputDevice::getDeviceByOption("summary-output");
689  int departedVehiclesNumber = myVehicleControl->getDepartedVehicleNo();
690  const double meanWaitingTime = departedVehiclesNumber != 0 ? myVehicleControl->getTotalDepartureDelay() / (double) departedVehiclesNumber : -1.;
691  int endedVehicleNumber = myVehicleControl->getEndedVehicleNo();
692  const double meanTravelTime = endedVehicleNumber != 0 ? myVehicleControl->getTotalTravelTime() / (double) endedVehicleNumber : -1.;
693  od.openTag("step");
694  od.writeAttr("time", time2string(myStep));
698  od.writeAttr("waiting", myInserter->getWaitingVehicleNo());
700  od.writeAttr("meanWaitingTime", meanWaitingTime);
701  od.writeAttr("meanTravelTime", meanTravelTime);
703  std::pair<double, double> meanSpeed = myVehicleControl->getVehicleMeanSpeeds();
704  od.writeAttr("meanSpeed", meanSpeed.first);
705  od.writeAttr("meanSpeedRelative", meanSpeed.second);
706  if (myLogExecutionTime) {
707  od.writeAttr("duration", mySimStepDuration);
708  }
709  od.closeTag();
710  }
711 
712  // write detector values
714 
715  // write link states
716  if (OptionsCont::getOptions().isSet("link-output")) {
717  OutputDevice& od = OutputDevice::getDeviceByOption("link-output");
718  od.openTag("timestep");
720  const MSEdgeVector& edges = myEdges->getEdges();
721  for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
722  const std::vector<MSLane*>& lanes = (*i)->getLanes();
723  for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
724  const std::vector<MSLink*>& links = (*j)->getLinkCont();
725  for (std::vector<MSLink*>::const_iterator k = links.begin(); k != links.end(); ++k) {
726  (*k)->writeApproaching(od, (*j)->getID());
727  }
728  }
729  }
730  od.closeTag();
731  }
732 
733  // write SSM output
734  for (std::set<MSDevice_SSM*>::iterator di = MSDevice_SSM::getInstances().begin(); di != MSDevice_SSM::getInstances().end(); ++di) {
735  MSDevice_SSM* dev = (*di);
736  dev->updateAndWriteOutput();
737  }
738 }
739 
740 
741 bool
743  return myLogExecutionTime;
744 }
745 
746 
749  if (myPersonControl == 0) {
751  }
752  return *myPersonControl;
753 }
754 
757  if (myContainerControl == 0) {
759  }
760  return *myContainerControl;
761 }
762 
763 
766  if (myEdgeWeights == 0) {
768  }
769  return *myEdgeWeights;
770 }
771 
772 
773 void
775  std::cout << "Step #" << time2string(myStep);
776 }
777 
778 
779 void
781  if (myLogExecutionTime) {
782  std::ostringstream oss;
783  oss.setf(std::ios::fixed , std::ios::floatfield); // use decimal format
784  oss.setf(std::ios::showpoint); // print decimal point
785  oss << std::setprecision(gPrecision);
786  if (mySimStepDuration != 0) {
787  const double durationSec = (double)mySimStepDuration / 1000.;
788  oss << " (" << mySimStepDuration << "ms ~= "
789  << (TS / durationSec) << "*RT, ~"
790  << ((double) myVehicleControl->getRunningVehicleNo() / durationSec);
791  } else {
792  oss << " (0ms ?*RT. ?";
793  }
794  oss << "UPS, ";
795  if (TraCIServer::getInstance() != 0) {
796  oss << "TraCI: " << myTraCIStepDuration << "ms, ";
797  }
798  oss << "vehicles TOT " << myVehicleControl->getDepartedVehicleNo()
799  << " ACT " << myVehicleControl->getRunningVehicleNo()
800  << " BUF " << myInserter->getWaitingVehicleNo()
801  << ") ";
802  std::string prev = "Step #" + time2string(myStep - DELTA_T);
803  std::cout << oss.str().substr(0, 78 - prev.length());
804  }
805  std::cout << '\r';
806 }
807 
808 
809 void
811  if (find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener) == myVehicleStateListeners.end()) {
812  myVehicleStateListeners.push_back(listener);
813  }
814 }
815 
816 
817 void
819  std::vector<VehicleStateListener*>::iterator i = find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener);
820  if (i != myVehicleStateListeners.end()) {
821  myVehicleStateListeners.erase(i);
822  }
823 }
824 
825 
826 void
827 MSNet::informVehicleStateListener(const SUMOVehicle* const vehicle, VehicleState to, const std::string& info) {
828  for (std::vector<VehicleStateListener*>::iterator i = myVehicleStateListeners.begin(); i != myVehicleStateListeners.end(); ++i) {
829  (*i)->vehicleStateChanged(vehicle, to, info);
830  }
831 }
832 
833 
834 bool
836  return myStoppingPlaces[category == SUMO_TAG_TRAIN_STOP ? SUMO_TAG_BUS_STOP : category].add(stop->getID(), stop);
837 }
838 
839 
841 MSNet::getStoppingPlace(const std::string& id, const SumoXMLTag category) const {
842  if (myStoppingPlaces.count(category) > 0) {
843  return myStoppingPlaces.find(category)->second.get(id);
844  }
845  return 0;
846 }
847 
848 
849 std::string
850 MSNet::getStoppingPlaceID(const MSLane* lane, const double pos, const SumoXMLTag category) const {
851  if (myStoppingPlaces.count(category) > 0) {
852  for (const auto& it : myStoppingPlaces.find(category)->second) {
853  MSStoppingPlace* stop = it.second;
854  if (&stop->getLane() == lane && stop->getBeginLanePosition() <= pos && stop->getEndLanePosition() >= pos) {
855  return stop->getID();
856  }
857  }
858  }
859  return "";
860 }
861 
862 
863 void
866  OutputDevice& output = OutputDevice::getDeviceByOption("chargingstations-output");
867  for (const auto& it : myStoppingPlaces.find(SUMO_TAG_CHARGING_STATION)->second) {
868  static_cast<MSChargingStation*>(it.second)->writeChargingStationOutput(output);
869  }
870  }
871 }
872 
873 
875 MSNet::getRouterTT(const MSEdgeVector& prohibited) const {
876  if (myRouterTT == 0) {
877  const std::string routingAlgorithm = OptionsCont::getOptions().getString("routing-algorithm");
878  if (routingAlgorithm == "dijkstra") {
881  } else {
882  if (routingAlgorithm != "astar") {
883  WRITE_WARNING("TraCI and Triggers cannot use routing algorithm '" + routingAlgorithm + "'. using 'astar' instead.");
884  }
887  }
888  }
889  dynamic_cast<SUMOAbstractRouterPermissions<MSEdge, SUMOVehicle>*>(myRouterTT)->prohibit(prohibited);
890  return *myRouterTT;
891 }
892 
893 
895 MSNet::getRouterEffort(const MSEdgeVector& prohibited) const {
896  if (myRouterEffort == 0) {
899  }
900  dynamic_cast<SUMOAbstractRouterPermissions<MSEdge, SUMOVehicle>*>(myRouterEffort)->prohibit(prohibited);
901  return *myRouterEffort;
902 }
903 
904 
906 MSNet::getPedestrianRouter(const MSEdgeVector& prohibited) const {
907  if (myPedestrianRouter == 0) {
909  }
910  myPedestrianRouter->prohibit(prohibited);
911  return *myPedestrianRouter;
912 }
913 
914 
916 MSNet::getIntermodalRouter(const int routingMode, const MSEdgeVector& prohibited) const {
917  if (myIntermodalRouter.count(routingMode) == 0) {
918  int carWalk = 0;
919  for (const std::string& opt : OptionsCont::getOptions().getStringVector("persontrip.transfer.car-walk")) {
920  if (opt == "parkingAreas") {
922  } else if (opt == "ptStops") {
924  } else if (opt == "allJunctions") {
926  }
927  }
928  if (routingMode == ROUTING_MODE_COMBINED) {
929  // replace nullptr here by your EffortCalculator
930  myIntermodalRouter[routingMode] = new MSIntermodalRouter(MSNet::adaptIntermodalRouter, carWalk, routingMode, nullptr);
931  } else {
932  myIntermodalRouter[routingMode] = new MSIntermodalRouter(MSNet::adaptIntermodalRouter, carWalk, routingMode);
933  }
934  }
935  myIntermodalRouter[routingMode]->prohibit(prohibited);
936  return *myIntermodalRouter[routingMode];
937 }
938 
939 
940 void
942  // add access to all parking areas
943  for (const auto& i : myInstance->myStoppingPlaces[SUMO_TAG_PARKING_AREA]) {
944  const MSEdge* const edge = &i.second->getLane().getEdge();
945  router.getNetwork()->addAccess(i.first, edge, i.second->getAccessPos(edge), i.second->getAccessDistance(edge), SUMO_TAG_PARKING_AREA);
946  }
947  // add access to all public transport stops
948  for (const auto& i : myInstance->myStoppingPlaces[SUMO_TAG_BUS_STOP]) {
949  const MSEdge* const edge = &i.second->getLane().getEdge();
950  router.getNetwork()->addAccess(i.first, edge, i.second->getAccessPos(edge), i.second->getAccessDistance(edge), SUMO_TAG_BUS_STOP);
951  for (const auto& a : i.second->getAllAccessPos()) {
952  router.getNetwork()->addAccess(i.first, &std::get<0>(a)->getEdge(), std::get<1>(a), std::get<2>(a), SUMO_TAG_BUS_STOP);
953  }
954  }
957 }
958 
959 
960 const NamedRTree&
962  if (!myLanesRTree.first) {
963  MSLane::fill(myLanesRTree.second);
964  myLanesRTree.first = true;
965  }
966  return myLanesRTree.second;
967 }
968 
969 
970 bool
972  const MSEdgeVector& edges = myEdges->getEdges();
973  for (MSEdgeVector::const_iterator e = edges.begin(); e != edges.end(); ++e) {
974  for (std::vector<MSLane*>::const_iterator i = (*e)->getLanes().begin(); i != (*e)->getLanes().end(); ++i) {
975  if ((*i)->getShape().hasElevation()) {
976  return true;
977  }
978  }
979  }
980  return false;
981 }
982 
983 
984 bool
985 MSNet::warnOnce(const std::string& typeAndID) {
986  if (myWarnedOnce.find(typeAndID) == myWarnedOnce.end()) {
987  myWarnedOnce[typeAndID] = true;
988  return true;
989  }
990  return false;
991 }
992 
993 /****************************************************************************/
std::string myStateDumpSuffix
Definition: MSNet.h:706
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:49
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
static double gLateralResolution
Definition: MSGlobals.h:85
bool hasNonWaiting() const
checks whether any transportable is still engaged in walking / stopping
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
SumoXMLTag
Numbers representing SUMO-XML - element names.
int getEndedVehicleNo() const
Returns the number of removed vehicles.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79
public transport stops and access
long long int SUMOTime
Definition: SUMOTime.h:36
double getBeginLanePosition() const
Returns the begin position of this stop.
Interface for objects listening to vehicle state changes.
Definition: MSNet.h:518
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
void loadNext(SUMOTime step)
loads the next routes up to and including the given time step
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle&#39;s state change.
Definition: MSNet.cpp:827
void removeVehicleStateListener(VehicleStateListener *listener)
Removes a vehicle states listener.
Definition: MSNet.cpp:818
MSPedestrianRouter * myPedestrianRouter
Definition: MSNet.h:744
MSEventControl * myEndOfTimestepEvents
Controls events executed at the end of a time step;.
Definition: MSNet.h:663
int getRunningVehicleNo() const
Returns the number of build and inserted, but not yet deleted vehicles.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
int getLoadedVehicleNo() const
Returns the number of build vehicles.
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:841
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:850
static void cleanup()
Clean up remaining devices instances.
A lane area vehicles can halt at.
bool warnOnce(const std::string &typeAndID)
return whether a warning regarding the given object shall be issued
Definition: MSNet.cpp:985
const NamedRTree & getLanesRTree() const
Returns an RTree that contains lane IDs.
Definition: MSNet.cpp:961
void patchActiveLanes()
Resets information whether a lane is active for all lanes.
int getLoadedNumber() const
Returns the number of build transportables.
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition: MSLane.cpp:1736
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
Definition: MSNet.h:645
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:27
void updateDetectors(const SUMOTime step)
Computes detector values.
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
Definition: MSDevice_SSM.h:56
std::vector< SUMOTime > myStateDumpTimes
Times at which a state shall be written.
Definition: MSNet.h:699
virtual void execute(SUMOTime time)
Executes time-dependant commands.
SimulationState simulate(SUMOTime start, SUMOTime stop)
Simulates from timestep start to stop.
Definition: MSNet.cpp:308
SUMOAbstractRouter< MSEdge, SUMOVehicle > * myRouterEffort
Definition: MSNet.h:743
bool logSimulationDuration() const
Returns whether duration shall be logged.
Definition: MSNet.cpp:742
MSIntermodalRouter & getIntermodalRouter(const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:916
void changeLanes(SUMOTime t)
Moves (precomputes) critical vehicles.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:67
std::map< SumoXMLTag, NamedObjectCont< MSStoppingPlace * > > myStoppingPlaces
Dictionary of bus / container stops.
Definition: MSNet.h:730
A RT-tree for efficient storing of SUMO&#39;s Named objects.
Definition: NamedRTree.h:65
Computes the shortest path through a network using the A* algorithm.
Definition: AStarRouter.h:77
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:160
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
Definition: MSNet.h:712
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
MSEdgeControl * myEdges
Controls edges, performs vehicle movement;.
Definition: MSNet.h:651
The final simulation step has been performed.
Definition: MSNet.h:96
void writeOutput(SUMOTime step, bool closing)
Writes the output to be generated within the given time step.
double myVersion
the network version
Definition: MSNet.h:727
std::vector< std::string > myStateDumpFiles
The names for the state files.
Definition: MSNet.h:701
static void cleanup()
Definition: Helper.cpp:292
bool myLogExecutionTime
Information whether the simulation duration shall be logged.
Definition: MSNet.h:678
int getActiveVehicleCount() const
Returns the number of build vehicles that have not been removed or need to wait for a passenger or a ...
Storage for geometrical objects.
#define ROUTING_MODE_COMBINED
static const std::string STAGE_LANECHANGE
Definition: MSNet.h:755
void cleanup()
clean up subscriptions
static void write(OutputDevice &of, SUMOTime timestep)
Dumping a hugh List of Parameters available in the Simulation.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
Definition: Named.h:69
std::vector< std::string > & getLoadArgs()
Definition: TraCIServer.h:250
#define TS
Definition: SUMOTime.h:45
Detectors container; responsible for string and output generation.
bool myLefthand
Whether the network was built for left-hand traffic.
Definition: MSNet.h:724
A storage for edge travel times and efforts.
void detectCollisions(SUMOTime timestep, const std::string &stage)
Detect collisions.
std::map< int, MSIntermodalRouter * > myIntermodalRouter
Definition: MSNet.h:745
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition: MSNet.cpp:810
SimulationState
Possible states of a simulation - running or stopped with different reasons.
Definition: MSNet.h:90
bool addStoppingPlace(const SumoXMLTag category, MSStoppingPlace *stop)
Adds a stopping place.
Definition: MSNet.cpp:835
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:242
The simulated network and simulation perfomer.
Definition: MSNet.h:85
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
Definition: OptionsIO.cpp:55
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
#define SIMTIME
Definition: SUMOTime.h:65
ShapeContainer * myShapeContainer
A container for geometrical shapes;.
Definition: MSNet.h:667
std::pair< bool, NamedRTree > myLanesRTree
An RTree structure holding lane IDs.
Definition: MSNet.h:749
void abortWaitingForVehicle()
aborts the plan for any transportable that is still waiting for a ride
Container for junctions; performs operations on all stored junctions.
static bool gCheck4Accidents
Definition: MSGlobals.h:76
static void write(OutputDevice &of, SUMOTime timestep)
Export the queueing length in front of a junction (very experimental!)
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:756
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
virtual std::pair< double, double > getVehicleMeanSpeeds() const
get current absolute and relative mean vehicle speed in the network
void writeChargingStationOutput() const
write charging station output
Definition: MSNet.cpp:864
A class that stores and controls tls and switching of their programs.
A road/street connecting two junctions.
Definition: MSEdge.h:75
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
long long int myVehiclesMoved
The overall number of vehicle movements.
Definition: MSNet.h:690
double getEndLanePosition() const
Returns the end position of this stop.
The simulation does not contain further vehicles.
Definition: MSNet.h:98
static void generateOutputForUnfinished()
generate output for vehicles which are still in the network
An error occurred during the simulation step.
Definition: MSNet.h:102
double getTotalDepartureDelay() const
Returns the total departure delay.
static void clear()
Clears the dictionary (delete all known routes, too)
Definition: MSRoute.cpp:167
The main mesocopic simulation loop.
Definition: MELoop.h:49
void writeOutput()
Write netstate, summary and detector output.
Definition: MSNet.cpp:625
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
SimulationState simulationState(SUMOTime stopTime) const
Called after a simulation step, this method returns the current simulation state. ...
Definition: MSNet.cpp:545
static std::string printStatistics()
get statistics for printing to stdout
MSInsertionControl * myInserter
Controls vehicle insertion;.
Definition: MSNet.h:657
Representation of a vehicle.
Definition: SUMOVehicle.h:60
void checkInsertions(SUMOTime time)
Checks "movement" of stored vehicles.
static void cleanup()
Definition: MSStopOut.cpp:48
Computes the shortest path through a network using the Dijkstra algorithm.
int emitVehicles(SUMOTime time)
Emits vehicles that want to depart at the given time.
SUMORouteLoaderControl * myRouteLoaders
Route loader for dynamic loading of routes.
Definition: MSNet.h:631
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:748
static double getTravelTime(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the travel time to pass an edge.
Definition: MSNet.cpp:143
void closeSimulation(SUMOTime start)
Closes the simulation (all files, connections, etc.)
Definition: MSNet.cpp:363
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
Definition: MSNet.h:715
bool myLogStepNumber
Information whether the number of the simulation step shall be logged.
Definition: MSNet.h:681
int getTeleportsYield() const
return the number of teleports due to vehicles stuck on a minor road
An output device that encapsulates an ofstream.
static void clear()
Clears the dictionary.
Definition: MSEdge.cpp:779
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:309
SUMOTime getTargetTime() const
Definition: TraCIServer.h:67
MSDetectorControl * myDetectorControl
Controls detectors;.
Definition: MSNet.h:659
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void postSimStepOutput() const
Prints the statistics of the step at its end.
Definition: MSNet.cpp:780
double getMinimumTravelTime(const SUMOVehicle *const veh) const
returns the minimum travel time for the given vehicle
Definition: MSEdge.h:407
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:67
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:298
#define STEPS2TIME(x)
Definition: SUMOTime.h:58
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
Definition: MSNet.h:655
static void write(OutputDevice &of, SUMOTime timestep)
Produce a VTK output to use with Tools like ParaView.
Definition: MSVTKExport.cpp:43
The connection to a client was closed by the client.
Definition: MSNet.h:100
The simulation is running.
Definition: MSNet.h:94
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:256
int getEmergencyStops() const
return the number of emergency stops
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:42
std::map< std::string, bool > myWarnedOnce
container to record warnings that shall only be issued once
Definition: MSNet.h:736
void check2Switch(SUMOTime step)
Checks whether any WAUT is trying to switch a tls into another program.
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
Definition: MSNet.cpp:292
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
static void postProcessRemoteControl()
Definition: Helper.cpp:428
bool hasInternalLinks() const
return whether the network contains internal links
Definition: MSNet.h:598
bool hasTransportables() const
checks whether any transportable waits to finish her plan
void updateAndWriteOutput()
This is called once per time step in MSNet::writeOutput() and collects the surrounding vehicles...
int getTeleportsJam() const
return the number of teleports due to jamming
static void cleanupAll()
perform cleanup for all devices
Definition: MSDevice.cpp:105
static void cleanup()
properly deletes all trigger instances
Definition: MSTrigger.cpp:44
static const std::set< MSDevice_SSM * > & getInstances()
returns all currently existing SSM devices
double getTotalTravelTime() const
Returns the total travel time.
TraCI server used to control sumo by a remote TraCI client.
Definition: TraCIServer.h:62
MSPedestrianRouter & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:906
static void generateOutputForUnfinished()
generate vehroute output for vehicles which are still in the network
bool lefthand() const
return whether the network was built for lefthand traffic
Definition: MSNet.h:608
SUMOTime myStateDumpPeriod
The period for writing state.
Definition: MSNet.h:703
int getTeleportsWrongLane() const
return the number of teleports due to vehicles stuck on the wrong lane
Inserts vehicles into the network when their departure time is reached.
long myTraCIStepDuration
The last simulation step duration.
Definition: MSNet.h:684
void postloadInitContainer()
Closes building of junctions.
int myMaxTeleports
Maximum number of teleports.
Definition: MSNet.h:637
junctions with edges allowing the additional mode
void abortWaiting()
informes about all waiting vehicles (deletion in destructor)
PedestrianRouter< MSEdge, MSLane, MSJunction, MSVehicle > MSPedestrianRouter
Definition: MSNet.h:107
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:487
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 hasNeighs, bool lefthand, double version)
Closes the network&#39;s building process.
Definition: MSNet.cpp:213
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
static const std::string STAGE_MOVEMENTS
Definition: MSNet.h:754
void processCommandsUntilSimStep(SUMOTime step)
process all commands until the next SUMO simulation step. It is guaranteed that t->getTargetTime() >=...
std::vector< VehicleStateListener * > myVehicleStateListeners
Container for vehicle state listener.
Definition: MSNet.h:733
static MSNet * myInstance
Unique instance of MSNet.
Definition: MSNet.h:628
static void clearAll()
Clears all dictionaries.
Definition: MSNet.cpp:601
The simulation is loading.
Definition: MSNet.h:92
void planMovements(SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step...
void executeMovements(SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
A train stop (alias for bus stop)
bool retrieveExistingTravelTime(const MSEdge *const e, const double t, double &value) const
Returns a travel time for an edge and time if stored.
void close(SUMOTime step)
Closes the detector outputs.
MSTransportableControl * myContainerControl
Controls container building and deletion;.
Definition: MSNet.h:649
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
Definition: MSNet.h:653
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
virtual int getHaltingVehicleNo() const
Returns the number of halting vehicles.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:362
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:1719
static void write(OutputDevice &of, SUMOTime timestep, int precision)
Writes the complete network state of the given edges into the given device.
MSTransportableControl * myPersonControl
Controls person building and deletion;.
Definition: MSNet.h:647
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:773
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool checkElevation()
check all lanes for elevation data
Definition: MSNet.cpp:971
int getPendingFlowCount() const
Returns the number of flows that are still active.
static void cleanup()
remove state at simulation end
Definition: MSPModel.cpp:82
void preSimStepOutput() const
Prints the current step number.
Definition: MSNet.cpp:774
static TraCIServer * getInstance()
Definition: TraCIServer.h:73
MSEventControl * myBeginOfTimestepEvents
Controls events executed at the begin of a time step;.
Definition: MSNet.h:661
A storage for options typed value containers)
Definition: OptionsCont.h:92
static void cleanup()
removes remaining vehicleInformation in sVehicles
MSEdgeWeightsStorage * myEdgeWeights
The net&#39;s knowledge about edge efforts/travel times;.
Definition: MSNet.h:669
The simulation had too many teleports.
Definition: MSNet.h:104
void prohibit(const std::vector< E *> &toProhibit)
MSNet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents, ShapeContainer *shapeCont=0)
Constructor.
Definition: MSNet.cpp:168
void checkWaiting(MSNet *net, const SUMOTime time)
checks whether any transportables waiting time is over
static void write(OutputDevice &of, const SUMOTime timestep)
Writes the complete network state into the given device.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:106
static void cleanup()
cleanup remaining data structures
const MSEdgeVector & getEdges() const
Returns loaded edges.
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle&#39;s internal edge travel times/efforts container.
Definition: MSVehicle.cpp:848
long mySimBeginMillis
The overall simulation duration.
Definition: MSNet.h:687
virtual ~MSNet()
Destructor.
Definition: MSNet.cpp:250
bool myHasElevation
Whether the network contains elevation data.
Definition: MSNet.h:721
static void write(OutputDevice &of, SUMOTime timestep, int precision)
Writes the complete network state of the given edges into the given device.
std::string myStateDumpPrefix
name components for periodic state
Definition: MSNet.h:705
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
static void closeAll(bool keepErrorRetrievers=false)
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static std::string getStateMessage(SimulationState state)
Returns the message to show if a certain state occurs.
Definition: MSNet.cpp:578
IntermodalRouter< MSEdge, MSLane, MSJunction, SUMOVehicle > MSIntermodalRouter
Definition: MSNet.h:108
bool isEmbedded() const
Definition: TraCIServer.h:70
SUMOTime myStep
Current time step.
Definition: MSNet.h:634
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:875
The class responsible for building and deletion of vehicles.
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:71
int getDepartedVehicleNo() const
Returns the number of inserted vehicles.
void simulationStep()
Performs a single simulation step.
Definition: MSNet.cpp:430
static long getCurrentMillis()
Returns the current time in milliseconds.
Definition: SysUtils.cpp:39
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
const MSLane & getLane() const
Returns the lane this stop is located at.
void simulate(SUMOTime tMax)
Perform simulation up to the given time.
Definition: MELoop.cpp:63
void loadRoutes()
loads routes for the next few steps
Definition: MSNet.cpp:357
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:243
static const std::string STAGE_INSERTIONS
Definition: MSNet.h:756
MSEventControl * myInsertionEvents
Controls insertion events;.
Definition: MSNet.h:665
static bool gUseMesoSim
Definition: MSGlobals.h:91
int getCollisionCount() const
return the number of collisions
Representation of a lane in the micro simulation.
Definition: MSLane.h:71
long mySimStepDuration
Definition: MSNet.h:684
static bool wasClosed()
check whether close was requested
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterEffort(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:895
int getTeleportCount() const
return the number of teleports (including collisions)
Stores time-dependant events and executes them at the proper time.
bool myHasInternalLinks
Whether the network contains internal links/lanes/edges.
Definition: MSNet.h:718
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:230
void addAccess(const std::string &stopId, const E *stopEdge, const double pos, const double length, const SumoXMLTag category)
Adds access edges for stopping places to the intermodal network.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
SUMOAbstractRouter< MSEdge, SUMOVehicle > * myRouterTT
Definition: MSNet.h:742
static void adaptIntermodalRouter(MSIntermodalRouter &router)
Definition: MSNet.cpp:941
static void cleanup()
remove state at simulation end
void determineCandidates(SUMOTime time)
Checks for all vehicles whether they can be emitted.
Network * getNetwork() const
static void saveState(const std::string &file, SUMOTime step)
Saves the current state.
static double getEffort(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the effort to pass an edge.
Definition: MSNet.cpp:129
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net&#39;s internal edge travel times/efforts container.
Definition: MSNet.cpp:765
static const std::string STAGE_EVENTS
string constants for simstep stages
Definition: MSNet.h:753
int getJammedNumber() const
Returns the number of times a transportables was jammed.