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 
189 #ifdef HAVE_INTERNAL
191  MSGlobals::gMesoNet = new MELoop(string2time(oc.getString("meso-recheck")));
192  }
193 #endif
194  myInstance = this;
195 }
196 
197 
198 
199 
200 void
202  SUMORouteLoaderControl* routeLoaders,
203  MSTLLogicControl* tlc,
204  std::vector<SUMOTime> stateDumpTimes,
205  std::vector<std::string> stateDumpFiles) {
206  myEdges = edges;
207  myJunctions = junctions;
208  myRouteLoaders = routeLoaders;
209  myLogics = tlc;
210  // save the time the network state shall be saved at
211  myStateDumpTimes = stateDumpTimes;
212  myStateDumpFiles = stateDumpFiles;
213 
214  // set requests/responses
216 
217  // initialise performance computation
218  if (myLogExecutionTime) {
220  }
221 }
222 
223 
225  // delete events first maybe they do some cleanup
227  delete myEndOfTimestepEvents;
228  delete myInsertionEvents;
229  // delete controls
230  delete myJunctions;
231  delete myDetectorControl;
232  // delete mean data
233  delete myEdges;
234  delete myInserter;
235  delete myLogics;
236  delete myRouteLoaders;
237  delete myVehicleControl;
238  if (myPersonControl != 0) {
239  delete myPersonControl;
240  }
241  delete myShapeContainer;
242  delete myEdgeWeights;
243  delete myRouterTTDijkstra;
244  delete myRouterTTAStar;
245  delete myRouterEffort;
246 #ifdef HAVE_INTERNAL
248  delete MSGlobals::gMesoNet;
249  }
250 #endif
251  clearAll();
252  myInstance = 0;
253 }
254 
255 
256 int
258  // report the begin when wished
259  WRITE_MESSAGE("Simulation started with time: " + time2string(start));
260  // the simulation loop
262  myStep = start;
263  // preload the routes especially for TraCI
264  loadRoutes();
265 #ifndef NO_TRACI
266 #ifdef HAVE_PYTHON
267  if (OptionsCont::getOptions().isSet("python-script")) {
268  traci::TraCIServer::runEmbedded(OptionsCont::getOptions().getString("python-script"));
269  closeSimulation(start);
270  WRITE_MESSAGE("Simulation ended at time: " + time2string(getCurrentTimeStep()));
271  WRITE_MESSAGE("Reason: Script ended");
272  return 0;
273  }
274 #endif
275 #endif
276  while (state == SIMSTATE_RUNNING) {
277  if (myLogStepNumber) {
279  }
280  simulationStep();
281  if (myLogStepNumber) {
283  }
284  state = simulationState(stop);
285 #ifndef NO_TRACI
286  if (state != SIMSTATE_RUNNING) {
287  if (OptionsCont::getOptions().getInt("remote-port") != 0 && !traci::TraCIServer::wasClosed()) {
288  state = SIMSTATE_RUNNING;
289  }
290  }
291 #endif
292  }
293  // report the end when wished
294  WRITE_MESSAGE("Simulation ended at time: " + time2string(getCurrentTimeStep()));
295  WRITE_MESSAGE("Reason: " + getStateMessage(state));
296  // exit simulation loop
297  closeSimulation(start);
298  return 0;
299 }
300 
301 void
304 }
305 
306 
307 void
309  if (myLogExecutionTime) {
310  long duration = SysUtils::getCurrentMillis() - mySimBeginMillis;
311  std::ostringstream msg;
312  msg << "Performance: " << "\n" << " Duration: " << duration << " ms" << "\n";
313  if (duration != 0) {
314  msg << " Real time factor: " << (STEPS2TIME(myStep - start) * 1000. / (SUMOReal)duration) << "\n";
315  msg.setf(std::ios::fixed , std::ios::floatfield); // use decimal format
316  msg.setf(std::ios::showpoint); // print decimal point
317  msg << " UPS: " << ((SUMOReal)myVehiclesMoved / ((SUMOReal)duration / 1000)) << "\n";
318  }
319  // prepare optional statistics
320  const std::string discardNotice = ((myVehicleControl->getLoadedVehicleNo() != myVehicleControl->getDepartedVehicleNo()) ?
321  " (Loaded: " + toString(myVehicleControl->getLoadedVehicleNo()) + ")" : "");
322  const std::string collisionNotice = (
324  " (Collisions: " + toString(myVehicleControl->getCollisionCount()) + ")" : "");
325  const std::string teleportNotice = (
327  "Teleports: " + toString(myVehicleControl->getTeleportCount()) + collisionNotice + "\n" : "");
328  // print statistics
329  msg << "Vehicles: " << "\n"
330  << " Emitted: " << myVehicleControl->getDepartedVehicleNo() << discardNotice << "\n"
331  << " Running: " << myVehicleControl->getRunningVehicleNo() << "\n"
332  << " Waiting: " << myInserter->getWaitingVehicleNo() << "\n"
333  << teleportNotice;
334  WRITE_MESSAGE(msg.str());
335  }
337  if (OptionsCont::getOptions().getBool("vehroute-output.write-unfinished")) {
339  }
340 #ifndef NO_TRACI
342 #endif
343 }
344 
345 
346 void
348 #ifndef NO_TRACI
351  if (t != 0 && t->getTargetTime() != 0 && t->getTargetTime() < myStep) {
352  return;
353  }
354 #endif
355  // execute beginOfTimestepEvents
356  if (myLogExecutionTime) {
358  }
359  // simulation state output
360  std::vector<SUMOTime>::iterator timeIt = find(myStateDumpTimes.begin(), myStateDumpTimes.end(), myStep);
361  if (timeIt != myStateDumpTimes.end()) {
362  const int dist = (int)distance(myStateDumpTimes.begin(), timeIt);
364  }
368  }
369  // check whether the tls programs need to be switched
371 
372 #ifdef HAVE_INTERNAL
374  MSGlobals::gMesoNet->simulate(myStep);
375  } else {
376 #endif
377 
378  // assure all lanes with vehicles are 'active'
380 
381  // compute safe velocities for all vehicles for the next few lanes
382  // also register ApproachingVehicleInformation for all links
384 
385  // decide right-of-way and execute movements
389  }
390 
391  // Vehicles change Lanes (maybe)
393 
396  }
397 #ifdef HAVE_INTERNAL
398  }
399 #endif
400  loadRoutes();
401 
402  // persons
403  if (myPersonControl != 0) {
405  }
406  // emit Vehicles
411  }
413 
414  // execute endOfTimestepEvents
416 
417 #ifndef NO_TRACI
418  if (traci::TraCIServer::getInstance() != 0) {
420  }
421 #endif
422  // update and write (if needed) detector values
423  writeOutput();
424 
425  if (myLogExecutionTime) {
429  }
430  myStep += DELTA_T;
431 }
432 
433 
438  }
439 #ifndef NO_TRACI
442  }
443  if (stopTime < 0 && OptionsCont::getOptions().getInt("remote-port") == 0) {
444 #else
445  if (stopTime < 0) {
446 #endif
449  && (myInserter->getPendingFlowCount() == 0)
450  && (myPersonControl == 0 || !myPersonControl->hasNonWaiting())) {
451  if (myPersonControl) {
453  }
456  }
457  }
458  if (stopTime >= 0 && myStep >= stopTime) {
460  }
461  return SIMSTATE_RUNNING;
462 }
463 
464 
465 std::string
467  switch (state) {
469  return "";
471  return "The final simulation step has been reached.";
473  return "All vehicles have left the simulation.";
475  return "TraCI requested termination.";
477  return "An error occured (see log).";
479  return "Too many vehicles.";
480  default:
481  return "Unknown reason.";
482  }
483 }
484 
485 
486 void
488  // clear container
489  MSEdge::clear();
490  MSLane::clear();
491  MSRoute::clear();
496 }
497 
498 
499 SUMOTime
501  return myStep;
502 }
503 
504 
505 void
507  // update detector values
509 
510  // check state dumps
511  if (OptionsCont::getOptions().isSet("netstate-dump")) {
513  }
514 
515  // check fcd dumps
516  if (OptionsCont::getOptions().isSet("fcd-output")) {
518  }
519 
520  // check emission dumps
521  if (OptionsCont::getOptions().isSet("emission-output")) {
523  }
524 
525  // check full dumps
526  if (OptionsCont::getOptions().isSet("full-output")) {
528  }
529 
530  // check queue dumps
531  if (OptionsCont::getOptions().isSet("queue-output")) {
533  }
534 
535  // check vtk dumps
536  if (OptionsCont::getOptions().isSet("vtk-output")) {
537 
538  if (MSNet::getInstance()->getVehicleControl().getRunningVehicleNo() > 0) {
539  std::string timestep = time2string(myStep);
540  timestep = timestep.substr(0, timestep.length() - 3);
541  std::string output = OptionsCont::getOptions().getString("vtk-output");
542  std::string filename = output + "_" + timestep + ".vtp";
543 
544  OutputDevice_File dev = OutputDevice_File(filename, false);
545 
546  //build a huge mass of xml files
548 
549  }
550 
551  }
552 
553  // emission output
554  if (OptionsCont::getOptions().isSet("summary-output")) {
555  OutputDevice& od = OutputDevice::getDeviceByOption("summary-output");
556  od << " <step time=\"" << time2string(myStep) << "\" "
557  << "loaded=\"" << myVehicleControl->getLoadedVehicleNo() << "\" "
558  << "emitted=\"" << myVehicleControl->getDepartedVehicleNo() << "\" "
559  << "running=\"" << myVehicleControl->getRunningVehicleNo() << "\" "
560  << "waiting=\"" << myInserter->getWaitingVehicleNo() << "\" "
561  << "ended=\"" << myVehicleControl->getEndedVehicleNo() << "\" "
562  << "meanWaitingTime=\"";
564  od << "\" meanTravelTime=\"";
566  od << "\" ";
567  if (myLogExecutionTime) {
568  od << "duration=\"" << mySimStepDuration << "\" ";
569  }
570  od << "/>\n";
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 /****************************************************************************/
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:424
long mySimStepEnd
Definition: MSNet.h:544
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:523
static SUMOReal getEffort(const MSEdge *const e, const SUMOVehicle *const v, SUMOReal t)
Returns the effort to pass an edge.
Definition: MSNet.cpp:118
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:501
The simulation contains too many vehicles (.
Definition: MSNet.h:104
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:507
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.
void updateDetectors(const SUMOTime step)
Computes detector values.
std::vector< SUMOTime > myStateDumpTimes
Times at which a state shall be written.
Definition: MSNet.h:559
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:257
void changeLanes(SUMOTime t)
Moves (precomputes) critical vehicles.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:61
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:509
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:511
The final simulation step has been performed.
Definition: MSNet.h:96
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:561
bool myLogExecutionTime
Information whether the simulation duration shall be logged.
Definition: MSNet.h:538
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:500
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterEffort(const std::vector< MSEdge * > &prohibited=std::vector< MSEdge * >()) const
Definition: MSNet.cpp:730
void printMeanTravelTime(OutputDevice &od) const
Returns the mean travel time of vehicles The mean travel time of ended vehicles (-1 if no vehicle has...
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
void printMeanWaitingTime(OutputDevice &od) const
Prints the mean waiting time of vehicles. The mean time vehicles had to wait for being inserted (-1 i...
SimulationState
Possible states of a simulation - running or stopped with different reasons.
Definition: MSNet.h:92
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:196
The simulated network and simulation perfomer.
Definition: MSNet.h:87
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
SUMOLong myVehiclesMoved
The overall number of vehicle movements.
Definition: MSNet.h:550
ShapeContainer * myShapeContainer
A container for geometrical shapes;.
Definition: MSNet.h:527
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.
bool addBusStop(MSBusStop *busStop)
Adds a bus stop.
Definition: MSNet.cpp:678
static bool gCheck4Accidents
Definition: MSGlobals.h:73
#define OUTPUT_ACCURACY
Definition: config.h:168
static void write(OutputDevice &of, SUMOTime timestep)
Export the queueing length in front of a junction (very experimental!)
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)
TraCI server used to control sumo by a remote TraCI client.
Definition: TraCIServer.h:76
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:544
The simulation does not contain further vehicles.
Definition: MSNet.h:98
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:102
static void clear()
Clears the dictionary (delete all known routes, too)
Definition: MSRoute.cpp:160
static bool wasClosed()
check whether close was requested
void writeOutput()
Write netstate, summary and detector output.
Definition: MSNet.cpp:506
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:517
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:54
SUMORouteLoaderControl * myRouteLoaders
Route loader for dynamic loading of routes.
Definition: MSNet.h:496
void closeSimulation(SUMOTime start)
Closes the simulation (all files, connections, etc.)
Definition: MSNet.cpp:308
bool myLogStepNumber
Information whether the number of the simulation step shall be logged.
Definition: MSNet.h:541
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:507
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:248
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:519
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:515
static void write(OutputDevice &of, SUMOTime timestep)
Produce a VTK output to use with Tools like ParaView.
Definition: MSVTKExport.cpp:56
The connection to a client was closed by the client.
Definition: MSNet.h:100
DijkstraRouterTT_ByProxi< MSEdge, SUMOVehicle, prohibited_withRestrictions< MSEdge, SUMOVehicle > > * myRouterTTDijkstra
Definition: MSNet.h:581
The simulation is running.
Definition: MSNet.h:94
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:192
void preSimStepOutput() const
Prints the current step number.
Definition: MSNet.cpp:620
static void close()
request termination of connection
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:582
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:51
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.
static TraCIServer * getInstance()
Definition: TraCIServer.h:85
void abortWaiting()
removes any vehicles that are still waiting
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:405
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
std::vector< VehicleStateListener * > myVehicleStateListeners
Container for vehicle state listener.
Definition: MSNet.h:573
static MSNet * myInstance
Unique instance of MSNet.
Definition: MSNet.h:493
bool isEmpty()
Returns whether events are in the que.
static void clearAll()
Clears all dictionaries.
Definition: MSNet.cpp:487
bool myRouterTTInitialized
Definition: MSNet.h:580
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:435
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
Definition: MSNet.h:513
virtual MSPersonControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:602
static void clear()
Definition: MSLane.cpp:830
static void processCommandsUntilSimStep(SUMOTime step)
process all commands until a simulation step is wanted
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
MSEventControl * myBeginOfTimestepEvents
Controls events executed at the begin of a time step;.
Definition: MSNet.h:521
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:529
SUMOTime getTargetTime()
Definition: TraCIServer.h:82
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
static void cleanup()
cleanup remaining data structures
long mySimBeginMillis
The overall simulation duration.
Definition: MSNet.h:547
virtual ~MSNet()
Destructor.
Definition: MSNet.cpp:224
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:221
static const bool gUseMesoSim
Definition: MSGlobals.h:95
static std::string getStateMessage(SimulationState state)
Returns the message to show if a certain state occurs.
Definition: MSNet.cpp:466
SUMOReal getMinimumTravelTime(const SUMOVehicle *const veh) const
returns the minimum travel time for the given vehicle
Definition: MSEdge.h:310
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:499
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:201
NamedObjectCont< MSBusStop * > myBusStopDict
Dictionary of bus stops.
Definition: MSNet.h:570
void simulationStep()
Performs a single simulation step.
Definition: MSNet.cpp:347
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:302
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:197
MSEventControl * myInsertionEvents
Controls insertion events;.
Definition: MSNet.h:525
int myTooManyVehicles
Storage for maximum vehicle number.
Definition: MSNet.h:566
Representation of a lane in the micro simulation.
Definition: MSLane.h:73
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle&#39;s internal edge travel times/efforts container.
Definition: MSVehicle.cpp:418
long mySimStepDuration
Definition: MSNet.h:544
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:583