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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
25 // The simulated network and simulation perfomer
26 /****************************************************************************/
27 
28 
29 // ===========================================================================
30 // included modules
31 // ===========================================================================
32 #ifdef _MSC_VER
33 #include <windows_config.h>
34 #else
35 #include <config.h>
36 #endif
37 
38 #include <string>
39 #include <iostream>
40 #include <sstream>
41 #include <typeinfo>
42 #include <algorithm>
43 #include <cassert>
44 #include <vector>
45 #include <ctime>
46 
47 #include "trigger/MSTrigger.h"
48 #include "trigger/MSCalibrator.h"
50 #include "MSVehicleControl.h"
52 #include <utils/common/ToString.h>
53 #include <utils/common/SysUtils.h>
67 #include <utils/xml/XMLSubSys.h>
68 #include <mesosim/MELoop.h>
89 
90 #include "MSTransportableControl.h"
91 #include "MSEdgeControl.h"
92 #include "MSJunctionControl.h"
93 #include "MSInsertionControl.h"
94 #include "MSEventControl.h"
95 #include "MSEdge.h"
96 #include "MSJunction.h"
97 #include "MSJunctionLogic.h"
98 #include "MSLane.h"
99 #include "MSVehicleTransfer.h"
100 #include "MSRoute.h"
101 #include "MSGlobals.h"
102 #include "MSContainer.h"
103 #include "MSEdgeWeightsStorage.h"
104 #include "MSStateHandler.h"
105 #include "MSFrame.h"
106 #include "MSParkingArea.h"
107 #include "MSStoppingPlace.h"
108 #include "MSNet.h"
109 
110 #ifndef NO_TRACI
112 #include <libsumo/Simulation.h>
113 #endif
114 
115 
116 // ===========================================================================
117 // debug constants
118 // ===========================================================================
119 //#define DEBUG_SIMSTEP
120 
121 
122 // ===========================================================================
123 // static member definitions
124 // ===========================================================================
126 
127 const std::string MSNet::STAGE_EVENTS("events");
128 const std::string MSNet::STAGE_MOVEMENTS("move");
129 const std::string MSNet::STAGE_LANECHANGE("laneChange");
130 const std::string MSNet::STAGE_INSERTIONS("insertion");
131 
132 // ===========================================================================
133 // static member method definitions
134 // ===========================================================================
135 double
136 MSNet::getEffort(const MSEdge* const e, const SUMOVehicle* const v, double t) {
137  double value;
138  const MSVehicle* const veh = dynamic_cast<const MSVehicle* const>(v);
139  if (veh != 0 && veh->getWeightsStorage().retrieveExistingEffort(e, t, value)) {
140  return value;
141  }
142  if (getInstance()->getWeightsStorage().retrieveExistingEffort(e, t, value)) {
143  return value;
144  }
145  return 0;
146 }
147 
148 
149 double
150 MSNet::getTravelTime(const MSEdge* const e, const SUMOVehicle* const v, double t) {
151  double value;
152  const MSVehicle* const veh = dynamic_cast<const MSVehicle* const>(v);
153  if (veh != 0 && veh->getWeightsStorage().retrieveExistingTravelTime(e, t, value)) {
154  return value;
155  }
157  return value;
158  }
159  return e->getMinimumTravelTime(v);
160 }
161 
162 
163 // ---------------------------------------------------------------------------
164 // MSNet - methods
165 // ---------------------------------------------------------------------------
166 MSNet*
168  if (myInstance != 0) {
169  return myInstance;
170  }
171  throw ProcessError("A network was not yet constructed.");
172 }
173 
174 
175 MSNet::MSNet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
176  MSEventControl* endOfTimestepEvents, MSEventControl* insertionEvents,
177  ShapeContainer* shapeCont):
178  myVehiclesMoved(0),
179  myHavePermissions(false),
180  myHasInternalLinks(false),
181  myHasElevation(false),
182  myRouterTT(0),
183  myRouterEffort(0),
185  myIntermodalRouter(0) {
186  if (myInstance != 0) {
187  throw ProcessError("A network was already constructed.");
188  }
190  myStep = string2time(oc.getString("begin"));
191  myMaxTeleports = oc.getInt("max-num-teleports");
192  myLogExecutionTime = !oc.getBool("no-duration-log");
193  myLogStepNumber = !oc.getBool("no-step-log");
194  myInserter = new MSInsertionControl(*vc, string2time(oc.getString("max-depart-delay")), oc.getBool("eager-insert"), oc.getInt("max-num-vehicles"));
195  myVehicleControl = vc;
197  myEdges = 0;
198  myJunctions = 0;
199  myRouteLoaders = 0;
200  myLogics = 0;
201  myPersonControl = 0;
202  myContainerControl = 0;
203  myEdgeWeights = 0;
204  myShapeContainer = shapeCont == 0 ? new ShapeContainer() : shapeCont;
205 
206  myBeginOfTimestepEvents = beginOfTimestepEvents;
207  myEndOfTimestepEvents = endOfTimestepEvents;
208  myInsertionEvents = insertionEvents;
209  myLanesRTree.first = false;
210 
212  MSGlobals::gMesoNet = new MELoop(string2time(oc.getString("meso-recheck")));
213  }
214  myInstance = this;
215 }
216 
217 
218 void
220  SUMORouteLoaderControl* routeLoaders,
221  MSTLLogicControl* tlc,
222  std::vector<SUMOTime> stateDumpTimes,
223  std::vector<std::string> stateDumpFiles,
224  bool hasInternalLinks,
225  bool hasNeighs,
226  bool lefthand,
227  double version) {
228  myEdges = edges;
229  myJunctions = junctions;
230  myRouteLoaders = routeLoaders;
231  myLogics = tlc;
232  // save the time the network state shall be saved at
233  myStateDumpTimes = stateDumpTimes;
234  myStateDumpFiles = stateDumpFiles;
235  myStateDumpPeriod = string2time(oc.getString("save-state.period"));
236  myStateDumpPrefix = oc.getString("save-state.prefix");
237  myStateDumpSuffix = oc.getString("save-state.suffix");
238 
239  // set requests/responses
241 
242  // initialise performance computation
243  if (myLogExecutionTime) {
245  }
247  if (hasNeighs && MSGlobals::gLateralResolution > 0) {
248  WRITE_WARNING("Opposite direction driving does not work together with the sublane model.");
249  }
252  myVersion = version;
253 }
254 
255 
257  // delete events first maybe they do some cleanup
260  delete myEndOfTimestepEvents;
262  delete myInsertionEvents;
263  myInsertionEvents = 0;
264  // delete controls
265  delete myJunctions;
266  delete myDetectorControl;
267  // delete mean data
268  delete myEdges;
269  delete myInserter;
270  delete myLogics;
271  delete myRouteLoaders;
272  if (myPersonControl != 0) {
273  delete myPersonControl;
274  }
275  if (myContainerControl != 0) {
276  delete myContainerControl;
277  }
278  delete myVehicleControl; // must happen after deleting transportables
279  delete myShapeContainer;
280  delete myEdgeWeights;
281  delete myRouterTT;
282  delete myRouterEffort;
283  if (myPedestrianRouter != 0) {
284  delete myPedestrianRouter;
285  }
286  myLanesRTree.second.RemoveAll();
287  clearAll();
289  delete MSGlobals::gMesoNet;
290  }
291 // delete myPedestrianRouter;
292  myInstance = 0;
293 }
294 
295 
296 void
297 MSNet::addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
298  myRestrictions[id][svc] = speed;
299 }
300 
301 
302 const std::map<SUMOVehicleClass, double>*
303 MSNet::getRestrictions(const std::string& id) const {
304  std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i = myRestrictions.find(id);
305  if (i == myRestrictions.end()) {
306  return 0;
307  }
308  return &i->second;
309 }
310 
311 
314  // report the begin when wished
315  WRITE_MESSAGE("Simulation started with time: " + time2string(start));
316  // the simulation loop
318  // state loading may have changed the start time so we need to reinit it
319  myStep = start;
320 #ifndef NO_TRACI
321 #ifdef HAVE_PYTHON
322  if (OptionsCont::getOptions().isSet("python-script")) {
323  TraCIServer::runEmbedded(OptionsCont::getOptions().getString("python-script"));
324  closeSimulation(start);
325  WRITE_MESSAGE("Simulation ended at time: " + time2string(getCurrentTimeStep()));
326  WRITE_MESSAGE("Reason: Script ended");
327  return state;
328  }
329 #endif
330 #endif
331  while (state == SIMSTATE_RUNNING) {
332  if (myLogStepNumber) {
334  }
335  simulationStep();
336  if (myLogStepNumber) {
338  }
339  state = simulationState(stop);
340 #ifdef DEBUG_SIMSTEP
341  std::cout << SIMTIME << " MSNet::simulate(" << start << ", " << stop << ")"
342  << "\n simulation state: " << getStateMessage(state)
343  << std::endl;
344 #endif
345 #ifndef NO_TRACI
346  if (state == SIMSTATE_LOADING) {
349  } else if (state != SIMSTATE_RUNNING) {
351  // overrides SIMSTATE_END_STEP_REACHED, e.g. (TraCI ignore SUMO's --end option)
352  state = SIMSTATE_RUNNING;
353  }
354  }
355 #endif
356  }
357  // report the end when wished
358  WRITE_MESSAGE("Simulation ended at time: " + time2string(getCurrentTimeStep()));
359  WRITE_MESSAGE("Reason: " + getStateMessage(state));
360  // exit simulation loop
361  closeSimulation(start);
362  return state;
363 }
364 
365 void
368 }
369 
370 
371 void
374  if (OptionsCont::getOptions().getBool("vehroute-output.write-unfinished")) {
376  }
377  if (OptionsCont::getOptions().getBool("tripinfo-output.write-unfinished")) {
379  }
380  if (OptionsCont::getOptions().isSet("chargingstations-output")) {
382  }
383  if (myLogExecutionTime) {
384  long duration = SysUtils::getCurrentMillis() - mySimBeginMillis;
385  std::ostringstream msg;
386  // print performance notice
387  msg << "Performance: " << "\n" << " Duration: " << duration << "ms" << "\n";
388  if (duration != 0) {
389  msg << " Real time factor: " << (STEPS2TIME(myStep - start) * 1000. / (double)duration) << "\n";
390  msg.setf(std::ios::fixed , std::ios::floatfield); // use decimal format
391  msg.setf(std::ios::showpoint); // print decimal point
392  msg << " UPS: " << ((double)myVehiclesMoved / ((double)duration / 1000)) << "\n";
393  }
394  // print vehicle statistics
395  const std::string discardNotice = ((myVehicleControl->getLoadedVehicleNo() != myVehicleControl->getDepartedVehicleNo()) ?
396  " (Loaded: " + toString(myVehicleControl->getLoadedVehicleNo()) + ")" : "");
397  msg << "Vehicles: " << "\n"
398  << " Inserted: " << myVehicleControl->getDepartedVehicleNo() << discardNotice << "\n"
399  << " Running: " << myVehicleControl->getRunningVehicleNo() << "\n"
400  << " Waiting: " << myInserter->getWaitingVehicleNo() << "\n";
401 
403  // print optional teleport statistics
404  std::vector<std::string> reasons;
405  if (myVehicleControl->getCollisionCount() > 0) {
406  reasons.push_back("Collisions: " + toString(myVehicleControl->getCollisionCount()));
407  }
408  if (myVehicleControl->getTeleportsJam() > 0) {
409  reasons.push_back("Jam: " + toString(myVehicleControl->getTeleportsJam()));
410  }
411  if (myVehicleControl->getTeleportsYield() > 0) {
412  reasons.push_back("Yield: " + toString(myVehicleControl->getTeleportsYield()));
413  }
415  reasons.push_back("Wrong Lane: " + toString(myVehicleControl->getTeleportsWrongLane()));
416  }
417  msg << "Teleports: " << myVehicleControl->getTeleportCount() << " (" << joinToString(reasons, ", ") << ")\n";
418  }
419  if (myVehicleControl->getEmergencyStops() > 0) {
420  msg << "Emergency Stops: " << myVehicleControl->getEmergencyStops() << "\n";
421  }
422  if (myPersonControl != 0 && myPersonControl->getLoadedNumber() > 0) {
423  msg << "Persons: " << "\n"
424  << " Inserted: " << myPersonControl->getLoadedNumber() << "\n"
425  << " Running: " << myPersonControl->getRunningNumber() << "\n";
426  if (myPersonControl->getJammedNumber() > 0) {
427  msg << " Jammed: " << myPersonControl->getJammedNumber() << "\n";
428  }
429  }
430  if (OptionsCont::getOptions().getBool("duration-log.statistics")) {
432  }
433  WRITE_MESSAGE(msg.str());
434  }
435 }
436 
437 
438 void
440 #ifdef DEBUG_SIMSTEP
441  std::cout << SIMTIME << ": MSNet::simulationStep() called"
442  << ", myStep = " << myStep
443  << std::endl;
444 #endif
445 #ifndef NO_TRACI
446  if (myLogExecutionTime) {
448  }
450  if (t != 0 && !t->isEmbedded()) {
452 #ifdef DEBUG_SIMSTEP
453  bool loadRequested = !TraCI::getLoadArgs().empty();
454  bool closed = TraCIServer::wasClosed();
455  assert(t->getTargetTime() >= myStep || loadRequested || closed);
456 #endif
457  }
458  if (myLogExecutionTime) {
460  }
461 #ifdef DEBUG_SIMSTEP
462  std::cout << SIMTIME << ": TraCI target time: " << t->getTargetTime() << std::endl;
463 #endif
464 #endif
465  // execute beginOfTimestepEvents
466  if (myLogExecutionTime) {
468  }
469  // simulation state output
470  std::vector<SUMOTime>::iterator timeIt = find(myStateDumpTimes.begin(), myStateDumpTimes.end(), myStep);
471  if (timeIt != myStateDumpTimes.end()) {
472  const int dist = (int)distance(myStateDumpTimes.begin(), timeIt);
474  }
475  if (myStateDumpPeriod > 0 && myStep % myStateDumpPeriod == 0) {
477  }
479 #ifdef HAVE_FOX
480  MSDevice_Routing::waitForAll();
481 #endif
484  }
485  // check whether the tls programs need to be switched
487 
490  } else {
491  // assure all lanes with vehicles are 'active'
493 
494  // compute safe velocities for all vehicles for the next few lanes
495  // also register ApproachingVehicleInformation for all links
497 
498  // decide right-of-way and execute movements
502  }
503 
504  // vehicles may change lanes
506 
509  }
510  }
511  loadRoutes();
512 
513  // persons
516  }
517  // containers
520  }
521  // insert vehicles
524 #ifdef HAVE_FOX
525  MSDevice_Routing::waitForAll();
526 #endif
529  //myEdges->patchActiveLanes(); // @note required to detect collisions on lanes that were empty before insertion. wasteful?
531  }
533 
534  // execute endOfTimestepEvents
536 
537 #ifndef NO_TRACI
538  if (TraCIServer::getInstance() != 0) {
539  if (myLogExecutionTime) {
541  }
543  if (myLogExecutionTime) {
545  }
546  }
547 #endif
548  // update and write (if needed) detector values
549  writeOutput();
550 
551  if (myLogExecutionTime) {
554  }
555  myStep += DELTA_T;
556 }
557 
558 
561 #ifndef NO_TRACI
562  if (TraCIServer::wasClosed()) {
564  }
565  if (TraCIServer::getInstance() != 0 && !TraCIServer::getInstance()->getLoadArgs().empty()) {
566  return SIMSTATE_LOADING;
567  }
568  if ((stopTime < 0 || myStep > stopTime) && TraCIServer::getInstance() == 0) {
569 #else
570  if (stopTime < 0 || myStep > stopTime) {
571 #endif
574  && (myInserter->getPendingFlowCount() == 0)
577  if (myPersonControl) {
579  }
580  if (myContainerControl) {
582  }
585  }
586  }
587  if (stopTime >= 0 && myStep >= stopTime) {
589  }
592  }
593  return SIMSTATE_RUNNING;
594 }
595 
596 
597 std::string
599  switch (state) {
601  return "";
603  return "The final simulation step has been reached.";
605  return "All vehicles have left the simulation.";
607  return "TraCI requested termination.";
609  return "An error occured (see log).";
611  return "Too many teleports.";
613  return "TraCI issued load command.";
614  default:
615  return "Unknown reason.";
616  }
617 }
618 
619 
620 void
622  // clear container
623  MSEdge::clear();
624  MSLane::clear();
625  MSRoute::clear();
634 #ifndef NO_TRACI
636  if (t != 0) {
637  t->cleanup();
638  }
640 #endif
641 }
642 
643 
644 void
646  // update detector values
648  const OptionsCont& oc = OptionsCont::getOptions();
649 
650  // check state dumps
651  if (oc.isSet("netstate-dump")) {
653  oc.getInt("netstate-dump.precision"));
654  }
655 
656  // check fcd dumps
657  if (OptionsCont::getOptions().isSet("fcd-output")) {
659  }
660 
661  // check emission dumps
662  if (OptionsCont::getOptions().isSet("emission-output")) {
664  oc.getInt("emission-output.precision"));
665  }
666 
667  // battery dumps
668  if (OptionsCont::getOptions().isSet("battery-output")) {
670  oc.getInt("battery-output.precision"));
671  }
672 
673  // check full dumps
674  if (OptionsCont::getOptions().isSet("full-output")) {
676  }
677 
678  // check queue dumps
679  if (OptionsCont::getOptions().isSet("queue-output")) {
681  }
682 
683  // check amitran dumps
684  if (OptionsCont::getOptions().isSet("amitran-output")) {
686  }
687 
688  // check vtk dumps
689  if (OptionsCont::getOptions().isSet("vtk-output")) {
690 
691  if (MSNet::getInstance()->getVehicleControl().getRunningVehicleNo() > 0) {
692  std::string timestep = time2string(myStep);
693  timestep = timestep.substr(0, timestep.length() - 3);
694  std::string output = OptionsCont::getOptions().getString("vtk-output");
695  std::string filename = output + "_" + timestep + ".vtp";
696 
697  OutputDevice_File dev = OutputDevice_File(filename, false);
698 
699  //build a huge mass of xml files
701 
702  }
703 
704  }
705 
706  // summary output
707  if (OptionsCont::getOptions().isSet("summary-output")) {
708  OutputDevice& od = OutputDevice::getDeviceByOption("summary-output");
709  int departedVehiclesNumber = myVehicleControl->getDepartedVehicleNo();
710  const double meanWaitingTime = departedVehiclesNumber != 0 ? myVehicleControl->getTotalDepartureDelay() / (double) departedVehiclesNumber : -1.;
711  int endedVehicleNumber = myVehicleControl->getEndedVehicleNo();
712  const double meanTravelTime = endedVehicleNumber != 0 ? myVehicleControl->getTotalTravelTime() / (double) endedVehicleNumber : -1.;
713  od.openTag("step");
714  od.writeAttr("time", time2string(myStep));
718  od.writeAttr("waiting", myInserter->getWaitingVehicleNo());
720  od.writeAttr("meanWaitingTime", meanWaitingTime);
721  od.writeAttr("meanTravelTime", meanTravelTime);
722  od.writeAttr("halting", getHaltingVehicleNumber());
723  std::pair<double, double> meanSpeed = getVehicleMeanSpeeds();
724  od.writeAttr("meanSpeed", meanSpeed.first);
725  od.writeAttr("meanSpeedRelative", meanSpeed.second);
726  if (myLogExecutionTime) {
727  od.writeAttr("duration", mySimStepDuration);
728  }
729  od.closeTag();
730  }
731 
732  // write detector values
734 
735  // write link states
736  if (OptionsCont::getOptions().isSet("link-output")) {
737  OutputDevice& od = OutputDevice::getDeviceByOption("link-output");
738  od.openTag("timestep");
740  const MSEdgeVector& edges = myEdges->getEdges();
741  for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
742  const std::vector<MSLane*>& lanes = (*i)->getLanes();
743  for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
744  const std::vector<MSLink*>& links = (*j)->getLinkCont();
745  for (std::vector<MSLink*>::const_iterator k = links.begin(); k != links.end(); ++k) {
746  (*k)->writeApproaching(od, (*j)->getID());
747  }
748  }
749  }
750  od.closeTag();
751  }
752 
753  // write SSM output
754  for (std::set<MSDevice*>::iterator di = MSDevice_SSM::getInstances().begin(); di != MSDevice_SSM::getInstances().end(); ++di) {
755  MSDevice_SSM* dev = static_cast<MSDevice_SSM*>(*di);
756  dev->updateAndWriteOutput();
757  }
758 }
759 
760 
761 bool
763  return myLogExecutionTime;
764 }
765 
766 
769  if (myPersonControl == 0) {
771  }
772  return *myPersonControl;
773 }
774 
777  if (myContainerControl == 0) {
779  }
780  return *myContainerControl;
781 }
782 
783 
786  if (myEdgeWeights == 0) {
788  }
789  return *myEdgeWeights;
790 }
791 
792 
793 void
795  std::cout << "Step #" << time2string(myStep);
796 }
797 
798 
799 void
801  if (myLogExecutionTime) {
802  std::ostringstream oss;
803  oss.setf(std::ios::fixed , std::ios::floatfield); // use decimal format
804  oss.setf(std::ios::showpoint); // print decimal point
805  oss << std::setprecision(gPrecision);
806  if (mySimStepDuration != 0) {
807  const double durationSec = (double)mySimStepDuration / 1000.;
808  oss << " (" << mySimStepDuration << "ms ~= "
809  << (TS / durationSec) << "*RT, ~"
810  << ((double) myVehicleControl->getRunningVehicleNo() / durationSec);
811  } else {
812  oss << " (0ms ?*RT. ?";
813  }
814  oss << "UPS, ";
815 #ifndef NO_TRACI
816  if (TraCIServer::getInstance() != 0) {
817  oss << "TraCI: " << myTraCIStepDuration << "ms, ";
818  }
819 #endif
820  oss << "vehicles TOT " << myVehicleControl->getDepartedVehicleNo()
821  << " ACT " << myVehicleControl->getRunningVehicleNo()
822  << " BUF " << myInserter->getWaitingVehicleNo()
823  << ") ";
824  std::string prev = "Step #" + time2string(myStep - DELTA_T);
825  std::cout << oss.str().substr(0, 78 - prev.length());
826  }
827  std::cout << '\r';
828 }
829 
830 
831 void
833  if (find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener) == myVehicleStateListeners.end()) {
834  myVehicleStateListeners.push_back(listener);
835  }
836 }
837 
838 
839 void
841  std::vector<VehicleStateListener*>::iterator i = find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener);
842  if (i != myVehicleStateListeners.end()) {
843  myVehicleStateListeners.erase(i);
844  }
845 }
846 
847 
848 void
850  for (std::vector<VehicleStateListener*>::iterator i = myVehicleStateListeners.begin(); i != myVehicleStateListeners.end(); ++i) {
851  (*i)->vehicleStateChanged(vehicle, to);
852  }
853 }
854 
855 
856 bool
858  return myStoppingPlaces[category == SUMO_TAG_TRAIN_STOP ? SUMO_TAG_BUS_STOP : category].add(stop->getID(), stop);
859 }
860 
861 
863 MSNet::getStoppingPlace(const std::string& id, const SumoXMLTag category) const {
864  if (myStoppingPlaces.count(category) > 0) {
865  return myStoppingPlaces.find(category)->second.get(id);
866  }
867  return 0;
868 }
869 
870 
871 std::string
872 MSNet::getStoppingPlaceID(const MSLane* lane, const double pos, const SumoXMLTag category) const {
873  if (myStoppingPlaces.count(category) > 0) {
874  for (const auto& it : myStoppingPlaces.find(category)->second) {
875  MSStoppingPlace* stop = it.second;
876  if (&stop->getLane() == lane && stop->getBeginLanePosition() <= pos && stop->getEndLanePosition() >= pos) {
877  return stop->getID();
878  }
879  }
880  }
881  return "";
882 }
883 
884 
885 void
888  OutputDevice& output = OutputDevice::getDeviceByOption("chargingstations-output");
889  for (const auto& it : myStoppingPlaces.find(SUMO_TAG_CHARGING_STATION)->second) {
890  static_cast<MSChargingStation*>(it.second)->writeChargingStationOutput(output);
891  }
892  }
893 }
894 
895 
897 MSNet::getRouterTT(const MSEdgeVector& prohibited) const {
898  if (myRouterTT == 0) {
899  const std::string routingAlgorithm = OptionsCont::getOptions().getString("routing-algorithm");
900  if (routingAlgorithm == "dijkstra") {
903  } else {
904  if (routingAlgorithm != "astar") {
905  WRITE_WARNING("TraCI and Triggers cannot use routing algorithm '" + routingAlgorithm + "'. using 'astar' instead.");
906  }
909  }
910  }
911  dynamic_cast<prohibited_withPermissions<MSEdge, SUMOVehicle>*>(myRouterTT)->prohibit(prohibited);
912  return *myRouterTT;
913 }
914 
915 
917 MSNet::getRouterEffort(const MSEdgeVector& prohibited) const {
918  if (myRouterEffort == 0) {
921  }
922  dynamic_cast<prohibited_withPermissions<MSEdge, SUMOVehicle>*>(myRouterEffort)->prohibit(prohibited);
923  return *myRouterEffort;
924 }
925 
926 
928 MSNet::getPedestrianRouter(const MSEdgeVector& prohibited) const {
929  if (myPedestrianRouter == 0) {
931  }
932  myPedestrianRouter->prohibit(prohibited);
933  return *myPedestrianRouter;
934 }
935 
936 
938 MSNet::getIntermodalRouter(const MSEdgeVector& prohibited) const {
939  if (myIntermodalRouter == 0) {
940  int carWalk = 0;
941  for (const std::string& opt : OptionsCont::getOptions().getStringVector("persontrip.transfer.car-walk")) {
942  if (opt == "parkingAreas") {
944  } else if (opt == "ptStops") {
945  carWalk |= MSIntermodalRouter::PT_STOPS;
946  } else if (opt == "allJunctions") {
948  }
949  }
951  }
952  myIntermodalRouter->prohibit(prohibited);
953  return *myIntermodalRouter;
954 }
955 
956 
957 void
959  // add access to all parking areas
960  for (const auto& i : myInstance->myStoppingPlaces[SUMO_TAG_PARKING_AREA]) {
961  router.addAccess(i.first, &i.second->getLane().getEdge(), i.second->getAccessPos(&i.second->getLane().getEdge()), SUMO_TAG_PARKING_AREA);
962  }
963  // add access to all public transport stops
964  for (const auto& i : myInstance->myStoppingPlaces[SUMO_TAG_BUS_STOP]) {
965  router.addAccess(i.first, &i.second->getLane().getEdge(), i.second->getAccessPos(&i.second->getLane().getEdge()), SUMO_TAG_BUS_STOP);
966  for (const auto& a : i.second->getAllAccessPos()) {
967  router.addAccess(i.first, &a.first->getEdge(), a.second, SUMO_TAG_BUS_STOP);
968  }
969  }
972 }
973 
974 
975 const NamedRTree&
977  if (!myLanesRTree.first) {
978  MSLane::fill(myLanesRTree.second);
979  myLanesRTree.first = true;
980  }
981  return myLanesRTree.second;
982 }
983 
984 
985 bool
987  const MSEdgeVector& edges = myEdges->getEdges();
988  for (MSEdgeVector::const_iterator e = edges.begin(); e != edges.end(); ++e) {
989  for (std::vector<MSLane*>::const_iterator i = (*e)->getLanes().begin(); i != (*e)->getLanes().end(); ++i) {
990  if ((*i)->getShape().hasElevation()) {
991  return true;
992  }
993  }
994  }
995  return false;
996 }
997 
998 
999 int
1001  int result = 0;
1003  const SUMOVehicle* veh = it->second;
1004  if ((veh->isOnRoad() || veh->isRemoteControlled()) && veh->getSpeed() < SUMO_const_haltingSpeed) {
1005  result++;
1006  }
1007  }
1008  return result;
1009 }
1010 
1011 
1012 std::pair<double, double>
1014  double speedSum = 0;
1015  double relSpeedSum = 0;
1016  int count = 0;
1018  const SUMOVehicle* veh = it->second;
1019  if ((veh->isOnRoad() || veh->isRemoteControlled()) && !veh->isStopped()) {
1020  count++;
1021  speedSum += veh->getSpeed();
1022  relSpeedSum += veh->getSpeed() / veh->getEdge()->getSpeedLimit();
1023  }
1024  }
1025  if (count > 0) {
1026  return std::make_pair(speedSum / count, relSpeedSum / count);
1027  } else {
1028  return std::make_pair(-1, -1);
1029  }
1030 }
1031 
1032 
1033 /****************************************************************************/
std::string myStateDumpSuffix
Definition: MSNet.h:702
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:54
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
static double gLateralResolution
Definition: MSGlobals.h:91
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:260
SumoXMLTag
Numbers representing SUMO-XML - element names.
int getEndedVehicleNo() const
Returns the number of removed vehicles.
static const std::set< MSDevice * > & getInstances()
returns all currently existing SSM devices
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
double getBeginLanePosition() const
Returns the begin position of this stop.
Interface for objects listening to vehicle state changes.
Definition: MSNet.h:509
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
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
void removeVehicleStateListener(VehicleStateListener *listener)
Removes a vehicle states listener.
Definition: MSNet.cpp:840
MSEventControl * myEndOfTimestepEvents
Controls events executed at the end of a time step;.
Definition: MSNet.h:659
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:863
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:872
static void cleanup()
Clean up remaining devices instances.
A lane area vehicles can halt at.
static void postProcessRemoteControl()
Definition: Helper.cpp:298
static void cleanup()
Definition: Helper.cpp:215
const NamedRTree & getLanesRTree() const
Returns an RTree that contains lane IDs.
Definition: MSNet.cpp:976
std::pair< double, double > getVehicleMeanSpeeds() const
get current absolute and relative mean vehicle speed in the network
Definition: MSNet.cpp:1013
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:1679
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
Definition: MSNet.h:641
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:29
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:62
std::vector< SUMOTime > myStateDumpTimes
Times at which a state shall be written.
Definition: MSNet.h:695
virtual void execute(SUMOTime time)
Executes time-dependant commands.
SimulationState simulate(SUMOTime start, SUMOTime stop)
Simulates from timestep start to stop.
Definition: MSNet.cpp:313
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
SUMOAbstractRouter< MSEdge, SUMOVehicle > * myRouterEffort
Definition: MSNet.h:737
bool logSimulationDuration() const
Returns whether duration shall be logged.
Definition: MSNet.cpp:762
void changeLanes(SUMOTime t)
Moves (precomputes) critical vehicles.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:59
std::map< SumoXMLTag, NamedObjectCont< MSStoppingPlace * > > myStoppingPlaces
Dictionary of bus / container stops.
Definition: MSNet.h:726
A RT-tree for efficient storing of SUMO&#39;s Named objects.
Definition: NamedRTree.h:71
Computes the shortest path through a network using the A* algorithm.
Definition: AStarRouter.h:84
MSIntermodalRouter * myIntermodalRouter
Definition: MSNet.h:739
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
MSPedestrianRouterDijkstra & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:928
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
Definition: MSNet.h:708
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
MSEdgeControl * myEdges
Controls edges, performs vehicle movement;.
Definition: MSNet.h:647
The final simulation step has been performed.
Definition: MSNet.h:101
MSIntermodalRouter & getIntermodalRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:938
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:723
std::vector< std::string > myStateDumpFiles
The names for the state files.
Definition: MSNet.h:697
bool myLogExecutionTime
Information whether the simulation duration shall be logged.
Definition: MSNet.h:674
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.
static const std::string STAGE_LANECHANGE
Definition: MSNet.h:749
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:74
std::vector< std::string > & getLoadArgs()
Definition: TraCIServer.h:269
#define TS
Definition: SUMOTime.h:51
Detectors container; responsible for string and output generation.
bool myLefthand
Whether the network was built for left-hand traffic.
Definition: MSNet.h:720
A storage for edge travel times and efforts.
void detectCollisions(SUMOTime timestep, const std::string &stage)
Detect collisions.
double getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
Definition: MSEdge.cpp:846
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition: MSNet.cpp:832
SimulationState
Possible states of a simulation - running or stopped with different reasons.
Definition: MSNet.h:95
bool addStoppingPlace(const SumoXMLTag category, MSStoppingPlace *stop)
Adds a stopping place.
Definition: MSNet.cpp:857
MSPedestrianRouterDijkstra * myPedestrianRouter
Definition: MSNet.h:738
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
The simulated network and simulation perfomer.
Definition: MSNet.h:90
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
Definition: OptionsIO.cpp:61
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
#define SIMTIME
Definition: SUMOTime.h:71
ShapeContainer * myShapeContainer
A container for geometrical shapes;.
Definition: MSNet.h:663
std::pair< bool, NamedRTree > myLanesRTree
An RTree structure holding lane IDs.
Definition: MSNet.h:743
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:82
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:776
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:54
void writeChargingStationOutput() const
write charging station output
Definition: MSNet.cpp:886
A class that stores and controls tls and switching of their programs.
A road/street connecting two junctions.
Definition: MSEdge.h:80
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double version() const
return the network version
Definition: MSNet.h:602
long long int myVehiclesMoved
The overall number of vehicle movements.
Definition: MSNet.h:686
double getEndLanePosition() const
Returns the end position of this stop.
The simulation does not contain further vehicles.
Definition: MSNet.h:103
int getHaltingVehicleNumber() const
count number of standing vehicles in the network
Definition: MSNet.cpp:1000
static void generateOutputForUnfinished()
generate output for vehicles which are still in the network
An error occured during the simulation step.
Definition: MSNet.h:107
double getTotalDepartureDelay() const
Returns the total departure delay.
static void clear()
Clears the dictionary (delete all known routes, too)
Definition: MSRoute.cpp:173
The main mesocopic simulation loop.
Definition: MELoop.h:55
void writeOutput()
Write netstate, summary and detector output.
Definition: MSNet.cpp:645
void addAccess(const std::string &stopId, const E *stopEdge, const double pos, const SumoXMLTag category)
Adds access edges for stopping places to the intermodal network.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
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:560
static std::string printStatistics()
get statistics for printing to stdout
MSInsertionControl * myInserter
Controls vehicle insertion;.
Definition: MSNet.h:653
Representation of a vehicle.
Definition: SUMOVehicle.h:66
void checkInsertions(SUMOTime time)
Checks "movement" of stored vehicles.
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:627
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:768
void prohibit(const std::vector< E *> &toProhibit)
static double getTravelTime(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the travel time to pass an edge.
Definition: MSNet.cpp:150
void closeSimulation(SUMOTime start)
Closes the simulation (all files, connections, etc.)
Definition: MSNet.cpp:372
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
Definition: MSNet.h:711
bool myLogStepNumber
Information whether the number of the simulation step shall be logged.
Definition: MSNet.h:677
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:783
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:306
SUMOTime getTargetTime() const
Definition: TraCIServer.h:75
MSDetectorControl * myDetectorControl
Controls detectors;.
Definition: MSNet.h:655
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:800
double getMinimumTravelTime(const SUMOVehicle *const veh) const
returns the minimum travel time for the given vehicle
Definition: MSEdge.h:413
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:73
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:303
#define STEPS2TIME(x)
Definition: SUMOTime.h:64
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
Definition: MSNet.h:651
static void write(OutputDevice &of, SUMOTime timestep)
Produce a VTK output to use with Tools like ParaView.
Definition: MSVTKExport.cpp:49
The connection to a client was closed by the client.
Definition: MSNet.h:105
virtual bool isRemoteControlled() const =0
Returns the information whether the vehicle is fully controlled via TraCI.
The simulation is running.
Definition: MSNet.h:99
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:253
int getEmergencyStops() const
return the number of emergency stops
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:46
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:297
bool hasInternalLinks() const
return whether the network contains internal links
Definition: MSNet.h:587
bool hasTransportables() const
checks whether any transportable waits to finish her plan
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
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:95
static void cleanup()
properly deletes all trigger instances
Definition: MSTrigger.cpp:46
PedestrianRouterDijkstra< MSEdge, MSLane, MSJunction, MSVehicle > MSPedestrianRouterDijkstra
Definition: MSNet.h:113
double getTotalTravelTime() const
Returns the total travel time.
TraCI server used to control sumo by a remote TraCI client.
Definition: TraCIServer.h:69
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:597
public transport stops and access
SUMOTime myStateDumpPeriod
The period for writing state.
Definition: MSNet.h:699
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:680
void postloadInitContainer()
Closes building of junctions.
int myMaxTeleports
Maximum number of teleports.
Definition: MSNet.h:633
void abortWaiting()
informes about all waiting vehicles (deletion in destructor)
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:482
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:219
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
static const std::string STAGE_MOVEMENTS
Definition: MSNet.h:748
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:729
static MSNet * myInstance
Unique instance of MSNet.
Definition: MSNet.h:624
bool isEmpty()
Returns whether events are in the que.
static void clearAll()
Clears all dictionaries.
Definition: MSNet.cpp:621
The simulation is loading.
Definition: MSNet.h:97
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:645
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
Definition: MSNet.h:649
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:359
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:1662
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:643
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:777
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:986
int getPendingFlowCount() const
Returns the number of flows that are still active.
static void cleanup()
remove state at simulation end
Definition: MSPModel.cpp:88
void preSimStepOutput() const
Prints the current step number.
Definition: MSNet.cpp:794
static TraCIServer * getInstance()
Definition: TraCIServer.h:81
MSEventControl * myBeginOfTimestepEvents
Controls events executed at the begin of a time step;.
Definition: MSNet.h:657
A storage for options typed value containers)
Definition: OptionsCont.h:98
static void cleanup()
removes remaining vehicleInformation in sVehicles
MSEdgeWeightsStorage * myEdgeWeights
The net&#39;s knowledge about edge efforts/travel times;.
Definition: MSNet.h:665
The simulation had too many teleports.
Definition: MSNet.h:109
MSNet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents, ShapeContainer *shapeCont=0)
Constructor.
Definition: MSNet.cpp:175
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:112
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to)
Informs all added listeners about a vehicle&#39;s state change.
Definition: MSNet.cpp:849
static void cleanup()
cleanup remaining data structures
const MSEdgeVector & getEdges() const
Returns loaded edges.
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:57
void prohibit(const std::vector< E *> &toProhibit)
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle&#39;s internal edge travel times/efforts container.
Definition: MSVehicle.cpp:817
long mySimBeginMillis
The overall simulation duration.
Definition: MSNet.h:683
virtual ~MSNet()
Destructor.
Definition: MSNet.cpp:256
bool myHasElevation
Whether the network contains elevation data.
Definition: MSNet.h:717
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:701
virtual bool isStopped() const =0
Returns whether the vehicle is at a stop.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
bool closeTag()
Closes the most recently opened tag.
static std::string getStateMessage(SimulationState state)
Returns the message to show if a certain state occurs.
Definition: MSNet.cpp:598
long long int SUMOTime
Definition: TraCIDefs.h:51
IntermodalRouter< MSEdge, MSLane, MSJunction, SUMOVehicle > MSIntermodalRouter
Definition: MSNet.h:114
bool isEmbedded() const
Definition: TraCIServer.h:78
SUMOTime myStep
Current time step.
Definition: MSNet.h:630
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:897
The class responsible for building and deletion of vehicles.
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:77
int getDepartedVehicleNo() const
Returns the number of inserted vehicles.
void simulationStep()
Performs a single simulation step.
Definition: MSNet.cpp:439
static long getCurrentMillis()
Returns the current time in milliseconds.
Definition: SysUtils.cpp:45
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:69
void loadRoutes()
loads routes for the next few steps
Definition: MSNet.cpp:366
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:200
static const std::string STAGE_INSERTIONS
Definition: MSNet.h:750
virtual double getSpeed() const =0
Returns the vehicle&#39;s current speed.
MSEventControl * myInsertionEvents
Controls insertion events;.
Definition: MSNet.h:661
static bool gUseMesoSim
Definition: MSGlobals.h:97
int getCollisionCount() const
return the number of collisions
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
long mySimStepDuration
Definition: MSNet.h:680
static bool wasClosed()
check whether close was requested
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterEffort(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:917
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:714
junctions with edges allowing the additional mode
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:236
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
SUMOAbstractRouter< MSEdge, SUMOVehicle > * myRouterTT
Definition: MSNet.h:736
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
static void adaptIntermodalRouter(MSIntermodalRouter &router)
Definition: MSNet.cpp:958
static void cleanup()
remove state at simulation end
void determineCandidates(SUMOTime time)
Checks for all vehicles whether they can be emitted.
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:136
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net&#39;s internal edge travel times/efforts container.
Definition: MSNet.cpp:785
static const std::string STAGE_EVENTS
string constants for simstep stages
Definition: MSNet.h:747
int getJammedNumber() const
Returns the number of times a transportables was jammed.