Eclipse SUMO - Simulation of Urban MObility
MSNet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 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>
93 #include <utils/router/FareModul.h>
94 
95 #include "MSTransportableControl.h"
96 #include "MSEdgeControl.h"
97 #include "MSJunctionControl.h"
98 #include "MSInsertionControl.h"
99 #include "MSDynamicShapeUpdater.h"
100 #include "MSEventControl.h"
101 #include "MSEdge.h"
102 #include "MSJunction.h"
103 #include "MSJunctionLogic.h"
104 #include "MSLane.h"
105 #include "MSVehicleTransfer.h"
106 #include "MSRoute.h"
107 #include "MSGlobals.h"
108 #include "MSContainer.h"
109 #include "MSEdgeWeightsStorage.h"
110 #include "MSStateHandler.h"
111 #include "MSFrame.h"
112 #include "MSParkingArea.h"
113 #include "MSStoppingPlace.h"
114 #include "MSNet.h"
115 
116 
117 // ===========================================================================
118 // debug constants
119 // ===========================================================================
120 //#define DEBUG_SIMSTEP
121 
122 
123 // ===========================================================================
124 // static member definitions
125 // ===========================================================================
126 MSNet* MSNet::myInstance = nullptr;
127 
128 const std::string MSNet::STAGE_EVENTS("events");
129 const std::string MSNet::STAGE_MOVEMENTS("move");
130 const std::string MSNet::STAGE_LANECHANGE("laneChange");
131 const std::string MSNet::STAGE_INSERTIONS("insertion");
132 
133 // ===========================================================================
134 // static member method definitions
135 // ===========================================================================
136 double
137 MSNet::getEffort(const MSEdge* const e, const SUMOVehicle* const v, double t) {
138  double value;
139  const MSVehicle* const veh = dynamic_cast<const MSVehicle* const>(v);
140  if (veh != nullptr && veh->getWeightsStorage().retrieveExistingEffort(e, t, value)) {
141  return value;
142  }
143  if (getInstance()->getWeightsStorage().retrieveExistingEffort(e, t, value)) {
144  return value;
145  }
146  return 0;
147 }
148 
149 
150 double
151 MSNet::getTravelTime(const MSEdge* const e, const SUMOVehicle* const v, double t) {
152  double value;
153  const MSVehicle* const veh = dynamic_cast<const MSVehicle* const>(v);
154  if (veh != nullptr && veh->getWeightsStorage().retrieveExistingTravelTime(e, t, value)) {
155  return value;
156  }
158  return value;
159  }
160  return e->getMinimumTravelTime(v);
161 }
162 
163 
164 // ---------------------------------------------------------------------------
165 // MSNet - methods
166 // ---------------------------------------------------------------------------
167 MSNet*
169  if (myInstance != nullptr) {
170  return myInstance;
171  }
172  throw ProcessError("A network was not yet constructed.");
173 }
174 
175 void
177  if (!MSGlobals::gUseMesoSim) {
179  }
180 }
181 
182 void
184  if (!MSGlobals::gUseMesoSim) {
186  }
187 }
188 
189 
190 MSNet::MSNet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
191  MSEventControl* endOfTimestepEvents,
192  MSEventControl* insertionEvents,
193  ShapeContainer* shapeCont):
194  myAmInterrupted(false),
195  myVehiclesMoved(0),
196  myHavePermissions(false),
197  myHasInternalLinks(false),
198  myHasElevation(false),
199  myHasPedestrianNetwork(false),
200  myHasBidiEdges(false),
201  myEdgeDataEndTime(-1),
202  myRouterTT(nullptr),
203  myRouterEffort(nullptr),
204  myPedestrianRouter(nullptr),
205  myDynamicShapeUpdater(nullptr) {
206  if (myInstance != nullptr) {
207  throw ProcessError("A network was already constructed.");
208  }
210  myStep = string2time(oc.getString("begin"));
211  myMaxTeleports = oc.getInt("max-num-teleports");
212  myLogExecutionTime = !oc.getBool("no-duration-log");
213  myLogStepNumber = !oc.getBool("no-step-log");
214  myInserter = new MSInsertionControl(*vc, string2time(oc.getString("max-depart-delay")), oc.getBool("eager-insert"), oc.getInt("max-num-vehicles"),
215  string2time(oc.getString("random-depart-offset")));
216  myVehicleControl = vc;
218  myEdges = nullptr;
219  myJunctions = nullptr;
220  myRouteLoaders = nullptr;
221  myLogics = nullptr;
222  myPersonControl = nullptr;
223  myContainerControl = nullptr;
224  myEdgeWeights = nullptr;
225  myShapeContainer = shapeCont == nullptr ? new ShapeContainer() : shapeCont;
226 
227  myBeginOfTimestepEvents = beginOfTimestepEvents;
228  myEndOfTimestepEvents = endOfTimestepEvents;
229  myInsertionEvents = insertionEvents;
230  myLanesRTree.first = false;
231 
233  MSGlobals::gMesoNet = new MELoop(string2time(oc.getString("meso-recheck")));
234  }
235  myInstance = this;
236  initStatic();
237 }
238 
239 
240 void
242  SUMORouteLoaderControl* routeLoaders,
243  MSTLLogicControl* tlc,
244  std::vector<SUMOTime> stateDumpTimes,
245  std::vector<std::string> stateDumpFiles,
246  bool hasInternalLinks,
247  bool hasNeighs,
248  bool lefthand,
249  double version) {
250  myEdges = edges;
251  myJunctions = junctions;
252  myRouteLoaders = routeLoaders;
253  myLogics = tlc;
254  // save the time the network state shall be saved at
255  myStateDumpTimes = stateDumpTimes;
256  myStateDumpFiles = stateDumpFiles;
257  myStateDumpPeriod = string2time(oc.getString("save-state.period"));
258  myStateDumpPrefix = oc.getString("save-state.prefix");
259  myStateDumpSuffix = oc.getString("save-state.suffix");
260 
261  // initialise performance computation
264  if (hasNeighs && MSGlobals::gLateralResolution > 0) {
265  WRITE_WARNING("Opposite direction driving does not work together with the sublane model.");
266  }
271  myVersion = version;
272 }
273 
274 
276  cleanupStatic();
277  // delete controls
278  delete myJunctions;
279  delete myDetectorControl;
280  // delete mean data
281  delete myEdges;
282  delete myInserter;
283  delete myLogics;
284  delete myRouteLoaders;
285  if (myPersonControl != nullptr) {
286  delete myPersonControl;
287  }
288  if (myContainerControl != nullptr) {
289  delete myContainerControl;
290  }
291  delete myVehicleControl; // must happen after deleting transportables
292  // delete events late so that vehicles can get rid of references first
294  myBeginOfTimestepEvents = nullptr;
295  delete myEndOfTimestepEvents;
296  myEndOfTimestepEvents = nullptr;
297  delete myInsertionEvents;
298  myInsertionEvents = nullptr;
299  delete myShapeContainer;
300  delete myEdgeWeights;
301  delete myRouterTT;
302  delete myRouterEffort;
303  delete myPedestrianRouter;
304  for (auto& router : myIntermodalRouter) {
305  delete router.second;
306  }
307  myIntermodalRouter.clear();
308  myLanesRTree.second.RemoveAll();
309  clearAll();
311  delete MSGlobals::gMesoNet;
312  }
313  myInstance = nullptr;
314 }
315 
316 
317 void
318 MSNet::addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
319  myRestrictions[id][svc] = speed;
320 }
321 
322 
323 const std::map<SUMOVehicleClass, double>*
324 MSNet::getRestrictions(const std::string& id) const {
325  std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i = myRestrictions.find(id);
326  if (i == myRestrictions.end()) {
327  return nullptr;
328  }
329  return &i->second;
330 }
331 
332 
335  // report the begin when wished
336  WRITE_MESSAGE("Simulation version " + std::string(VERSION_STRING) + " started with time: " + time2string(start));
337  // the simulation loop
339  // state loading may have changed the start time so we need to reinit it
340  myStep = start;
341  while (state == SIMSTATE_RUNNING) {
342  if (myLogStepNumber) {
344  }
345  simulationStep();
346  if (myLogStepNumber) {
348  }
349  state = simulationState(stop);
350 #ifdef DEBUG_SIMSTEP
351  std::cout << SIMTIME << " MSNet::simulate(" << start << ", " << stop << ")"
352  << "\n simulation state: " << getStateMessage(state)
353  << std::endl;
354 #endif
355  if (state == SIMSTATE_LOADING) {
358  } else if (state != SIMSTATE_RUNNING) {
359  if (TraCIServer::getInstance() != nullptr && !TraCIServer::wasClosed()) {
360  // overrides SIMSTATE_END_STEP_REACHED, e.g. (TraCI ignore SUMO's --end option)
361  state = SIMSTATE_RUNNING;
362  }
363  }
364  }
365  // report the end when wished
366  WRITE_MESSAGE("Simulation ended at time: " + time2string(getCurrentTimeStep()));
367  WRITE_MESSAGE("Reason: " + getStateMessage(state));
368  // exit simulation loop
369  closeSimulation(start);
370  return state;
371 }
372 
373 
374 void
377 }
378 
379 
380 const std::string
382  long duration = SysUtils::getCurrentMillis() - mySimBeginMillis;
383  std::ostringstream msg;
384  // print performance notice
385  msg << "Performance: " << "\n" << " Duration: " << duration << "ms" << "\n";
386  if (duration != 0) {
387  msg << " Real time factor: " << (STEPS2TIME(myStep - start) * 1000. / (double)duration) << "\n";
388  msg.setf(std::ios::fixed, std::ios::floatfield); // use decimal format
389  msg.setf(std::ios::showpoint); // print decimal point
390  msg << " UPS: " << ((double)myVehiclesMoved / ((double)duration / 1000)) << "\n";
391  }
392  // print vehicle statistics
393  const std::string discardNotice = ((myVehicleControl->getLoadedVehicleNo() != myVehicleControl->getDepartedVehicleNo()) ?
394  " (Loaded: " + toString(myVehicleControl->getLoadedVehicleNo()) + ")" : "");
395  msg << "Vehicles: " << "\n"
396  << " Inserted: " << myVehicleControl->getDepartedVehicleNo() << discardNotice << "\n"
397  << " Running: " << myVehicleControl->getRunningVehicleNo() << "\n"
398  << " Waiting: " << myInserter->getWaitingVehicleNo() << "\n";
399 
401  // print optional teleport statistics
402  std::vector<std::string> reasons;
403  if (myVehicleControl->getCollisionCount() > 0) {
404  reasons.push_back("Collisions: " + toString(myVehicleControl->getCollisionCount()));
405  }
406  if (myVehicleControl->getTeleportsJam() > 0) {
407  reasons.push_back("Jam: " + toString(myVehicleControl->getTeleportsJam()));
408  }
409  if (myVehicleControl->getTeleportsYield() > 0) {
410  reasons.push_back("Yield: " + toString(myVehicleControl->getTeleportsYield()));
411  }
413  reasons.push_back("Wrong Lane: " + toString(myVehicleControl->getTeleportsWrongLane()));
414  }
415  msg << "Teleports: " << myVehicleControl->getTeleportCount() << " (" << joinToString(reasons, ", ") << ")\n";
416  }
417  if (myVehicleControl->getEmergencyStops() > 0) {
418  msg << "Emergency Stops: " << myVehicleControl->getEmergencyStops() << "\n";
419  }
420  if (myPersonControl != nullptr && myPersonControl->getLoadedNumber() > 0) {
421  msg << "Persons: " << "\n"
422  << " Inserted: " << myPersonControl->getLoadedNumber() << "\n"
423  << " Running: " << myPersonControl->getRunningNumber() << "\n";
424  if (myPersonControl->getJammedNumber() > 0) {
425  msg << " Jammed: " << myPersonControl->getJammedNumber() << "\n";
426  }
427  }
428  if (OptionsCont::getOptions().getBool("duration-log.statistics")) {
430  }
431  return msg.str();
432 }
433 
434 
435 void
438  if (OptionsCont::getOptions().getBool("vehroute-output.write-unfinished")) {
440  }
441  if (OptionsCont::getOptions().getBool("tripinfo-output.write-unfinished")) {
443  }
444  if (OptionsCont::getOptions().isSet("chargingstations-output")) {
446  }
447  if (OptionsCont::getOptions().isSet("railsignal-block-output")) {
449  }
450  if (myLogExecutionTime) {
452  }
453 }
454 
455 
456 void
458 #ifdef DEBUG_SIMSTEP
459  std::cout << SIMTIME << ": MSNet::simulationStep() called"
460  << ", myStep = " << myStep
461  << std::endl;
462 #endif
464  if (t != nullptr) {
465  if (myLogExecutionTime) {
467  }
469 #ifdef DEBUG_SIMSTEP
470  bool loadRequested = !TraCI::getLoadArgs().empty();
471  assert(t->getTargetTime() >= myStep || loadRequested || TraCIServer::wasClosed());
472 #endif
473  if (myLogExecutionTime) {
475  }
476  if (TraCIServer::wasClosed()) {
477  return;
478  }
479  }
480 #ifdef DEBUG_SIMSTEP
481  std::cout << SIMTIME << ": TraCI target time: " << t->getTargetTime() << std::endl;
482 #endif
483  // execute beginOfTimestepEvents
484  if (myLogExecutionTime) {
486  }
487  // simulation state output
488  std::vector<SUMOTime>::iterator timeIt = std::find(myStateDumpTimes.begin(), myStateDumpTimes.end(), myStep);
489  if (timeIt != myStateDumpTimes.end()) {
490  const int dist = (int)distance(myStateDumpTimes.begin(), timeIt);
492  }
493  if (myStateDumpPeriod > 0 && myStep % myStateDumpPeriod == 0) {
495  }
497 #ifdef HAVE_FOX
498  MSRoutingEngine::waitForAll();
499 #endif
502  }
503  // check whether the tls programs need to be switched
505 
509  } else {
510  // assure all lanes with vehicles are 'active'
512 
513  // compute safe velocities for all vehicles for the next few lanes
514  // also register ApproachingVehicleInformation for all links
516 
517  // register junction approaches based on planned velocities as basis for right-of-way decision
519 
520  // decide right-of-way and execute movements
524  }
525 
526  // vehicles may change lanes
528 
531  }
532  }
533  loadRoutes();
534 
535  // persons
536  if (myPersonControl != nullptr && myPersonControl->hasTransportables()) {
538  }
539  // containers
542  }
543  // insert vehicles
546 #ifdef HAVE_FOX
547  MSRoutingEngine::waitForAll();
548 #endif
551  //myEdges->patchActiveLanes(); // @note required to detect collisions on lanes that were empty before insertion. wasteful?
553  }
555 
556  // execute endOfTimestepEvents
558 
559  if (myLogExecutionTime) {
561  }
563  if (myLogExecutionTime) {
565  }
566  // update and write (if needed) detector values
567  writeOutput();
568 
569  if (myLogExecutionTime) {
572  }
573  myStep += DELTA_T;
574 }
575 
576 
579  if (TraCIServer::wasClosed()) {
581  }
582  if (TraCIServer::getInstance() != nullptr && !TraCIServer::getInstance()->getLoadArgs().empty()) {
583  return SIMSTATE_LOADING;
584  }
585  if ((stopTime < 0 || myStep > stopTime) && TraCIServer::getInstance() == nullptr && (stopTime > 0 || myStep > myEdgeDataEndTime)) {
587  && (myInserter->getPendingFlowCount() == 0)
588  && (myPersonControl == nullptr || !myPersonControl->hasNonWaiting())
589  && (myContainerControl == nullptr || !myContainerControl->hasNonWaiting())) {
590  if (myPersonControl) {
592  }
593  if (myContainerControl) {
595  }
598  }
599  }
600  if (stopTime >= 0 && myStep >= stopTime) {
602  }
605  }
606  if (myAmInterrupted) {
607  return SIMSTATE_INTERRUPTED;
608  }
609  return SIMSTATE_RUNNING;
610 }
611 
612 
613 std::string
615  switch (state) {
617  return "";
619  return "The final simulation step has been reached.";
621  return "All vehicles have left the simulation.";
623  return "TraCI requested termination.";
625  return "An error occurred (see log).";
627  return "Interrupted.";
629  return "Too many teleports.";
631  return "TraCI issued load command.";
632  default:
633  return "Unknown reason.";
634  }
635 }
636 
637 
638 void
640  // clear container
641  MSEdge::clear();
642  MSLane::clear();
643  MSRoute::clear();
655  if (t != nullptr) {
656  t->cleanup();
657  }
660 }
661 
662 
663 void
665  // update detector values
667  const OptionsCont& oc = OptionsCont::getOptions();
668 
669  // check state dumps
670  if (oc.isSet("netstate-dump")) {
672  oc.getInt("netstate-dump.precision"));
673  }
674 
675  // check fcd dumps
676  if (OptionsCont::getOptions().isSet("fcd-output")) {
678  }
679 
680  // check emission dumps
681  if (OptionsCont::getOptions().isSet("emission-output")) {
683  oc.getInt("emission-output.precision"));
684  }
685 
686  // battery dumps
687  if (OptionsCont::getOptions().isSet("battery-output")) {
689  oc.getInt("battery-output.precision"));
690  }
691 
692  // check full dumps
693  if (OptionsCont::getOptions().isSet("full-output")) {
695  }
696 
697  // check queue dumps
698  if (OptionsCont::getOptions().isSet("queue-output")) {
700  }
701 
702  // check amitran dumps
703  if (OptionsCont::getOptions().isSet("amitran-output")) {
705  }
706 
707  // check vtk dumps
708  if (OptionsCont::getOptions().isSet("vtk-output")) {
709 
710  if (MSNet::getInstance()->getVehicleControl().getRunningVehicleNo() > 0) {
711  std::string timestep = time2string(myStep);
712  timestep = timestep.substr(0, timestep.length() - 3);
713  std::string output = OptionsCont::getOptions().getString("vtk-output");
714  std::string filename = output + "_" + timestep + ".vtp";
715 
716  OutputDevice_File dev = OutputDevice_File(filename, false);
717 
718  //build a huge mass of xml files
720 
721  }
722 
723  }
724 
725  // summary output
726  if (OptionsCont::getOptions().isSet("summary-output")) {
727  OutputDevice& od = OutputDevice::getDeviceByOption("summary-output");
728  int departedVehiclesNumber = myVehicleControl->getDepartedVehicleNo();
729  const double meanWaitingTime = departedVehiclesNumber != 0 ? myVehicleControl->getTotalDepartureDelay() / (double) departedVehiclesNumber : -1.;
730  int endedVehicleNumber = myVehicleControl->getEndedVehicleNo();
731  const double meanTravelTime = endedVehicleNumber != 0 ? myVehicleControl->getTotalTravelTime() / (double) endedVehicleNumber : -1.;
732  od.openTag("step");
733  od.writeAttr("time", time2string(myStep));
737  od.writeAttr("waiting", myInserter->getWaitingVehicleNo());
740  od.writeAttr("collisions", myVehicleControl->getCollisionCount());
741  od.writeAttr("teleports", myVehicleControl->getTeleportCount());
743  od.writeAttr("meanWaitingTime", meanWaitingTime);
744  od.writeAttr("meanTravelTime", meanTravelTime);
745  std::pair<double, double> meanSpeed = myVehicleControl->getVehicleMeanSpeeds();
746  od.writeAttr("meanSpeed", meanSpeed.first);
747  od.writeAttr("meanSpeedRelative", meanSpeed.second);
748  if (myLogExecutionTime) {
749  od.writeAttr("duration", mySimStepDuration);
750  }
751  od.closeTag();
752  }
753 
754  // write detector values
756 
757  // write link states
758  if (OptionsCont::getOptions().isSet("link-output")) {
759  OutputDevice& od = OutputDevice::getDeviceByOption("link-output");
760  od.openTag("timestep");
762  const MSEdgeVector& edges = myEdges->getEdges();
763  for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
764  const std::vector<MSLane*>& lanes = (*i)->getLanes();
765  for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
766  const std::vector<MSLink*>& links = (*j)->getLinkCont();
767  for (std::vector<MSLink*>::const_iterator k = links.begin(); k != links.end(); ++k) {
768  (*k)->writeApproaching(od, (*j)->getID());
769  }
770  }
771  }
772  od.closeTag();
773  }
774 
775  // write SSM output
776  for (std::set<MSDevice_SSM*>::iterator di = MSDevice_SSM::getInstances().begin(); di != MSDevice_SSM::getInstances().end(); ++di) {
777  MSDevice_SSM* dev = (*di);
778  dev->updateAndWriteOutput();
779  }
780 
781  // write ToC output
782  for (std::set<MSDevice_ToC*>::iterator di = MSDevice_ToC::getInstances().begin(); di != MSDevice_ToC::getInstances().end(); ++di) {
783  MSDevice_ToC* dev = (*di);
784  if (dev->generatesOutput()) {
785  dev->writeOutput();
786  }
787  }
788 }
789 
790 
791 bool
793  return myLogExecutionTime;
794 }
795 
796 
799  if (myPersonControl == nullptr) {
801  }
802  return *myPersonControl;
803 }
804 
807  if (myContainerControl == nullptr) {
809  }
810  return *myContainerControl;
811 }
812 
815  myDynamicShapeUpdater = std::unique_ptr<MSDynamicShapeUpdater> (new MSDynamicShapeUpdater(MSNet::getInstance()->getShapeContainer()));
816  return myDynamicShapeUpdater.get();
817 }
818 
821  if (myEdgeWeights == nullptr) {
823  }
824  return *myEdgeWeights;
825 }
826 
827 
828 void
830  std::cout << "Step #" << time2string(myStep);
831 }
832 
833 
834 void
836  if (myLogExecutionTime) {
837  std::ostringstream oss;
838  oss.setf(std::ios::fixed, std::ios::floatfield); // use decimal format
839  oss.setf(std::ios::showpoint); // print decimal point
840  oss << std::setprecision(gPrecision);
841  if (mySimStepDuration != 0) {
842  const double durationSec = (double)mySimStepDuration / 1000.;
843  oss << " (" << mySimStepDuration << "ms ~= "
844  << (TS / durationSec) << "*RT, ~"
845  << ((double) myVehicleControl->getRunningVehicleNo() / durationSec);
846  } else {
847  oss << " (0ms ?*RT. ?";
848  }
849  oss << "UPS, ";
850  if (TraCIServer::getInstance() != nullptr) {
851  oss << "TraCI: " << myTraCIStepDuration << "ms, ";
852  }
853  oss << "vehicles TOT " << myVehicleControl->getDepartedVehicleNo()
854  << " ACT " << myVehicleControl->getRunningVehicleNo()
855  << " BUF " << myInserter->getWaitingVehicleNo()
856  << ") ";
857  std::string prev = "Step #" + time2string(myStep - DELTA_T);
858  std::cout << oss.str().substr(0, 90 - prev.length());
859  }
860  std::cout << '\r';
861 }
862 
863 
864 void
866  if (find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener) == myVehicleStateListeners.end()) {
867  myVehicleStateListeners.push_back(listener);
868  }
869 }
870 
871 
872 void
874  std::vector<VehicleStateListener*>::iterator i = std::find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener);
875  if (i != myVehicleStateListeners.end()) {
876  myVehicleStateListeners.erase(i);
877  }
878 }
879 
880 
881 void
882 MSNet::informVehicleStateListener(const SUMOVehicle* const vehicle, VehicleState to, const std::string& info) {
883 #ifdef HAVE_FOX
884  FXConditionalLock lock(myStateListenerMutex, MSRoutingEngine::isParallel());
885 #endif
886  for (std::vector<VehicleStateListener*>::iterator i = myVehicleStateListeners.begin(); i != myVehicleStateListeners.end(); ++i) {
887  (*i)->vehicleStateChanged(vehicle, to, info);
888  }
889 }
890 
891 
892 bool
894  return myStoppingPlaces[category == SUMO_TAG_TRAIN_STOP ? SUMO_TAG_BUS_STOP : category].add(stop->getID(), stop);
895 }
896 
897 
899 MSNet::getStoppingPlace(const std::string& id, const SumoXMLTag category) const {
900  if (myStoppingPlaces.count(category) > 0) {
901  return myStoppingPlaces.find(category)->second.get(id);
902  }
903  return nullptr;
904 }
905 
906 
907 std::string
908 MSNet::getStoppingPlaceID(const MSLane* lane, const double pos, const SumoXMLTag category) const {
909  if (myStoppingPlaces.count(category) > 0) {
910  for (const auto& it : myStoppingPlaces.find(category)->second) {
911  MSStoppingPlace* stop = it.second;
912  if (&stop->getLane() == lane && stop->getBeginLanePosition() - POSITION_EPS <= pos && stop->getEndLanePosition() + POSITION_EPS >= pos) {
913  return stop->getID();
914  }
915  }
916  }
917  return "";
918 }
919 
920 
923  auto it = myStoppingPlaces.find(category);
924  if (it != myStoppingPlaces.end()) {
925  return it->second;
926  } else {
927  throw ProcessError("No stoppingPlace of type '" + toString(category) + "' found");
928  }
929 }
930 
931 void
934  OutputDevice& output = OutputDevice::getDeviceByOption("chargingstations-output");
935  for (const auto& it : myStoppingPlaces.find(SUMO_TAG_CHARGING_STATION)->second) {
936  static_cast<MSChargingStation*>(it.second)->writeChargingStationOutput(output);
937  }
938  }
939 }
940 
941 void
943  OutputDevice& output = OutputDevice::getDeviceByOption("railsignal-block-output");
944  for (auto tls : myLogics->getAllLogics()) {
945  MSRailSignal* rs = dynamic_cast<MSRailSignal*>(tls);
946  if (rs != nullptr) {
947  rs->writeBlocks(output);
948  }
949  }
950 }
951 
952 
954 MSNet::getRouterTT(const MSEdgeVector& prohibited) const {
955  if (myRouterTT == nullptr) {
956  const std::string routingAlgorithm = OptionsCont::getOptions().getString("routing-algorithm");
957  if (routingAlgorithm == "dijkstra") {
960  } else {
961  if (routingAlgorithm != "astar") {
962  WRITE_WARNING("TraCI and Triggers cannot use routing algorithm '" + routingAlgorithm + "'. using 'astar' instead.");
963  }
966  }
967  }
968  dynamic_cast<SUMOAbstractRouterPermissions<MSEdge, SUMOVehicle>*>(myRouterTT)->prohibit(prohibited);
969  return *myRouterTT;
970 }
971 
972 
974 MSNet::getRouterEffort(const MSEdgeVector& prohibited) const {
975  if (myRouterEffort == nullptr) {
978  }
979  dynamic_cast<SUMOAbstractRouterPermissions<MSEdge, SUMOVehicle>*>(myRouterEffort)->prohibit(prohibited);
980  return *myRouterEffort;
981 }
982 
983 
985 MSNet::getPedestrianRouter(const MSEdgeVector& prohibited) const {
986  if (myPedestrianRouter == nullptr) {
988  }
989  myPedestrianRouter->prohibit(prohibited);
990  return *myPedestrianRouter;
991 }
992 
993 
995 MSNet::getIntermodalRouter(const int routingMode, const MSEdgeVector& prohibited) const {
996  if (myIntermodalRouter.count(routingMode) == 0) {
997  int carWalk = 0;
998  for (const std::string& opt : OptionsCont::getOptions().getStringVector("persontrip.transfer.car-walk")) {
999  if (opt == "parkingAreas") {
1001  } else if (opt == "ptStops") {
1003  } else if (opt == "allJunctions") {
1005  }
1006  }
1007  const std::string routingAlgorithm = OptionsCont::getOptions().getString("routing-algorithm");
1008  if (routingMode == libsumo::ROUTING_MODE_COMBINED) {
1009  myIntermodalRouter[routingMode] = new MSIntermodalRouter(MSNet::adaptIntermodalRouter, carWalk, routingAlgorithm, routingMode, new FareModul());
1010  } else {
1011  myIntermodalRouter[routingMode] = new MSIntermodalRouter(MSNet::adaptIntermodalRouter, carWalk, routingAlgorithm, routingMode);
1012  }
1013  }
1014  myIntermodalRouter[routingMode]->prohibit(prohibited);
1015  return *myIntermodalRouter[routingMode];
1016 }
1017 
1018 
1019 void
1021  // add access to all parking areas
1022  for (const auto& i : myInstance->myStoppingPlaces[SUMO_TAG_PARKING_AREA]) {
1023  const MSEdge* const edge = &i.second->getLane().getEdge();
1024  router.getNetwork()->addAccess(i.first, edge, i.second->getAccessPos(edge), i.second->getAccessDistance(edge), SUMO_TAG_PARKING_AREA);
1025  }
1026  EffortCalculator* const external = router.getExternalEffort();
1027  // add access to all public transport stops
1028  for (const auto& i : myInstance->myStoppingPlaces[SUMO_TAG_BUS_STOP]) {
1029  const MSEdge* const edge = &i.second->getLane().getEdge();
1030  router.getNetwork()->addAccess(i.first, edge, i.second->getAccessPos(edge),
1031  i.second->getAccessDistance(edge), SUMO_TAG_BUS_STOP);
1032  for (const auto& a : i.second->getAllAccessPos()) {
1033  router.getNetwork()->addAccess(i.first, &std::get<0>(a)->getEdge(), std::get<1>(a), std::get<2>(a), SUMO_TAG_BUS_STOP);
1034  }
1035  if (external != nullptr) {
1036  external->addStop(router.getNetwork()->getStopEdge(i.first)->getNumericalID(), *i.second);
1037  }
1038  }
1041 }
1042 
1043 
1044 bool
1046  const MSEdgeVector& edges = myEdges->getEdges();
1047  for (MSEdgeVector::const_iterator e = edges.begin(); e != edges.end(); ++e) {
1048  for (std::vector<MSLane*>::const_iterator i = (*e)->getLanes().begin(); i != (*e)->getLanes().end(); ++i) {
1049  if ((*i)->getShape().hasElevation()) {
1050  return true;
1051  }
1052  }
1053  }
1054  return false;
1055 }
1056 
1057 
1058 bool
1060  for (const MSEdge* e : myEdges->getEdges()) {
1061  if (e->getFunction() == EDGEFUNC_WALKINGAREA) {
1062  return true;
1063  }
1064  }
1065  return false;
1066 }
1067 
1068 
1069 bool
1071  for (const MSEdge* e : myEdges->getEdges()) {
1072  if (e->getBidiEdge() != nullptr) {
1073  return true;
1074  }
1075  }
1076  return false;
1077 }
1078 
1079 bool
1080 MSNet::warnOnce(const std::string& typeAndID) {
1081  if (myWarnedOnce.find(typeAndID) == myWarnedOnce.end()) {
1082  myWarnedOnce[typeAndID] = true;
1083  return true;
1084  }
1085  return false;
1086 }
1087 
1088 
1089 /****************************************************************************/
std::string myStateDumpSuffix
Definition: MSNet.h:775
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.
void writeBlocks(OutputDevice &od) const
write rail signal block output for all links and driveways
bool myHasPedestrianNetwork
Whether the network contains pedestrian network elements.
Definition: MSNet.h:793
int getEndedVehicleNo() const
Returns the number of removed vehicles.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
public transport stops and access
long long int SUMOTime
Definition: SUMOTime.h:35
double getBeginLanePosition() const
Returns the begin position of this stop.
Interface for objects listening to vehicle state changes.
Definition: MSNet.h:567
TRACI_CONST int ROUTING_MODE_COMBINED
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
MSDynamicShapeUpdater * makeDynamicShapeUpdater()
Creates and returns a dynamic shapes updater.
Definition: MSNet.cpp:814
bool checkBidiEdges()
check wether bidirectional edges occur in the network
Definition: MSNet.cpp:1070
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:882
void removeVehicleStateListener(VehicleStateListener *listener)
Removes a vehicle states listener.
Definition: MSNet.cpp:873
EffortCalculator * getExternalEffort() const
int getArrivedVehicleNo() const
Returns the number of arrived vehicles.
MSPedestrianRouter * myPedestrianRouter
Definition: MSNet.h:827
MSEventControl * myEndOfTimestepEvents
Controls events executed at the end of a time step;.
Definition: MSNet.h:732
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:899
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:908
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:1080
void patchActiveLanes()
Resets information whether a lane is active for all lanes.
int getLoadedNumber() const
Returns the number of build transportables.
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
Definition: MSNet.h:714
A signal for rails.
Definition: MSRailSignal.h:47
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:57
std::vector< SUMOTime > myStateDumpTimes
Times at which a state shall be written.
Definition: MSNet.h:768
virtual void execute(SUMOTime time)
Executes time-dependant commands.
_IntermodalEdge * getStopEdge(const std::string &stopId) const
Returns the associated stop edge.
SimulationState simulate(SUMOTime start, SUMOTime stop)
Simulates from timestep start to stop.
Definition: MSNet.cpp:334
SUMOAbstractRouter< MSEdge, SUMOVehicle > * myRouterEffort
Definition: MSNet.h:826
bool logSimulationDuration() const
Returns whether duration shall be logged.
Definition: MSNet.cpp:792
MSIntermodalRouter & getIntermodalRouter(const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:995
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:65
std::map< SumoXMLTag, NamedObjectCont< MSStoppingPlace * > > myStoppingPlaces
Dictionary of bus / container stops.
Definition: MSNet.h:808
int getNumericalID() const
Computes the shortest path through a network using the A* algorithm.
Definition: AStarRouter.h:78
void writeRailSignalBlocks() const
write rail signal block output
Definition: MSNet.cpp:942
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:168
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:781
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
MSEdgeControl * myEdges
Controls edges, performs vehicle movement;.
Definition: MSNet.h:720
The final simulation step has been performed.
Definition: MSNet.h:103
SUMOTime myEdgeDataEndTime
end of loaded edgeData
Definition: MSNet.h:805
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:802
std::vector< std::string > myStateDumpFiles
The names for the state files.
Definition: MSNet.h:770
static void cleanup()
Definition: Helper.cpp:359
bool myLogExecutionTime
Information whether the simulation duration shall be logged.
Definition: MSNet.h:747
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:842
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:77
bool myHasBidiEdges
Whether the network contains bidirectional rail edges.
Definition: MSNet.h:796
std::vector< std::string > & getLoadArgs()
Definition: TraCIServer.h:249
#define TS
Definition: SUMOTime.h:44
A map of named object pointers.
Detectors container; responsible for string and output generation.
bool myLefthand
Whether the network was built for left-hand traffic.
Definition: MSNet.h:799
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:828
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition: MSNet.cpp:865
SimulationState
Possible states of a simulation - running or stopped with different reasons.
Definition: MSNet.h:97
bool addStoppingPlace(const SumoXMLTag category, MSStoppingPlace *stop)
Adds a stopping place.
Definition: MSNet.cpp:893
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
The simulated network and simulation perfomer.
Definition: MSNet.h:92
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:64
ShapeContainer * myShapeContainer
A container for geometrical shapes;.
Definition: MSNet.h:736
std::pair< bool, NamedRTree > myLanesRTree
An RTree structure holding lane IDs.
Definition: MSNet.h:831
Container for junctions; performs operations on all stored junctions.
std::unique_ptr< MSDynamicShapeUpdater > myDynamicShapeUpdater
Updater for dynamic shapes that are tracking traffic objects (ensures removal of shape dynamics when ...
Definition: MSNet.h:836
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:806
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:50
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:932
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:76
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:759
double getEndLanePosition() const
Returns the end position of this stop.
The simulation does not contain further vehicles.
Definition: MSNet.h:105
the effort calculator interface
A scoped lock which only triggers on condition.
static void generateOutputForUnfinished()
generate output for vehicles which are still in the network
static void cleanupStatic()
Place for static initializations of simulation components (called after successful net build) ...
Definition: MSNet.cpp:183
An error occurred during the simulation step.
Definition: MSNet.h:109
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:706
The main mesocopic simulation loop.
Definition: MELoop.h:49
void writeOutput()
Write netstate, summary and detector output.
Definition: MSNet.cpp:664
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
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:578
static std::string printStatistics()
get statistics for printing to stdout
MSInsertionControl * myInserter
Controls vehicle insertion;.
Definition: MSNet.h:726
Representation of a vehicle.
Definition: SUMOVehicle.h:61
static const std::set< MSDevice_SSM *, ComparatorNumericalIdLess > & getInstances()
returns all currently existing SSM devices
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:697
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:798
static double getTravelTime(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the travel time to pass an edge.
Definition: MSNet.cpp:151
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:460
void closeSimulation(SUMOTime start)
Closes the simulation (all files, connections, etc.)
Definition: MSNet.cpp:436
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
Definition: MSNet.h:784
bool myLogStepNumber
Information whether the number of the simulation step shall be logged.
Definition: MSNet.h:750
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:843
void abortAnyWaitingForVehicle()
aborts the plan for any transportable that is still waiting for a ride
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:337
SUMOTime getTargetTime() const
Definition: TraCIServer.h:67
MSDetectorControl * myDetectorControl
Controls detectors;.
Definition: MSNet.h:728
static void init()
Static initalization.
Definition: MSVehicle.cpp:377
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:835
double getMinimumTravelTime(const SUMOVehicle *const veh) const
returns the minimum travel time for the given vehicle
Definition: MSEdge.h:419
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:324
#define STEPS2TIME(x)
Definition: SUMOTime.h:57
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
Definition: MSNet.h:724
static void write(OutputDevice &of, SUMOTime timestep)
Produce a VTK output to use with Tools like ParaView.
Definition: MSVTKExport.cpp:43
virtual void addStop(const int stopEdge, const Parameterised &params)=0
The connection to a client was closed by the client.
Definition: MSNet.h:107
The simulation is running.
Definition: MSNet.h:101
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:284
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:819
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:318
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:169
static void postProcessRemoteControl()
Definition: Helper.cpp:801
bool hasInternalLinks() const
return whether the network contains internal links
Definition: MSNet.h:642
bool hasTransportables() const
checks whether any transportable waits to finish her plan
void changeLanes(const SUMOTime t)
Moves (precomputes) critical vehicles.
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
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition: MSNet.cpp:922
static void cleanupAll()
perform cleanup for all devices
Definition: MSDevice.cpp:119
static void cleanup()
properly deletes all trigger instances
Definition: MSTrigger.cpp:44
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:985
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:662
SUMOTime myStateDumpPeriod
The period for writing state.
Definition: MSNet.h:772
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:753
int myMaxTeleports
Maximum number of teleports.
Definition: MSNet.h:703
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:116
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:536
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:241
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
static const std::string STAGE_MOVEMENTS
Definition: MSNet.h:841
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:811
static MSNet * myInstance
Unique instance of MSNet.
Definition: MSNet.h:694
static void clearAll()
Clears all dictionaries.
Definition: MSNet.cpp:639
static void cleanup()
Static cleanup.
Definition: MSVehicle.cpp:382
The simulation is loading.
Definition: MSNet.h:99
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:718
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
Definition: MSNet.h:722
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
virtual int getHaltingVehicleNo() const
Returns the number of halting vehicles.
bool checkWalkingarea()
check all lanes for type walkingArea
Definition: MSNet.cpp:1059
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:390
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:1878
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:716
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:837
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:1045
An external interrupt occured.
Definition: MSNet.h:111
int getPendingFlowCount() const
Returns the number of flows that are still active.
void removePending()
Removes a vehicle after it has ended.
static void cleanup()
remove state at simulation end
Definition: MSPModel.cpp:82
void preSimStepOutput() const
Prints the current step number.
Definition: MSNet.cpp:829
static TraCIServer * getInstance()
Definition: TraCIServer.h:71
MSEventControl * myBeginOfTimestepEvents
Controls events executed at the begin of a time step;.
Definition: MSNet.h:730
A storage for options typed value containers)
Definition: OptionsCont.h:90
static void cleanup()
removes remaining vehicleInformation in sVehicles
static void initStatic()
Place for static initializations of simulation components (called after successful net build) ...
Definition: MSNet.cpp:176
MSEdgeWeightsStorage * myEdgeWeights
The net&#39;s knowledge about edge efforts/travel times;.
Definition: MSNet.h:738
The simulation had too many teleports.
Definition: MSNet.h:113
void prohibit(const std::vector< E *> &toProhibit)
MSNet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents, ShapeContainer *shapeCont=0)
Constructor.
Definition: MSNet.cpp:190
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:1196
long mySimBeginMillis
The overall simulation duration.
Definition: MSNet.h:756
virtual ~MSNet()
Destructor.
Definition: MSNet.cpp:275
bool myHasElevation
Whether the network contains elevation data.
Definition: MSNet.h:790
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:774
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 const std::set< MSDevice_ToC *, ComparatorNumericalIdLess > & getInstances()
returns all currently existing ToC devices
Definition: MSDevice_ToC.h:94
static std::string getStateMessage(SimulationState state)
Returns the message to show if a certain state occurs.
Definition: MSNet.cpp:614
IntermodalRouter< MSEdge, MSLane, MSJunction, SUMOVehicle > MSIntermodalRouter
Definition: MSNet.h:117
SUMOTime myStep
Current time step.
Definition: MSNet.h:700
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:954
The class responsible for building and deletion of vehicles.
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:72
int getDepartedVehicleNo() const
Returns the number of inserted vehicles.
void simulationStep()
Performs a single simulation step.
Definition: MSNet.cpp:457
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:375
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:240
static const std::string STAGE_INSERTIONS
Definition: MSNet.h:843
MSEventControl * myInsertionEvents
Controls insertion events;.
Definition: MSNet.h:734
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:83
std::vector< MSTrafficLightLogic * > getAllLogics() const
Returns a vector which contains all logics.
long mySimStepDuration
Definition: MSNet.h:753
static bool wasClosed()
check whether close was requested
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterEffort(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:974
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:787
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:247
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:825
static void adaptIntermodalRouter(MSIntermodalRouter &router)
Definition: MSNet.cpp:1020
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:381
bool generatesOutput()
Whether this device requested to write output.
Definition: MSDevice_ToC.h:186
The ToC Device controls transition of control between automated and manual driving.
Definition: MSDevice_ToC.h:55
static double getEffort(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the effort to pass an edge.
Definition: MSNet.cpp:137
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net&#39;s internal edge travel times/efforts container.
Definition: MSNet.cpp:820
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:840
int getJammedNumber() const
Returns the number of times a transportables was jammed.