SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSNet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
13 // The simulated network and simulation perfomer
14 /****************************************************************************/
15 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
16 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
17 /****************************************************************************/
18 //
19 // This file is part of SUMO.
20 // SUMO is free software: you can redistribute it and/or modify
21 // it under the terms of the GNU General Public License as published by
22 // the Free Software Foundation, either version 3 of the License, or
23 // (at your option) any later version.
24 //
25 /****************************************************************************/
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #ifdef HAVE_VERSION_H
38 #include <version.h>
39 #endif
40 
41 #include <string>
42 #include <iostream>
43 #include <sstream>
44 #include <typeinfo>
45 #include <algorithm>
46 #include <cassert>
47 #include <vector>
49 #include "MSNet.h"
50 #include "MSPersonControl.h"
51 #include "MSEdgeControl.h"
52 #include "MSJunctionControl.h"
53 #include "MSInsertionControl.h"
54 #include "MSEventControl.h"
55 #include "MSEdge.h"
56 #include "MSJunction.h"
57 #include "MSJunctionLogic.h"
58 #include "MSLane.h"
59 #include "MSVehicleTransfer.h"
60 #include "MSRoute.h"
62 #include "trigger/MSTrigger.h"
63 #include "trigger/MSCalibrator.h"
65 #include "MSVehicleControl.h"
67 #include <utils/common/ToString.h>
73 #include <utils/shapes/Polygon.h>
75 
77 #include "output/MSFCDExport.h"
79 #include "output/MSFullExport.h"
80 #include "output/MSQueueExport.h"
81 #include "output/MSVTKExport.h"
82 #include "output/MSXMLRawOut.h"
84 #include <utils/common/SysUtils.h>
87 #include "MSGlobals.h"
89 #include <ctime>
90 #include "MSPerson.h"
91 #include "MSEdgeWeightsStorage.h"
92 #include "MSStateHandler.h"
93 
94 #ifdef HAVE_INTERNAL
95 #include <mesosim/MELoop.h>
97 #endif
98 
99 #ifndef NO_TRACI
101 #endif
102 
103 #ifdef CHECK_MEMORY_LEAKS
104 #include <foreign/nvwa/debug_new.h>
105 #endif // CHECK_MEMORY_LEAKS
106 
107 
108 // ===========================================================================
109 // static member definitions
110 // ===========================================================================
112 
113 
114 // ===========================================================================
115 // member method definitions
116 // ===========================================================================
117 SUMOReal
118 MSNet::getEffort(const MSEdge* const e, const SUMOVehicle* const v, SUMOReal t) {
119  SUMOReal value;
120  const MSVehicle* const veh = dynamic_cast<const MSVehicle* const>(v);
121  if (veh != 0 && veh->getWeightsStorage().retrieveExistingEffort(e, v, t, value)) {
122  return value;
123  }
124  if (getInstance()->getWeightsStorage().retrieveExistingEffort(e, v, t, value)) {
125  return value;
126  }
127  return 0;
128 }
129 
130 
131 SUMOReal
132 MSNet::getTravelTime(const MSEdge* const e, const SUMOVehicle* const v, SUMOReal t) {
133  SUMOReal value;
134  const MSVehicle* const veh = dynamic_cast<const MSVehicle* const>(v);
135  if (veh != 0 && veh->getWeightsStorage().retrieveExistingTravelTime(e, v, t, value)) {
136  return value;
137  }
138  if (getInstance()->getWeightsStorage().retrieveExistingTravelTime(e, v, t, value)) {
139  return value;
140  }
141  return e->getMinimumTravelTime(v);
142 }
143 
144 
145 
146 // ---------------------------------------------------------------------------
147 // MSNet - methods
148 // ---------------------------------------------------------------------------
149 MSNet*
151  if (myInstance != 0) {
152  return myInstance;
153  }
154  throw ProcessError("A network was not yet constructed.");
155 }
156 
157 
158 MSNet::MSNet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
159  MSEventControl* endOfTimestepEvents, MSEventControl* insertionEvents,
160  ShapeContainer* shapeCont):
161  myVehiclesMoved(0),
162  myRouterTTInitialized(false),
163  myRouterTTDijkstra(0),
164  myRouterTTAStar(0),
165  myRouterEffort(0) {
166  if (myInstance != 0) {
167  throw ProcessError("A network was already constructed.");
168  }
170  myStep = string2time(oc.getString("begin"));
171  myLogExecutionTime = !oc.getBool("no-duration-log");
172  myLogStepNumber = !oc.getBool("no-step-log");
173  myTooManyVehicles = oc.getInt("max-num-vehicles");
174  myInserter = new MSInsertionControl(*vc, string2time(oc.getString("max-depart-delay")), !oc.getBool("eager-insert"));
175  myVehicleControl = vc;
177  myEdges = 0;
178  myJunctions = 0;
179  myRouteLoaders = 0;
180  myLogics = 0;
181  myPersonControl = 0;
182  myEdgeWeights = 0;
183  myShapeContainer = shapeCont == 0 ? new ShapeContainer() : shapeCont;
184 
185  myBeginOfTimestepEvents = beginOfTimestepEvents;
186  myEndOfTimestepEvents = endOfTimestepEvents;
187  myInsertionEvents = insertionEvents;
188  myLanesRTree.first = false;
189 
190 #ifdef HAVE_INTERNAL
192  MSGlobals::gMesoNet = new MELoop(string2time(oc.getString("meso-recheck")));
193  }
194 #endif
195  myInstance = this;
196 }
197 
198 
199 
200 
201 void
203  SUMORouteLoaderControl* routeLoaders,
204  MSTLLogicControl* tlc,
205  std::vector<SUMOTime> stateDumpTimes,
206  std::vector<std::string> stateDumpFiles) {
207  myEdges = edges;
208  myJunctions = junctions;
209  myRouteLoaders = routeLoaders;
210  myLogics = tlc;
211  // save the time the network state shall be saved at
212  myStateDumpTimes = stateDumpTimes;
213  myStateDumpFiles = stateDumpFiles;
214 
215  // set requests/responses
217 
218  // initialise performance computation
219  if (myLogExecutionTime) {
221  }
222 }
223 
224 
226  // delete events first maybe they do some cleanup
228  delete myEndOfTimestepEvents;
229  delete myInsertionEvents;
230  // delete controls
231  delete myJunctions;
232  delete myDetectorControl;
233  // delete mean data
234  delete myEdges;
235  delete myInserter;
236  delete myLogics;
237  delete myRouteLoaders;
238  delete myVehicleControl;
239  if (myPersonControl != 0) {
240  delete myPersonControl;
241  }
242  delete myShapeContainer;
243  delete myEdgeWeights;
244  delete myRouterTTDijkstra;
245  delete myRouterTTAStar;
246  delete myRouterEffort;
247  myLanesRTree.second.RemoveAll();
248  clearAll();
249 #ifdef HAVE_INTERNAL
251  delete MSGlobals::gMesoNet;
252  }
253 #endif
254  myInstance = 0;
255 }
256 
257 
258 int
260  // report the begin when wished
261  WRITE_MESSAGE("Simulation started with time: " + time2string(start));
262  // the simulation loop
264  myStep = start;
265  // preload the routes especially for TraCI
266  loadRoutes();
267 #ifndef NO_TRACI
268 #ifdef HAVE_PYTHON
269  if (OptionsCont::getOptions().isSet("python-script")) {
270  TraCIServer::runEmbedded(OptionsCont::getOptions().getString("python-script"));
271  closeSimulation(start);
272  WRITE_MESSAGE("Simulation ended at time: " + time2string(getCurrentTimeStep()));
273  WRITE_MESSAGE("Reason: Script ended");
274  return 0;
275  }
276 #endif
277 #endif
278  while (state == SIMSTATE_RUNNING) {
279  if (myLogStepNumber) {
281  }
282  simulationStep();
283  if (myLogStepNumber) {
285  }
286  state = simulationState(stop);
287 #ifndef NO_TRACI
288  if (state != SIMSTATE_RUNNING) {
289  if (OptionsCont::getOptions().getInt("remote-port") != 0 && !TraCIServer::wasClosed()) {
290  state = SIMSTATE_RUNNING;
291  }
292  }
293 #endif
294  }
295  // report the end when wished
296  WRITE_MESSAGE("Simulation ended at time: " + time2string(getCurrentTimeStep()));
297  WRITE_MESSAGE("Reason: " + getStateMessage(state));
298  // exit simulation loop
299  closeSimulation(start);
300  return 0;
301 }
302 
303 void
306 }
307 
308 
309 void
311  if (myLogExecutionTime) {
312  long duration = SysUtils::getCurrentMillis() - mySimBeginMillis;
313  std::ostringstream msg;
314  msg << "Performance: " << "\n" << " Duration: " << duration << " ms" << "\n";
315  if (duration != 0) {
316  msg << " Real time factor: " << (STEPS2TIME(myStep - start) * 1000. / (SUMOReal)duration) << "\n";
317  msg.setf(std::ios::fixed , std::ios::floatfield); // use decimal format
318  msg.setf(std::ios::showpoint); // print decimal point
319  msg << " UPS: " << ((SUMOReal)myVehiclesMoved / ((SUMOReal)duration / 1000)) << "\n";
320  }
321  // prepare optional statistics
322  const std::string discardNotice = ((myVehicleControl->getLoadedVehicleNo() != myVehicleControl->getDepartedVehicleNo()) ?
323  " (Loaded: " + toString(myVehicleControl->getLoadedVehicleNo()) + ")" : "");
324  const std::string collisionNotice = (
326  " (Collisions: " + toString(myVehicleControl->getCollisionCount()) + ")" : "");
327  const std::string teleportNotice = (
329  "Teleports: " + toString(myVehicleControl->getTeleportCount()) + collisionNotice + "\n" : "");
330  // print statistics
331  msg << "Vehicles: " << "\n"
332  << " Emitted: " << myVehicleControl->getDepartedVehicleNo() << discardNotice << "\n"
333  << " Running: " << myVehicleControl->getRunningVehicleNo() << "\n"
334  << " Waiting: " << myInserter->getWaitingVehicleNo() << "\n"
335  << teleportNotice;
336  WRITE_MESSAGE(msg.str());
337  }
339  if (OptionsCont::getOptions().getBool("vehroute-output.write-unfinished")) {
341  }
342 #ifndef NO_TRACI
344 #endif
345 }
346 
347 
348 void
350 #ifndef NO_TRACI
353  if (t != 0 && t->getTargetTime() != 0 && t->getTargetTime() < myStep) {
354  return;
355  }
356 #endif
357  // execute beginOfTimestepEvents
358  if (myLogExecutionTime) {
360  }
361  // simulation state output
362  std::vector<SUMOTime>::iterator timeIt = find(myStateDumpTimes.begin(), myStateDumpTimes.end(), myStep);
363  if (timeIt != myStateDumpTimes.end()) {
364  const int dist = (int)distance(myStateDumpTimes.begin(), timeIt);
366  }
370  }
371  // check whether the tls programs need to be switched
373 
374 #ifdef HAVE_INTERNAL
376  MSGlobals::gMesoNet->simulate(myStep);
377  } else {
378 #endif
379 
380  // assure all lanes with vehicles are 'active'
382 
383  // compute safe velocities for all vehicles for the next few lanes
384  // also register ApproachingVehicleInformation for all links
386 
387  // decide right-of-way and execute movements
391  }
392 
393  // Vehicles change Lanes (maybe)
395 
398  }
399 #ifdef HAVE_INTERNAL
400  }
401 #endif
402  loadRoutes();
403 
404  // persons
405  if (myPersonControl != 0) {
407  }
408  // emit Vehicles
413  }
415 
416  // execute endOfTimestepEvents
418 
419 #ifndef NO_TRACI
420  if (TraCIServer::getInstance() != 0) {
422  }
423 #endif
424  // update and write (if needed) detector values
425  writeOutput();
426 
427  if (myLogExecutionTime) {
431  }
432  myStep += DELTA_T;
433 }
434 
435 
440  }
441 #ifndef NO_TRACI
442  if (TraCIServer::wasClosed()) {
444  }
445  if (stopTime < 0 && OptionsCont::getOptions().getInt("remote-port") == 0) {
446 #else
447  if (stopTime < 0) {
448 #endif
451  && (myInserter->getPendingFlowCount() == 0)
452  && (myPersonControl == 0 || !myPersonControl->hasNonWaiting())) {
453  if (myPersonControl) {
455  }
458  }
459  }
460  if (stopTime >= 0 && myStep >= stopTime) {
462  }
463  return SIMSTATE_RUNNING;
464 }
465 
466 
467 std::string
469  switch (state) {
471  return "";
473  return "The final simulation step has been reached.";
475  return "All vehicles have left the simulation.";
477  return "TraCI requested termination.";
479  return "An error occured (see log).";
481  return "Too many vehicles.";
482  default:
483  return "Unknown reason.";
484  }
485 }
486 
487 
488 void
490  // clear container
491  MSEdge::clear();
492  MSLane::clear();
493  MSRoute::clear();
498 }
499 
500 
501 SUMOTime
503  return myStep;
504 }
505 
506 
507 void
509  // update detector values
511 
512  // check state dumps
513  if (OptionsCont::getOptions().isSet("netstate-dump")) {
515  }
516 
517  // check fcd dumps
518  if (OptionsCont::getOptions().isSet("fcd-output")) {
520  }
521 
522  // check emission dumps
523  if (OptionsCont::getOptions().isSet("emission-output")) {
525  }
526 
527  // check full dumps
528  if (OptionsCont::getOptions().isSet("full-output")) {
530  }
531 
532  // check queue dumps
533  if (OptionsCont::getOptions().isSet("queue-output")) {
535  }
536 
537  // check vtk dumps
538  if (OptionsCont::getOptions().isSet("vtk-output")) {
539 
540  if (MSNet::getInstance()->getVehicleControl().getRunningVehicleNo() > 0) {
541  std::string timestep = time2string(myStep);
542  timestep = timestep.substr(0, timestep.length() - 3);
543  std::string output = OptionsCont::getOptions().getString("vtk-output");
544  std::string filename = output + "_" + timestep + ".vtp";
545 
546  OutputDevice_File dev = OutputDevice_File(filename, false);
547 
548  //build a huge mass of xml files
550 
551  }
552 
553  }
554 
555  // summary output
556  if (OptionsCont::getOptions().isSet("summary-output")) {
557  OutputDevice& od = OutputDevice::getDeviceByOption("summary-output");
558  unsigned int departedVehiclesNumber = myVehicleControl->getDepartedVehicleNo();
559  const SUMOReal meanWaitingTime = departedVehiclesNumber != 0 ? myVehicleControl->getTotalDepartureDelay() / (SUMOReal) departedVehiclesNumber : -1.;
560  unsigned int endedVehicleNumber = myVehicleControl->getEndedVehicleNo();
561  const SUMOReal meanTravelTime = endedVehicleNumber != 0 ? myVehicleControl->getTotalTravelTime() / (SUMOReal) endedVehicleNumber : -1.;
563  .writeAttr("inserted", myVehicleControl->getDepartedVehicleNo()).writeAttr("running", myVehicleControl->getRunningVehicleNo())
564  .writeAttr("waiting", myInserter->getWaitingVehicleNo()).writeAttr("ended", myVehicleControl->getEndedVehicleNo())
565  .writeAttr("meanWaitingTime", meanWaitingTime).writeAttr("meanTravelTime", meanTravelTime);
566  if (myLogExecutionTime) {
567  od.writeAttr("duration", mySimStepDuration);
568  }
569  od.closeTag();
570  }
571 
572  // write detector values
574 
575  // write link states
576  if (OptionsCont::getOptions().isSet("link-output")) {
577  OutputDevice& od = OutputDevice::getDeviceByOption("link-output");
578  od.openTag("timestep");
580  const std::vector<MSEdge*>& edges = myEdges->getEdges();
581  for (std::vector<MSEdge*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
582  const std::vector<MSLane*>& lanes = (*i)->getLanes();
583  for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
584  const std::vector<MSLink*>& links = (*j)->getLinkCont();
585  for (std::vector<MSLink*>::const_iterator k = links.begin(); k != links.end(); ++k) {
586  (*k)->writeApproaching(od, (*j)->getID());
587  }
588  }
589  }
590  od.closeTag();
591  }
592 }
593 
594 
595 bool
597  return myLogExecutionTime;
598 }
599 
600 
603  if (myPersonControl == 0) {
605  }
606  return *myPersonControl;
607 }
608 
609 
612  if (myEdgeWeights == 0) {
614  }
615  return *myEdgeWeights;
616 }
617 
618 
619 void
621  std::cout << "Step #" << time2string(myStep);
622 }
623 
624 
625 void
627  if (myLogExecutionTime) {
628  std::ostringstream oss;
629  oss.setf(std::ios::fixed , std::ios::floatfield); // use decimal format
630  oss.setf(std::ios::showpoint); // print decimal point
631  oss << std::setprecision(OUTPUT_ACCURACY);
632  if (mySimStepDuration != 0) {
633  oss << " (" << mySimStepDuration << "ms ~= "
634  << (1000. / (SUMOReal) mySimStepDuration) << "*RT, ~"
636  } else {
637  oss << " (0ms ?*RT. ?";
638  }
639  oss << "UPS, vehicles"
640  << " TOT " << myVehicleControl->getDepartedVehicleNo()
641  << " ACT " << myVehicleControl->getRunningVehicleNo()
642  << ") ";
643  std::string prev = "Step #" + time2string(myStep - DELTA_T);
644  std::cout << oss.str().substr(0, 78 - prev.length());
645  }
646  std::cout << '\r';
647 }
648 
649 
650 void
652  if (find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener) == myVehicleStateListeners.end()) {
653  myVehicleStateListeners.push_back(listener);
654  }
655 }
656 
657 
658 void
660  std::vector<VehicleStateListener*>::iterator i = find(myVehicleStateListeners.begin(), myVehicleStateListeners.end(), listener);
661  if (i != myVehicleStateListeners.end()) {
662  myVehicleStateListeners.erase(i);
663  }
664 }
665 
666 
667 void
669  for (std::vector<VehicleStateListener*>::iterator i = myVehicleStateListeners.begin(); i != myVehicleStateListeners.end(); ++i) {
670  (*i)->vehicleStateChanged(vehicle, to);
671  }
672 }
673 
674 
675 
676 // ------ Insertion and retrieval of bus stops ------
677 bool
679  return myBusStopDict.add(busStop->getID(), busStop);
680 }
681 
682 
683 MSBusStop*
684 MSNet::getBusStop(const std::string& id) const {
685  return myBusStopDict.get(id);
686 }
687 
688 
689 std::string
690 MSNet::getBusStopID(const MSLane* lane, const SUMOReal pos) const {
691  const std::map<std::string, MSBusStop*>& vals = myBusStopDict.getMyMap();
692  for (std::map<std::string, MSBusStop*>::const_iterator it = vals.begin(); it != vals.end(); ++it) {
693  MSBusStop* stop = it->second;
694  if (&stop->getLane() == lane && fabs(stop->getEndLanePosition() - pos) < POSITION_EPS) {
695  return stop->getID();
696  }
697  }
698  return "";
699 }
700 
701 
703 MSNet::getRouterTT(const std::vector<MSEdge*>& prohibited) const {
704  if (!myRouterTTInitialized) {
705  myRouterTTInitialized = true;
706  const std::string routingAlgorithm = OptionsCont::getOptions().getString("routing-algorithm");
707  if (routingAlgorithm == "dijkstra") {
710  } else {
711  if (routingAlgorithm != "astar") {
712  WRITE_WARNING("TraCI and Triggers cannot use routing algorithm '" + routingAlgorithm + "'. using 'astar' instead.");
713  }
716  }
717  }
718  if (myRouterTTDijkstra != 0) {
719  myRouterTTDijkstra->prohibit(prohibited);
720  return *myRouterTTDijkstra;
721  } else {
722  assert(myRouterTTAStar != 0);
723  myRouterTTAStar->prohibit(prohibited);
724  return *myRouterTTAStar;
725  }
726 }
727 
728 
730 MSNet::getRouterEffort(const std::vector<MSEdge*>& prohibited) const {
731  if (myRouterEffort == 0) {
734  }
735  myRouterEffort->prohibit(prohibited);
736  return *myRouterEffort;
737 }
738 
739 
740 const NamedRTree&
742  if (!myLanesRTree.first) {
743  MSLane::fill(myLanesRTree.second);
744  myLanesRTree.first = true;
745  }
746  return myLanesRTree.second;
747 }
748 
749 
750 /****************************************************************************/
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:254
int getPendingFlowCount() const
Returns the number of flows that are still active.
void postSimStepOutput() const
Prints the statistics of the step at its end.
Definition: MSNet.cpp:626
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
Interface for objects listening to vehicle state changes.
Definition: MSNet.h:434
long mySimStepEnd
Definition: MSNet.h:561
void loadNext(SUMOTime step)
loads the next routes
void removeVehicleStateListener(VehicleStateListener *listener)
Removes a vehicle states listener.
Definition: MSNet.cpp:659
unsigned int getRunningVehicleNo() const
Returns the number of build and inserted, but not yet deleted vehicles.
MSEventControl * myEndOfTimestepEvents
Controls events executed at the end of a time step;.
Definition: MSNet.h:540
static SUMOReal getEffort(const MSEdge *const e, const SUMOVehicle *const v, SUMOReal t)
Returns the effort to pass an edge.
Definition: MSNet.cpp:118
SUMOReal getTotalDepartureDelay() const
Returns the total departure delay.
unsigned int getDepartedVehicleNo() const
Returns the number of inserted vehicles.
static size_t numericalDictSize()
Returns the number of edges with a numerical id.
Definition: MSEdge.cpp:505
The simulation contains too many vehicles (.
Definition: MSNet.h:106
virtual bool add(const std::string &id, T item)
Adds an item.
void patchActiveLanes()
Resets information whether a lane is active for all lanes.
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
Definition: MSNet.h:524
bool retrieveExistingTravelTime(const MSEdge *const e, const SUMOVehicle *const v, SUMOReal t, SUMOReal &value) const
Returns a travel time for an edge and time if stored.
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition: MSLane.cpp:852
void updateDetectors(const SUMOTime step)
Computes detector values.
std::vector< SUMOTime > myStateDumpTimes
Times at which a state shall be written.
Definition: MSNet.h:576
virtual void execute(SUMOTime time)
Executes time-dependant commands.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
int simulate(SUMOTime start, SUMOTime stop)
Simulates from timestep start to stop.
Definition: MSNet.cpp:259
void changeLanes(SUMOTime t)
Moves (precomputes) critical vehicles.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:61
A RT-tree for efficient storing of SUMO&#39;s Named objects.
Definition: NamedRTree.h:60
int getActiveVehicleCount() const
Returns the number of build vehicles that have not been removed or need to wait for a passenger...
MSPersonControl * myPersonControl
Controls person building and deletion;.
Definition: MSNet.h:526
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:150
MSEdgeControl * myEdges
Controls edges, performs vehicle movement;.
Definition: MSNet.h:528
The final simulation step has been performed.
Definition: MSNet.h:98
void writeOutput(SUMOTime step, bool closing)
Writes the output to be generated within the given time step.
std::vector< std::string > myStateDumpFiles
The names for the state files.
Definition: MSNet.h:578
bool myLogExecutionTime
Information whether the simulation duration shall be logged.
Definition: MSNet.h:555
Storage for geometrical objects.
static void write(OutputDevice &of, SUMOTime timestep)
Dumping a hugh List of Parameters available in the Simulation.
SUMOReal getEndLanePosition() const
Returns the end position of this bus stop.
Definition: MSBusStop.cpp:71
bool retrieveExistingEffort(const MSEdge *const e, const SUMOVehicle *const v, SUMOReal t, SUMOReal &value) const
Returns an effort for an edge and time if stored.
Detectors container; responsible for string and output generation.
A storage for edge travel times and efforts.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step (in s)
Definition: MSNet.cpp:502
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterEffort(const std::vector< MSEdge * > &prohibited=std::vector< MSEdge * >()) const
Definition: MSNet.cpp:730
std::string getBusStopID(const MSLane *lane, const SUMOReal pos) const
Returns the bus stop close to the given position.
Definition: MSNet.cpp:690
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition: MSNet.cpp:651
SimulationState
Possible states of a simulation - running or stopped with different reasons.
Definition: MSNet.h:94
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:196
The simulated network and simulation perfomer.
Definition: MSNet.h:89
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
SUMOLong myVehiclesMoved
The overall number of vehicle movements.
Definition: MSNet.h:567
ShapeContainer * myShapeContainer
A container for geometrical shapes;.
Definition: MSNet.h:544
std::pair< bool, NamedRTree > myLanesRTree
An RTree structure holding lane IDs.
Definition: MSNet.h:604
const MSLane & getLane() const
Returns the lane this bus stop is located at.
Definition: MSBusStop.cpp:59
Container for junctions; performs operations on all stored junctions.
SUMOReal getTotalTravelTime() const
Returns the total travel time.
bool addBusStop(MSBusStop *busStop)
Adds a bus stop.
Definition: MSNet.cpp:678
static bool gCheck4Accidents
Definition: MSGlobals.h:76
#define OUTPUT_ACCURACY
Definition: config.h:162
static void write(OutputDevice &of, SUMOTime timestep)
Export the queueing length in front of a junction (very experimental!)
void postProcessVTD()
T get(const std::string &id) const
Retrieves an item.
static void write(OutputDevice &of, SUMOTime timestep)
Writes the complete network state of the given edges into the given device.
unsigned int getCollisionCount() const
return the number of collisions
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)
const std::string & getID() const
Returns the id.
Definition: Named.h:60
A road/street connecting two junctions.
Definition: MSEdge.h:73
void prohibit(const std::vector< E * > &toProhibit)
long mySimStepBegin
The last simulation step begin, end and duration.
Definition: MSNet.h:561
static void close()
request termination of connection
The simulation does not contain further vehicles.
Definition: MSNet.h:100
void detectCollisions(SUMOTime timestep, int stage)
Detect collisions.
unsigned int getLoadedVehicleNo() const
Returns the number of build vehicles.
An error occured during the simulation step.
Definition: MSNet.h:104
static void clear()
Clears the dictionary (delete all known routes, too)
Definition: MSRoute.cpp:159
void writeOutput()
Write netstate, summary and detector output.
Definition: MSNet.cpp:508
unsigned int getTeleportCount() const
return the number of teleports (including collisions)
unsigned int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
void abortWaiting()
aborts the plan for any person that is still waiting for a ride
MSInsertionControl * myInserter
Controls vehicle insertion;.
Definition: MSNet.h:534
Representation of a vehicle.
Definition: SUMOVehicle.h:63
void checkInsertions(SUMOTime time)
Checks &quot;movement&quot; of stored vehicles.
static void write(OutputDevice &of, SUMOTime timestep)
Writes the posion and the angle of each vehcile into the given device.
Definition: MSFCDExport.cpp:56
SUMORouteLoaderControl * myRouteLoaders
Route loader for dynamic loading of routes.
Definition: MSNet.h:513
void closeSimulation(SUMOTime start)
Closes the simulation (all files, connections, etc.)
Definition: MSNet.cpp:310
bool myLogStepNumber
Information whether the number of the simulation step shall be logged.
Definition: MSNet.h:558
A lane area vehicles can halt at.
Definition: MSBusStop.h:63
An output device that encapsulates an ofstream.
static void clear()
Clears the dictionary.
Definition: MSEdge.cpp:511
SUMOTime getTargetTime()
Definition: TraCIServer.h:80
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:253
static SUMOReal getTravelTime(const MSEdge *const e, const SUMOVehicle *const v, SUMOReal t)
Returns the travel time to pass an edge.
Definition: MSNet.cpp:132
MSDetectorControl * myDetectorControl
Controls detectors;.
Definition: MSNet.h:536
void checkWaitingPersons(MSNet *net, const SUMOTime time)
checks whether any persons waiting or walking time is over
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:73
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
Definition: MSNet.h:532
static void write(OutputDevice &of, SUMOTime timestep)
Produce a VTK output to use with Tools like ParaView.
Definition: MSVTKExport.cpp:57
The connection to a client was closed by the client.
Definition: MSNet.h:102
DijkstraRouterTT_ByProxi< MSEdge, SUMOVehicle, prohibited_withRestrictions< MSEdge, SUMOVehicle > > * myRouterTTDijkstra
Definition: MSNet.h:598
The simulation is running.
Definition: MSNet.h:96
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:48
void check2Switch(SUMOTime step)
Checks whether any WAUT is trying to switch a tls into another program.
#define POSITION_EPS
Definition: config.h:186
void preSimStepOutput() const
Prints the current step number.
Definition: MSNet.cpp:620
MSBusStop * getBusStop(const std::string &id) const
Returns the named bus stop.
Definition: MSNet.cpp:684
static void cleanup()
properly deletes all trigger instances
Definition: MSTrigger.cpp:46
AStarRouterTT_ByProxi< MSEdge, SUMOVehicle, prohibited_withRestrictions< MSEdge, SUMOVehicle > > * myRouterTTAStar
Definition: MSNet.h:599
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:51
TraCI server used to control sumo by a remote TraCI client.
Definition: TraCIServer.h:74
static void generateOutputForUnfinished()
generate vehroute output for vehicles which are still in the network
Inserts vehicles into the network when their departure time is reached.
void postloadInitContainer()
Closes building of junctions.
void abortWaiting()
removes any vehicles that are still waiting
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:407
bool hasNonWaiting() const
checks whether any person is still engaged in walking / stopping
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
const IDMap & getMyMap() const
static void processCommandsUntilSimStep(SUMOTime step)
process all commands until a simulation step is wanted
std::vector< VehicleStateListener * > myVehicleStateListeners
Container for vehicle state listener.
Definition: MSNet.h:590
static MSNet * myInstance
Unique instance of MSNet.
Definition: MSNet.h:510
bool isEmpty()
Returns whether events are in the que.
static void clearAll()
Clears all dictionaries.
Definition: MSNet.cpp:489
bool myRouterTTInitialized
Definition: MSNet.h:597
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.
void close(SUMOTime step)
Closes the detector outputs.
SimulationState simulationState(SUMOTime stopTime) const
Called after a simulation step, this method returns the current simulation state. ...
Definition: MSNet.cpp:437
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
Definition: MSNet.h:530
virtual MSPersonControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:602
static void clear()
Clears the dictionary.
Definition: MSLane.cpp:835
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
static TraCIServer * getInstance()
Definition: TraCIServer.h:83
MSEventControl * myBeginOfTimestepEvents
Controls events executed at the begin of a time step;.
Definition: MSNet.h:538
A storage for options typed value containers)
Definition: OptionsCont.h:108
MSEdgeWeightsStorage * myEdgeWeights
The net&#39;s knowledge about edge efforts/travel times;.
Definition: MSNet.h:546
MSNet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents, ShapeContainer *shapeCont=0)
Constructor.
Definition: MSNet.cpp:158
unsigned int emitVehicles(SUMOTime time)
Emits vehicles that want to depart at the given time.
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const std::vector< MSEdge * > &prohibited=std::vector< MSEdge * >()) const
Definition: MSNet.cpp:703
int SUMOTime
Definition: SUMOTime.h:43
unsigned int getEndedVehicleNo() const
Returns the number of removed vehicles.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to)
Informs all added listeners about a vehicle&#39;s state change.
Definition: MSNet.cpp:668
const NamedRTree & getLanesRTree() const
Returns an RTree that contains lane IDs.
Definition: MSNet.cpp:741
static void cleanup()
cleanup remaining data structures
long mySimBeginMillis
The overall simulation duration.
Definition: MSNet.h:564
virtual ~MSNet()
Destructor.
Definition: MSNet.cpp:225
const std::vector< MSEdge * > & getEdges() const
Returns loaded edges.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
static void cleanup()
deletes the router instance
bool closeTag()
Closes the most recently opened tag.
#define SUMOReal
Definition: config.h:215
static const bool gUseMesoSim
Definition: MSGlobals.h:98
static std::string getStateMessage(SimulationState state)
Returns the message to show if a certain state occurs.
Definition: MSNet.cpp:468
SUMOReal getMinimumTravelTime(const SUMOVehicle *const veh) const
returns the minimum travel time for the given vehicle
Definition: MSEdge.h:312
bool logSimulationDuration() const
Returns whether duration shall be logged.
Definition: MSNet.cpp:596
#define DELTA_T
Definition: SUMOTime.h:50
SUMOTime myStep
Current time step.
Definition: MSNet.h:516
The class responsible for building and deletion of vehicles.
void closeBuilding(MSEdgeControl *edges, MSJunctionControl *junctions, SUMORouteLoaderControl *routeLoaders, MSTLLogicControl *tlc, std::vector< SUMOTime > stateDumpTimes, std::vector< std::string > stateDumpFiles)
Closes the network&#39;s building process.
Definition: MSNet.cpp:202
NamedObjectCont< MSBusStop * > myBusStopDict
Dictionary of bus stops.
Definition: MSNet.h:587
void simulationStep()
Performs a single simulation step.
Definition: MSNet.cpp:349
static long getCurrentMillis()
Returns the current time in milliseconds.
Definition: SysUtils.cpp:48
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:304
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:197
MSEventControl * myInsertionEvents
Controls insertion events;.
Definition: MSNet.h:542
int myTooManyVehicles
Storage for maximum vehicle number.
Definition: MSNet.h:584
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle&#39;s internal edge travel times/efforts container.
Definition: MSVehicle.cpp:511
long mySimStepDuration
Definition: MSNet.h:561
static bool wasClosed()
check whether close was requested
Stores time-dependant events and executes them at the proper time.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static void write(OutputDevice &of, const MSEdgeControl &ec, SUMOTime timestep)
Writes the complete network state of the given edges into the given device.
Definition: MSXMLRawOut.cpp:58
static void saveState(const std::string &file, SUMOTime step)
Saves the current state.
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net&#39;s internal edge travel times/efforts container.
Definition: MSNet.cpp:611
DijkstraRouterEffort_ByProxi< MSEdge, SUMOVehicle, prohibited_withRestrictions< MSEdge, SUMOVehicle > > * myRouterEffort
Definition: MSNet.h:600