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 #ifdef HAVE_VERSION_H
33 #include <version.h>
34 #endif
35 
36 #include <string>
37 #include <iostream>
38 #include <sstream>
39 #include <typeinfo>
40 #include <algorithm>
41 #include <cassert>
42 #include <vector>
43 #include <ctime>
44 
45 #include "trigger/MSTrigger.h"
46 #include "trigger/MSCalibrator.h"
48 #include "MSVehicleControl.h"
50 #include <utils/common/ToString.h>
51 #include <utils/common/SysUtils.h>
66 #include <utils/xml/XMLSubSys.h>
68 #include <libsumo/Simulation.h>
69 #include <mesosim/MELoop.h>
92 
93 #include "MSTransportableControl.h"
94 #include "MSEdgeControl.h"
95 #include "MSJunctionControl.h"
96 #include "MSInsertionControl.h"
97 #include "MSEventControl.h"
98 #include "MSEdge.h"
99 #include "MSJunction.h"
100 #include "MSJunctionLogic.h"
101 #include "MSLane.h"
102 #include "MSVehicleTransfer.h"
103 #include "MSRoute.h"
104 #include "MSGlobals.h"
105 #include "MSContainer.h"
106 #include "MSEdgeWeightsStorage.h"
107 #include "MSStateHandler.h"
108 #include "MSFrame.h"
109 #include "MSParkingArea.h"
110 #include "MSStoppingPlace.h"
111 #include "MSNet.h"
112 
113 
114 // ===========================================================================
115 // debug constants
116 // ===========================================================================
117 //#define DEBUG_SIMSTEP
118 
119 
120 // ===========================================================================
121 // static member definitions
122 // ===========================================================================
123 MSNet* MSNet::myInstance = nullptr;
124 
125 const std::string MSNet::STAGE_EVENTS("events");
126 const std::string MSNet::STAGE_MOVEMENTS("move");
127 const std::string MSNet::STAGE_LANECHANGE("laneChange");
128 const std::string MSNet::STAGE_INSERTIONS("insertion");
129 
130 // ===========================================================================
131 // static member method definitions
132 // ===========================================================================
133 double
134 MSNet::getEffort(const MSEdge* const e, const SUMOVehicle* const v, double t) {
135  double value;
136  const MSVehicle* const veh = dynamic_cast<const MSVehicle* const>(v);
137  if (veh != nullptr && veh->getWeightsStorage().retrieveExistingEffort(e, t, value)) {
138  return value;
139  }
140  if (getInstance()->getWeightsStorage().retrieveExistingEffort(e, t, value)) {
141  return value;
142  }
143  return 0;
144 }
145 
146 
147 double
148 MSNet::getTravelTime(const MSEdge* const e, const SUMOVehicle* const v, double t) {
149  double value;
150  const MSVehicle* const veh = dynamic_cast<const MSVehicle* const>(v);
151  if (veh != nullptr && veh->getWeightsStorage().retrieveExistingTravelTime(e, t, value)) {
152  return value;
153  }
155  return value;
156  }
157  return e->getMinimumTravelTime(v);
158 }
159 
160 
161 // ---------------------------------------------------------------------------
162 // MSNet - methods
163 // ---------------------------------------------------------------------------
164 MSNet*
166  if (myInstance != nullptr) {
167  return myInstance;
168  }
169  throw ProcessError("A network was not yet constructed.");
170 }
171 
172 
173 MSNet::MSNet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
174  MSEventControl* endOfTimestepEvents,
175  MSEventControl* insertionEvents,
176  ShapeContainer* shapeCont):
177  myAmInterrupted(false),
178  myVehiclesMoved(0),
179  myHavePermissions(false),
180  myHasInternalLinks(false),
181  myHasElevation(false),
182  myRouterTT(nullptr),
183  myRouterEffort(nullptr),
184  myPedestrianRouter(nullptr) {
185  if (myInstance != nullptr) {
186  throw ProcessError("A network was already constructed.");
187  }
189  myStep = string2time(oc.getString("begin"));
190  myMaxTeleports = oc.getInt("max-num-teleports");
191  myLogExecutionTime = !oc.getBool("no-duration-log");
192  myLogStepNumber = !oc.getBool("no-step-log");
193  myInserter = new MSInsertionControl(*vc, string2time(oc.getString("max-depart-delay")), oc.getBool("eager-insert"), oc.getInt("max-num-vehicles"),
194  string2time(oc.getString("random-depart-offset")));
195  myVehicleControl = vc;
197  myEdges = nullptr;
198  myJunctions = nullptr;
199  myRouteLoaders = nullptr;
200  myLogics = nullptr;
201  myPersonControl = nullptr;
202  myContainerControl = nullptr;
203  myEdgeWeights = nullptr;
204  myShapeContainer = shapeCont == nullptr ? 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
245  if (hasNeighs && MSGlobals::gLateralResolution > 0) {
246  WRITE_WARNING("Opposite direction driving does not work together with the sublane model.");
247  }
250  myVersion = version;
251 }
252 
253 
255  // delete controls
256  delete myJunctions;
257  delete myDetectorControl;
258  // delete mean data
259  delete myEdges;
260  delete myInserter;
261  delete myLogics;
262  delete myRouteLoaders;
263  if (myPersonControl != nullptr) {
264  delete myPersonControl;
265  }
266  if (myContainerControl != nullptr) {
267  delete myContainerControl;
268  }
269  delete myVehicleControl; // must happen after deleting transportables
270  // delete events late so that vehicles can get rid of references first
272  myBeginOfTimestepEvents = nullptr;
273  delete myEndOfTimestepEvents;
274  myEndOfTimestepEvents = nullptr;
275  delete myInsertionEvents;
276  myInsertionEvents = nullptr;
277  delete myShapeContainer;
278  delete myEdgeWeights;
279  delete myRouterTT;
280  delete myRouterEffort;
281  delete myPedestrianRouter;
282  for (auto& router : myIntermodalRouter) {
283  delete router.second;
284  }
285  myIntermodalRouter.clear();
286  myLanesRTree.second.RemoveAll();
287  clearAll();
289  delete MSGlobals::gMesoNet;
290  }
291  myInstance = nullptr;
292 }
293 
294 
295 void
296 MSNet::addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
297  myRestrictions[id][svc] = speed;
298 }
299 
300 
301 const std::map<SUMOVehicleClass, double>*
302 MSNet::getRestrictions(const std::string& id) const {
303  std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i = myRestrictions.find(id);
304  if (i == myRestrictions.end()) {
305  return nullptr;
306  }
307  return &i->second;
308 }
309 
310 
313  // report the begin when wished
314  WRITE_MESSAGE("Simulation version " + std::string(VERSION_STRING) + " started with time: " + time2string(start));
315  // the simulation loop
317  // state loading may have changed the start time so we need to reinit it
318  myStep = start;
319 #ifdef HAVE_PYTHON
320  if (OptionsCont::getOptions().isSet("python-script")) {
321  TraCIServer::runEmbedded(OptionsCont::getOptions().getString("python-script"));
322  closeSimulation(start);
323  WRITE_MESSAGE("Simulation ended at time: " + time2string(getCurrentTimeStep()));
324  WRITE_MESSAGE("Reason: Script ended");
325  return state;
326  }
327 #endif
328  while (state == SIMSTATE_RUNNING) {
329  if (myLogStepNumber) {
331  }
332  simulationStep();
333  if (myLogStepNumber) {
335  }
336  state = simulationState(stop);
337 #ifdef DEBUG_SIMSTEP
338  std::cout << SIMTIME << " MSNet::simulate(" << start << ", " << stop << ")"
339  << "\n simulation state: " << getStateMessage(state)
340  << std::endl;
341 #endif
342  if (state == SIMSTATE_LOADING) {
345  } else if (state != SIMSTATE_RUNNING) {
346  if (TraCIServer::getInstance() != nullptr && !TraCIServer::wasClosed()) {
347  // overrides SIMSTATE_END_STEP_REACHED, e.g. (TraCI ignore SUMO's --end option)
348  state = SIMSTATE_RUNNING;
349  }
350  }
351  }
352  // report the end when wished
353  WRITE_MESSAGE("Simulation ended at time: " + time2string(getCurrentTimeStep()));
354  WRITE_MESSAGE("Reason: " + getStateMessage(state));
355  // exit simulation loop
356  closeSimulation(start);
357  return state;
358 }
359 
360 
361 void
364 }
365 
366 
367 const std::string
369  long duration = SysUtils::getCurrentMillis() - mySimBeginMillis;
370  std::ostringstream msg;
371  // print performance notice
372  msg << "Performance: " << "\n" << " Duration: " << duration << "ms" << "\n";
373  if (duration != 0) {
374  msg << " Real time factor: " << (STEPS2TIME(myStep - start) * 1000. / (double)duration) << "\n";
375  msg.setf(std::ios::fixed , std::ios::floatfield); // use decimal format
376  msg.setf(std::ios::showpoint); // print decimal point
377  msg << " UPS: " << ((double)myVehiclesMoved / ((double)duration / 1000)) << "\n";
378  }
379  // print vehicle statistics
380  const std::string discardNotice = ((myVehicleControl->getLoadedVehicleNo() != myVehicleControl->getDepartedVehicleNo()) ?
381  " (Loaded: " + toString(myVehicleControl->getLoadedVehicleNo()) + ")" : "");
382  msg << "Vehicles: " << "\n"
383  << " Inserted: " << myVehicleControl->getDepartedVehicleNo() << discardNotice << "\n"
384  << " Running: " << myVehicleControl->getRunningVehicleNo() << "\n"
385  << " Waiting: " << myInserter->getWaitingVehicleNo() << "\n";
386 
388  // print optional teleport statistics
389  std::vector<std::string> reasons;
390  if (myVehicleControl->getCollisionCount() > 0) {
391  reasons.push_back("Collisions: " + toString(myVehicleControl->getCollisionCount()));
392  }
393  if (myVehicleControl->getTeleportsJam() > 0) {
394  reasons.push_back("Jam: " + toString(myVehicleControl->getTeleportsJam()));
395  }
396  if (myVehicleControl->getTeleportsYield() > 0) {
397  reasons.push_back("Yield: " + toString(myVehicleControl->getTeleportsYield()));
398  }
400  reasons.push_back("Wrong Lane: " + toString(myVehicleControl->getTeleportsWrongLane()));
401  }
402  msg << "Teleports: " << myVehicleControl->getTeleportCount() << " (" << joinToString(reasons, ", ") << ")\n";
403  }
404  if (myVehicleControl->getEmergencyStops() > 0) {
405  msg << "Emergency Stops: " << myVehicleControl->getEmergencyStops() << "\n";
406  }
407  if (myPersonControl != nullptr && myPersonControl->getLoadedNumber() > 0) {
408  msg << "Persons: " << "\n"
409  << " Inserted: " << myPersonControl->getLoadedNumber() << "\n"
410  << " Running: " << myPersonControl->getRunningNumber() << "\n";
411  if (myPersonControl->getJammedNumber() > 0) {
412  msg << " Jammed: " << myPersonControl->getJammedNumber() << "\n";
413  }
414  }
415  if (OptionsCont::getOptions().getBool("duration-log.statistics")) {
417  }
418  return msg.str();
419 }
420 
421 
422 void
425  if (OptionsCont::getOptions().getBool("vehroute-output.write-unfinished")) {
427  }
428  if (OptionsCont::getOptions().getBool("tripinfo-output.write-unfinished")) {
430  }
431  if (OptionsCont::getOptions().isSet("chargingstations-output")) {
433  }
434  if (myLogExecutionTime) {
436  }
437 }
438 
439 
440 void
442 #ifdef DEBUG_SIMSTEP
443  std::cout << SIMTIME << ": MSNet::simulationStep() called"
444  << ", myStep = " << myStep
445  << std::endl;
446 #endif
447  if (myLogExecutionTime) {
449  }
451  if (t != nullptr && !t->isEmbedded()) {
453 #ifdef DEBUG_SIMSTEP
454  bool loadRequested = !TraCI::getLoadArgs().empty();
455  bool closed = TraCIServer::wasClosed();
456  assert(t->getTargetTime() >= myStep || loadRequested || closed);
457 #endif
458  }
459  if (myLogExecutionTime) {
461  }
462 #ifdef DEBUG_SIMSTEP
463  std::cout << SIMTIME << ": TraCI target time: " << t->getTargetTime() << std::endl;
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  MSRoutingEngine::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  // register junction approaches based on planned velocities as basis for right-of-way decision
500 
501  // decide right-of-way and execute movements
505  }
506 
507  // vehicles may change lanes
509 
512  }
513  }
514  loadRoutes();
515 
516  // persons
517  if (myPersonControl != nullptr && myPersonControl->hasTransportables()) {
519  }
520  // containers
523  }
524  // insert vehicles
527 #ifdef HAVE_FOX
528  MSRoutingEngine::waitForAll();
529 #endif
532  //myEdges->patchActiveLanes(); // @note required to detect collisions on lanes that were empty before insertion. wasteful?
534  }
536 
537  // execute endOfTimestepEvents
539 
540  if (myLogExecutionTime) {
542  }
544  if (myLogExecutionTime) {
546  }
547  // update and write (if needed) detector values
548  writeOutput();
549 
550  if (myLogExecutionTime) {
553  }
554  myStep += DELTA_T;
555 }
556 
557 
560  if (TraCIServer::wasClosed()) {
562  }
563  if (TraCIServer::getInstance() != nullptr && !TraCIServer::getInstance()->getLoadArgs().empty()) {
564  return SIMSTATE_LOADING;
565  }
566  if ((stopTime < 0 || myStep > stopTime) && TraCIServer::getInstance() == nullptr) {
568  && (myInserter->getPendingFlowCount() == 0)
569  && (myPersonControl == nullptr || !myPersonControl->hasNonWaiting())
570  && (myContainerControl == nullptr || !myContainerControl->hasNonWaiting())) {
571  if (myPersonControl) {
573  }
574  if (myContainerControl) {
576  }
579  }
580  }
581  if (stopTime >= 0 && myStep >= stopTime) {
583  }
586  }
587  if (myAmInterrupted) {
588  return SIMSTATE_INTERRUPTED;
589  }
590  return SIMSTATE_RUNNING;
591 }
592 
593 
594 std::string
596  switch (state) {
598  return "";
600  return "The final simulation step has been reached.";
602  return "All vehicles have left the simulation.";
604  return "TraCI requested termination.";
606  return "An error occurred (see log).";
608  return "Interrupted.";
610  return "Too many teleports.";
612  return "TraCI issued load command.";
613  default:
614  return "Unknown reason.";
615  }
616 }
617 
618 
619 void
621  // clear container
622  MSEdge::clear();
623  MSLane::clear();
624  MSRoute::clear();
636  if (t != nullptr) {
637  t->cleanup();
638  }
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);
723  std::pair<double, double> meanSpeed = myVehicleControl->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_SSM*>::iterator di = MSDevice_SSM::getInstances().begin(); di != MSDevice_SSM::getInstances().end(); ++di) {
755  MSDevice_SSM* dev = (*di);
756  dev->updateAndWriteOutput();
757  }
758 
759  // write ToC output
760  for (std::set<MSDevice_ToC*>::iterator di = MSDevice_ToC::getInstances().begin(); di != MSDevice_ToC::getInstances().end(); ++di) {
761  MSDevice_ToC* dev = (*di);
762  if (dev->generatesOutput()) {
763  dev->writeOutput();
764  }
765  }
766 }
767 
768 
769 bool
771  return myLogExecutionTime;
772 }
773 
774 
777  if (myPersonControl == nullptr) {
779  }
780  return *myPersonControl;
781 }
782 
785  if (myContainerControl == nullptr) {
787  }
788  return *myContainerControl;
789 }
790 
791 
794  if (myEdgeWeights == nullptr) {
796  }
797  return *myEdgeWeights;
798 }
799 
800 
801 void
803  std::cout << "Step #" << time2string(myStep);
804 }
805 
806 
807 void
809  if (myLogExecutionTime) {
810  std::ostringstream oss;
811  oss.setf(std::ios::fixed , std::ios::floatfield); // use decimal format
812  oss.setf(std::ios::showpoint); // print decimal point
813  oss << std::setprecision(gPrecision);
814  if (mySimStepDuration != 0) {
815  const double durationSec = (double)mySimStepDuration / 1000.;
816  oss << " (" << mySimStepDuration << "ms ~= "
817  << (TS / durationSec) << "*RT, ~"
818  << ((double) myVehicleControl->getRunningVehicleNo() / durationSec);
819  } else {
820  oss << " (0ms ?*RT. ?";
821  }
822  oss << "UPS, ";
823  if (TraCIServer::getInstance() != nullptr) {
824  oss << "TraCI: " << myTraCIStepDuration << "ms, ";
825  }
826  oss << "vehicles TOT " << myVehicleControl->getDepartedVehicleNo()
827  << " ACT " << myVehicleControl->getRunningVehicleNo()
828  << " BUF " << myInserter->getWaitingVehicleNo()
829  << ") ";
830  std::string prev = "Step #" + time2string(myStep - DELTA_T);
831  std::cout << oss.str().substr(0, 78 - prev.length());
832  }
833  std::cout << '\r';
834 }
835 
836 
837 void
839  if (find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener) == myVehicleStateListeners.end()) {
840  myVehicleStateListeners.push_back(listener);
841  }
842 }
843 
844 
845 void
847  std::vector<VehicleStateListener*>::iterator i = find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener);
848  if (i != myVehicleStateListeners.end()) {
849  myVehicleStateListeners.erase(i);
850  }
851 }
852 
853 
854 void
855 MSNet::informVehicleStateListener(const SUMOVehicle* const vehicle, VehicleState to, const std::string& info) {
856  for (std::vector<VehicleStateListener*>::iterator i = myVehicleStateListeners.begin(); i != myVehicleStateListeners.end(); ++i) {
857  (*i)->vehicleStateChanged(vehicle, to, info);
858  }
859 }
860 
861 
862 bool
864  return myStoppingPlaces[category == SUMO_TAG_TRAIN_STOP ? SUMO_TAG_BUS_STOP : category].add(stop->getID(), stop);
865 }
866 
867 
869 MSNet::getStoppingPlace(const std::string& id, const SumoXMLTag category) const {
870  if (myStoppingPlaces.count(category) > 0) {
871  return myStoppingPlaces.find(category)->second.get(id);
872  }
873  return nullptr;
874 }
875 
876 
877 std::string
878 MSNet::getStoppingPlaceID(const MSLane* lane, const double pos, const SumoXMLTag category) const {
879  if (myStoppingPlaces.count(category) > 0) {
880  for (const auto& it : myStoppingPlaces.find(category)->second) {
881  MSStoppingPlace* stop = it.second;
882  if (&stop->getLane() == lane && stop->getBeginLanePosition() - POSITION_EPS <= pos && stop->getEndLanePosition() + POSITION_EPS >= pos) {
883  return stop->getID();
884  }
885  }
886  }
887  return "";
888 }
889 
890 
891 void
894  OutputDevice& output = OutputDevice::getDeviceByOption("chargingstations-output");
895  for (const auto& it : myStoppingPlaces.find(SUMO_TAG_CHARGING_STATION)->second) {
896  static_cast<MSChargingStation*>(it.second)->writeChargingStationOutput(output);
897  }
898  }
899 }
900 
901 
903 MSNet::getRouterTT(const MSEdgeVector& prohibited) const {
904  if (myRouterTT == nullptr) {
905  const std::string routingAlgorithm = OptionsCont::getOptions().getString("routing-algorithm");
906  if (routingAlgorithm == "dijkstra") {
909  } else {
910  if (routingAlgorithm != "astar") {
911  WRITE_WARNING("TraCI and Triggers cannot use routing algorithm '" + routingAlgorithm + "'. using 'astar' instead.");
912  }
915  }
916  }
917  dynamic_cast<SUMOAbstractRouterPermissions<MSEdge, SUMOVehicle>*>(myRouterTT)->prohibit(prohibited);
918  return *myRouterTT;
919 }
920 
921 
923 MSNet::getRouterEffort(const MSEdgeVector& prohibited) const {
924  if (myRouterEffort == nullptr) {
927  }
928  dynamic_cast<SUMOAbstractRouterPermissions<MSEdge, SUMOVehicle>*>(myRouterEffort)->prohibit(prohibited);
929  return *myRouterEffort;
930 }
931 
932 
934 MSNet::getPedestrianRouter(const MSEdgeVector& prohibited) const {
935  if (myPedestrianRouter == nullptr) {
937  }
938  myPedestrianRouter->prohibit(prohibited);
939  return *myPedestrianRouter;
940 }
941 
942 
944 MSNet::getIntermodalRouter(const int routingMode, const MSEdgeVector& prohibited) const {
945  if (myIntermodalRouter.count(routingMode) == 0) {
946  int carWalk = 0;
947  for (const std::string& opt : OptionsCont::getOptions().getStringVector("persontrip.transfer.car-walk")) {
948  if (opt == "parkingAreas") {
950  } else if (opt == "ptStops") {
952  } else if (opt == "allJunctions") {
954  }
955  }
956  const std::string routingAlgorithm = OptionsCont::getOptions().getString("routing-algorithm");
957  if (routingMode == ROUTING_MODE_COMBINED) {
958  // replace nullptr here by your EffortCalculator
959  myIntermodalRouter[routingMode] = new MSIntermodalRouter(MSNet::adaptIntermodalRouter, carWalk, routingAlgorithm, routingMode, nullptr);
960  } else {
961  myIntermodalRouter[routingMode] = new MSIntermodalRouter(MSNet::adaptIntermodalRouter, carWalk, routingAlgorithm, routingMode);
962  }
963  }
964  myIntermodalRouter[routingMode]->prohibit(prohibited);
965  return *myIntermodalRouter[routingMode];
966 }
967 
968 
969 void
971  // add access to all parking areas
972  for (const auto& i : myInstance->myStoppingPlaces[SUMO_TAG_PARKING_AREA]) {
973  const MSEdge* const edge = &i.second->getLane().getEdge();
974  router.getNetwork()->addAccess(i.first, edge, i.second->getAccessPos(edge), i.second->getAccessDistance(edge), SUMO_TAG_PARKING_AREA);
975  }
976  // add access to all public transport stops
977  for (const auto& i : myInstance->myStoppingPlaces[SUMO_TAG_BUS_STOP]) {
978  const MSEdge* const edge = &i.second->getLane().getEdge();
979  router.getNetwork()->addAccess(i.first, edge, i.second->getAccessPos(edge), i.second->getAccessDistance(edge), SUMO_TAG_BUS_STOP);
980  for (const auto& a : i.second->getAllAccessPos()) {
981  router.getNetwork()->addAccess(i.first, &std::get<0>(a)->getEdge(), std::get<1>(a), std::get<2>(a), SUMO_TAG_BUS_STOP);
982  }
983  }
986 }
987 
988 
989 const NamedRTree&
991  if (!myLanesRTree.first) {
992  MSLane::fill(myLanesRTree.second);
993  myLanesRTree.first = true;
994  }
995  return myLanesRTree.second;
996 }
997 
998 
999 bool
1001  const MSEdgeVector& edges = myEdges->getEdges();
1002  for (MSEdgeVector::const_iterator e = edges.begin(); e != edges.end(); ++e) {
1003  for (std::vector<MSLane*>::const_iterator i = (*e)->getLanes().begin(); i != (*e)->getLanes().end(); ++i) {
1004  if ((*i)->getShape().hasElevation()) {
1005  return true;
1006  }
1007  }
1008  }
1009  return false;
1010 }
1011 
1012 
1013 bool
1014 MSNet::warnOnce(const std::string& typeAndID) {
1015  if (myWarnedOnce.find(typeAndID) == myWarnedOnce.end()) {
1016  myWarnedOnce[typeAndID] = true;
1017  return true;
1018  }
1019  return false;
1020 }
1021 
1022 /****************************************************************************/
std::string myStateDumpSuffix
Definition: MSNet.h:723
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:525
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:855
void removeVehicleStateListener(VehicleStateListener *listener)
Removes a vehicle states listener.
Definition: MSNet.cpp:846
MSPedestrianRouter * myPedestrianRouter
Definition: MSNet.h:761
MSEventControl * myEndOfTimestepEvents
Controls events executed at the end of a time step;.
Definition: MSNet.h:680
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:869
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:878
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:1014
const NamedRTree & getLanesRTree() const
Returns an RTree that contains lane IDs.
Definition: MSNet.cpp:990
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:1770
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
Definition: MSNet.h:662
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:716
virtual void execute(SUMOTime time)
Executes time-dependant commands.
SimulationState simulate(SUMOTime start, SUMOTime stop)
Simulates from timestep start to stop.
Definition: MSNet.cpp:312
SUMOAbstractRouter< MSEdge, SUMOVehicle > * myRouterEffort
Definition: MSNet.h:760
bool logSimulationDuration() const
Returns whether duration shall be logged.
Definition: MSNet.cpp:770
MSIntermodalRouter & getIntermodalRouter(const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:944
void changeLanes(SUMOTime t)
Moves (precomputes) critical vehicles.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:65
std::map< SumoXMLTag, NamedObjectCont< MSStoppingPlace * > > myStoppingPlaces
Dictionary of bus / container stops.
Definition: MSNet.h:747
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:78
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:165
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:729
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
MSEdgeControl * myEdges
Controls edges, performs vehicle movement;.
Definition: MSNet.h:668
The final simulation step has been performed.
Definition: MSNet.h:95
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:744
std::vector< std::string > myStateDumpFiles
The names for the state files.
Definition: MSNet.h:718
static void cleanup()
Definition: Helper.cpp:314
bool myLogExecutionTime
Information whether the simulation duration shall be logged.
Definition: MSNet.h:695
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:772
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:78
std::vector< std::string > & getLoadArgs()
Definition: TraCIServer.h:252
#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:741
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:762
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition: MSNet.cpp:838
SimulationState
Possible states of a simulation - running or stopped with different reasons.
Definition: MSNet.h:89
bool addStoppingPlace(const SumoXMLTag category, MSStoppingPlace *stop)
Adds a stopping place.
Definition: MSNet.cpp:863
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:241
The simulated network and simulation perfomer.
Definition: MSNet.h:84
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:684
std::pair< bool, NamedRTree > myLanesRTree
An RTree structure holding lane IDs.
Definition: MSNet.h:766
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!)
void setJunctionApproaches(SUMOTime t)
Register junction approaches for all vehicles after velocities have been planned. This is a prerequis...
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:784
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:892
A class that stores and controls tls and switching of their programs.
static void cleanup()
Closes root tags of output files.
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:707
double getEndLanePosition() const
Returns the end position of this stop.
The simulation does not contain further vehicles.
Definition: MSNet.h:97
static void generateOutputForUnfinished()
generate output for vehicles which are still in the network
An error occurred during the simulation step.
Definition: MSNet.h:101
double getTotalDepartureDelay() const
Returns the total departure delay.
static void clear()
Clears the dictionary (delete all known routes, too)
Definition: MSRoute.cpp:170
bool myAmInterrupted
whether an interrupt occured
Definition: MSNet.h:654
The main mesocopic simulation loop.
Definition: MELoop.h:49
void writeOutput()
Write netstate, summary and detector output.
Definition: MSNet.cpp:645
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:559
static std::string printStatistics()
get statistics for printing to stdout
MSInsertionControl * myInserter
Controls vehicle insertion;.
Definition: MSNet.h:674
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:645
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:776
static double getTravelTime(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the travel time to pass an edge.
Definition: MSNet.cpp:148
void closeSimulation(SUMOTime start)
Closes the simulation (all files, connections, etc.)
Definition: MSNet.cpp:423
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
Definition: MSNet.h:732
bool myLogStepNumber
Information whether the number of the simulation step shall be logged.
Definition: MSNet.h:698
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:827
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:316
SUMOTime getTargetTime() const
Definition: TraCIServer.h:67
MSDetectorControl * myDetectorControl
Controls detectors;.
Definition: MSNet.h:676
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:808
double getMinimumTravelTime(const SUMOVehicle *const veh) const
returns the minimum travel time for the given vehicle
Definition: MSEdge.h:405
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:302
#define STEPS2TIME(x)
Definition: SUMOTime.h:58
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
Definition: MSNet.h:672
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:99
The simulation is running.
Definition: MSNet.h:93
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:263
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:753
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:296
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) ...
#define POSITION_EPS
Definition: config.h:172
static void postProcessRemoteControl()
Definition: Helper.cpp:754
bool hasInternalLinks() const
return whether the network contains internal links
Definition: MSNet.h:605
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:114
static const std::set< MSDevice_ToC * > & getInstances()
returns all currently existing ToC devices
Definition: MSDevice_ToC.h:92
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:934
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:615
SUMOTime myStateDumpPeriod
The period for writing state.
Definition: MSNet.h:720
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:701
void postloadInitContainer()
Closes building of junctions.
int myMaxTeleports
Maximum number of teleports.
Definition: MSNet.h:651
junctions with edges allowing the additional mode
void abortWaiting()
informes about all waiting vehicles (deletion in destructor)
#define VERSION_STRING
Definition: config.h:207
PedestrianRouter< MSEdge, MSLane, MSJunction, MSVehicle > MSPedestrianRouter
Definition: MSNet.h:108
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:494
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:771
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:750
static MSNet * myInstance
Unique instance of MSNet.
Definition: MSNet.h:642
static void clearAll()
Clears all dictionaries.
Definition: MSNet.cpp:620
The simulation is loading.
Definition: MSNet.h:91
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:666
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
Definition: MSNet.h:670
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:369
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:1753
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:664
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:821
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:1000
An external interrupt occured.
Definition: MSNet.h:103
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:802
static TraCIServer * getInstance()
Definition: TraCIServer.h:73
MSEventControl * myBeginOfTimestepEvents
Controls events executed at the begin of a time step;.
Definition: MSNet.h:678
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:686
The simulation had too many teleports.
Definition: MSNet.h:105
void prohibit(const std::vector< E *> &toProhibit)
MSNet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents, ShapeContainer *shapeCont=0)
Constructor.
Definition: MSNet.cpp:173
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:1042
long mySimBeginMillis
The overall simulation duration.
Definition: MSNet.h:704
virtual ~MSNet()
Destructor.
Definition: MSNet.cpp:254
bool myHasElevation
Whether the network contains elevation data.
Definition: MSNet.h:738
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:722
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:595
IntermodalRouter< MSEdge, MSLane, MSJunction, SUMOVehicle > MSIntermodalRouter
Definition: MSNet.h:109
bool isEmbedded() const
Definition: TraCIServer.h:70
SUMOTime myStep
Current time step.
Definition: MSNet.h:648
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:903
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:441
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:362
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:242
static const std::string STAGE_INSERTIONS
Definition: MSNet.h:773
MSEventControl * myInsertionEvents
Controls insertion events;.
Definition: MSNet.h:682
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:78
long mySimStepDuration
Definition: MSNet.h:701
static bool wasClosed()
check whether close was requested
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterEffort(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:923
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:735
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:237
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:759
static void adaptIntermodalRouter(MSIntermodalRouter &router)
Definition: MSNet.cpp:970
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.
const std::string generateStatistics(SUMOTime start)
Writes performance output and running vehicle stats.
Definition: MSNet.cpp:368
bool generatesOutput()
Whether this device requested to write output.
Definition: MSDevice_ToC.h:177
The ToC Device controls transition of control between automated and manual driving.
Definition: MSDevice_ToC.h:53
static double getEffort(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the effort to pass an edge.
Definition: MSNet.cpp:134
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net&#39;s internal edge travel times/efforts container.
Definition: MSNet.cpp:793
void writeOutput()
Write output to file given by option device.toc.file.
static const std::string STAGE_EVENTS
string constants for simstep stages
Definition: MSNet.h:770
int getJammedNumber() const
Returns the number of times a transportables was jammed.