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