Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSNet.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
25// The simulated network and simulation performer
26/****************************************************************************/
27#pragma once
28#include <config.h>
29
30#include <typeinfo>
31#include <vector>
32#include <map>
33#include <string>
34#include <fstream>
35#include <iostream>
36#include <cmath>
37#include <iomanip>
38#include <memory>
44#include <mesosim/MESegment.h>
45#include "MSJunction.h"
46
47
48// ===========================================================================
49// class declarations
50// ===========================================================================
51class MSEdge;
52class MSEdgeControl;
53class MSEventControl;
59class MSTransportable;
60class MSVehicle;
61class MSRoute;
62class MSLane;
66class ShapeContainer;
68class PolygonDynamics;
70class SUMOVehicle;
73class MSStoppingPlace;
74template<class E, class L, class N, class V>
76template<class E, class L, class N, class V>
78class OptionsCont;
79
80
81// ===========================================================================
82// class definitions
83// ===========================================================================
88class MSNet : public Parameterised {
89public:
111
114
116 struct Collision {
117 std::string victim;
118 std::string colliderType;
119 std::string victimType;
122 std::string type;
123 const MSLane* lane;
124 double pos;
126 };
127
128 typedef std::map<std::string, std::vector<Collision> > CollisionMap;
129
130public:
135 static MSNet* getInstance();
136
140 virtual bool isGUINet() const {
141 return false;
142 }
143
145 static void initStatic();
146
148 static void cleanupStatic();
149
150
154 static bool hasInstance() {
155 return myInstance != nullptr;
156 }
157
158
173 MSNet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
174 MSEventControl* endOfTimestepEvents,
175 MSEventControl* insertionEvents,
176 ShapeContainer* shapeCont = 0);
177
178
180 virtual ~MSNet();
181
182
198 void closeBuilding(const OptionsCont& oc, MSEdgeControl* edges, MSJunctionControl* junctions,
199 SUMORouteLoaderControl* routeLoaders, MSTLLogicControl* tlc,
200 std::vector<SUMOTime> stateDumpTimes, std::vector<std::string> stateDumpFiles,
201 bool hasInternalLinks,
202 bool junctionHigherSpeeds,
203 const MMVersion& version);
204
205
209 bool hasPermissions() const {
210 return myHavePermissions;
211 }
212
213
216 myHavePermissions = true;
217 }
218
219
225 void addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed);
226
227
233 const std::map<SUMOVehicleClass, double>* getRestrictions(const std::string& id) const;
234
239 void addMesoType(const std::string& typeID, const MESegment::MesoEdgeType& edgeType);
240
244 const MESegment::MesoEdgeType& getMesoType(const std::string& typeID);
245
249 static void clearAll();
250
252 bool hasFlow(const std::string& id) const;
253
262
263
267 void simulationStep(const bool onlyMove = false);
268
270 void loadRoutes();
271
272
277 const std::string generateStatistics(const SUMOTime start, const long now);
278
280 void writeCollisions() const;
281
283 void writeStatistics(const SUMOTime start, const long now) const;
284
286 void writeSummaryOutput();
287
294 void closeSimulation(SUMOTime start, const std::string& reason = "");
295
296
303
304
310 SimulationState adaptToState(const SimulationState state, const bool isLibsumo = false) const;
311
312
316 static std::string getStateMessage(SimulationState state);
317
318
323 return myStep;
324 }
325
326
330 inline void setCurrentTimeStep(const SUMOTime step) {
331 myStep = step;
332 }
333
334
338 void clearState(const SUMOTime step, bool quickReload = false);
339
343 void writeOutput();
344
345
349 bool logSimulationDuration() const;
350
351
352
354
355
360 void preSimStepOutput() const;
361
362
367 void postSimStepOutput() const;
368 //}
369
370
371
374
383
384
394
397 bool hasPersons() const {
398 return myPersonControl != nullptr;
399 }
400
410
413 bool hasContainers() const {
414 return myContainerControl != nullptr;
415 }
416
417
424 return *myEdges;
425 }
426
427
436
437
446
447
454 return *myLogics;
455 }
456
457
466
467
476
477
486
487
496
497
506
513
518
526
529
540 bool addStoppingPlace(const SumoXMLTag category, MSStoppingPlace* stop);
541
542
552
553
559 MSStoppingPlace* getStoppingPlace(const std::string& id, const SumoXMLTag category) const;
560
567 std::string getStoppingPlaceID(const MSLane* lane, const double pos, const SumoXMLTag category) const;
569
571
573 void writeChargingStationOutput() const;
574
576 void writeRailSignalBlocks() const;
577
580
583
585 void writeSubstationOutput() const;
586
588 virtual bool isSelected(const MSTrafficLightLogic*) const {
589 return false;
590 }
592 virtual void updateGUI() const { }
593
595 SUMOTime loadState(const std::string& fileName, const bool catchExceptions);
596
598 void quickReload();
599
602
632
633
638 public:
641
644
650 virtual void vehicleStateChanged(const SUMOVehicle* const vehicle, VehicleState to, const std::string& info = "") = 0;
651
652 };
653
654
659
660
665
666
673 void informVehicleStateListener(const SUMOVehicle* const vehicle, VehicleState to, const std::string& info = "");
675
676
679
691
692
697 public:
700
703
709 virtual void transportableStateChanged(const MSTransportable* const transportable, TransportableState to, const std::string& info = "") = 0;
710
711 };
712
713
718
719
724
725
732 void informTransportableStateListener(const MSTransportable* const transportable, TransportableState to, const std::string& info = "");
734
735
737 bool registerCollision(const SUMOTrafficObject* collider, const SUMOTrafficObject* victim, const std::string& collisionType, const MSLane* lane, double pos);
738
740 return myCollisions;
741 }
742
743
751 static double getTravelTime(const MSEdge* const e, const SUMOVehicle* const v, double t);
752
753
761 static double getEffort(const MSEdge* const e, const SUMOVehicle* const v, double t);
762
763
764 /* @brief get the router, initialize on first use
765 * @param[in] prohibited The vector of forbidden edges (optional)
766 */
768 const MSEdgeVector& prohibited = MSEdgeVector()) const;
770 const MSEdgeVector& prohibited = MSEdgeVector()) const;
771 MSPedestrianRouter& getPedestrianRouter(const int rngIndex, const MSEdgeVector& prohibited = MSEdgeVector()) const;
772 MSIntermodalRouter& getIntermodalRouter(const int rngIndex, const int routingMode = 0, const MSEdgeVector& prohibited = MSEdgeVector()) const;
773
774 static void adaptIntermodalRouter(MSIntermodalRouter& router);
775
776
778 bool hasInternalLinks() const {
779 return myHasInternalLinks;
780 }
781
785 }
786
788 bool hasElevation() const {
789 return myHasElevation;
790 }
791
793 bool hasPedestrianNetwork() const {
795
796 }
798 bool hasBidiEdges() const {
799 return myHasBidiEdges;
800 }
801
804 return myVersion;
805 }
806
808 bool warnOnce(const std::string& typeAndID);
809
810 void interrupt() {
811 myAmInterrupted = true;
812 }
813
814 bool isInterrupted() const {
815 return myAmInterrupted;
816 }
817
819 virtual bool skipFinalReset() const {
820 return false;
821 }
822
824 MSTractionSubstation* findTractionSubstation(const std::string& substationId);
825
827 bool existTractionSubstation(const std::string& substationId);
828
830 static const std::string STAGE_EVENTS;
831 static const std::string STAGE_MOVEMENTS;
832 static const std::string STAGE_LANECHANGE;
833 static const std::string STAGE_INSERTIONS;
834 static const std::string STAGE_REMOTECONTROL;
835
836protected:
838 bool checkElevation();
839
841 bool checkWalkingarea();
842
844 bool checkBidiEdges();
845
848
851 void postMoveStep();
852
853protected:
856
859
862
865
868
871
872
873
876
904
905
906
909
912
917
920
923
926
928 long long int myVehiclesMoved;
929 long long int myPersonsMoved;
930 //}
931
932
933
936
938 std::vector<SUMOTime> myStateDumpTimes;
940 std::vector<std::string> myStateDumpFiles;
942 std::vector<std::string> myPeriodicStateFiles;
946 std::string myStateDumpPrefix;
947 std::string myStateDumpSuffix;
949
950
951
954
956 std::map<std::string, std::map<SUMOVehicleClass, double> > myRestrictions;
957
959 std::map<std::string, MESegment::MesoEdgeType> myMesoEdgeTypes;
960
963
966
969
972
975
978
981
984
986 std::map<SumoXMLTag, NamedObjectCont<MSStoppingPlace*> > myStoppingPlaces;
987
989 std::vector<MSTractionSubstation*> myTractionSubstations;
990
992 std::vector<VehicleStateListener*> myVehicleStateListeners;
993
995 std::vector<TransportableStateListener*> myTransportableStateListeners;
996
999
1000#ifdef HAVE_FOX
1002 FXMutex myVehicleStateListenerMutex;
1003
1005 FXMutex myTransportableStateListenerMutex;
1006#endif
1008
1010 std::map<std::string, bool> myWarnedOnce;
1011
1012 /* @brief The router instance for routing by trigger and by traci
1013 * @note MSDevice_Routing has its own instance since it uses a different weight function
1014 * @note we provide one member for every switchable router type
1015 * because the class structure makes it inconvenient to use a superclass
1016 */
1017 mutable std::map<int, SUMOAbstractRouter<MSEdge, SUMOVehicle>*> myRouterTT;
1018 mutable std::map<int, SUMOAbstractRouter<MSEdge, SUMOVehicle>*> myRouterEffort;
1019 mutable std::map<int, MSPedestrianRouter*> myPedestrianRouter;
1020 mutable std::map<int, MSIntermodalRouter*> myIntermodalRouter;
1021
1023 mutable std::pair<bool, NamedRTree> myLanesRTree;
1024
1028 std::unique_ptr<MSDynamicShapeUpdater> myDynamicShapeUpdater;
1029
1030private:
1032 MSNet(const MSNet&);
1033
1036
1037
1038};
long long int SUMOTime
Definition GUI.h:36
std::vector< MSEdge * > MSEdgeVector
Definition MSEdge.h:73
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLTag
Numbers representing SUMO-XML - element names.
std::pair< int, double > MMVersion
(M)ajor/(M)inor version for written networks and default version for loading
Definition StdDefs.h:67
Detectors container; responsible for string and output generation.
Stores edges and lanes, performs moving of vehicle.
A road/street connecting two junctions.
Definition MSEdge.h:77
A storage for edge travel times and efforts.
Stores time-dependant events and executes them at the proper time.
Inserts vehicles into the network when their departure time is reached.
Container for junctions; performs operations on all stored junctions.
Representation of a lane in the micro simulation.
Definition MSLane.h:84
Interface for objects listening to transportable state changes.
Definition MSNet.h:696
virtual void transportableStateChanged(const MSTransportable *const transportable, TransportableState to, const std::string &info="")=0
Called if a transportable changes its state.
TransportableStateListener()
Constructor.
Definition MSNet.h:699
virtual ~TransportableStateListener()
Destructor.
Definition MSNet.h:702
Interface for objects listening to vehicle state changes.
Definition MSNet.h:637
virtual ~VehicleStateListener()
Destructor.
Definition MSNet.h:643
virtual void vehicleStateChanged(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")=0
Called if a vehicle changes its state.
VehicleStateListener()
Constructor.
Definition MSNet.h:640
The simulated network and simulation perfomer.
Definition MSNet.h:88
std::map< SumoXMLTag, NamedObjectCont< MSStoppingPlace * > > myStoppingPlaces
Dictionary of bus / container stops.
Definition MSNet.h:986
long myTraCIMillis
The overall time spent waiting for traci operations including.
Definition MSNet.h:925
static double getEffort(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the effort to pass an edge.
Definition MSNet.cpp:149
bool warnOnce(const std::string &typeAndID)
return whether a warning regarding the given object shall be issued
Definition MSNet.cpp:1623
SUMOTime loadState(const std::string &fileName, const bool catchExceptions)
load state from file and return new time
Definition MSNet.cpp:1653
std::map< int, SUMOAbstractRouter< MSEdge, SUMOVehicle > * > myRouterEffort
Definition MSNet.h:1018
MSIntermodalRouter & getIntermodalRouter(const int rngIndex, const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition MSNet.cpp:1503
bool myLogExecutionTime
Information whether the simulation duration shall be logged.
Definition MSNet.h:911
MSTransportableControl * myPersonControl
Controls person building and deletion;.
Definition MSNet.h:880
void removeVehicleStateListener(VehicleStateListener *listener)
Removes a vehicle states listener.
Definition MSNet.cpp:1248
SUMORouteLoaderControl * myRouteLoaders
Route loader for dynamic loading of routes.
Definition MSNet.h:858
bool addStoppingPlace(const SumoXMLTag category, MSStoppingPlace *stop)
Adds a stopping place.
Definition MSNet.cpp:1347
void informTransportableStateListener(const MSTransportable *const transportable, TransportableState to, const std::string &info="")
Informs all added listeners about a transportable's state change.
Definition MSNet.cpp:1285
SUMOTime myStateDumpPeriod
The period for writing state.
Definition MSNet.h:944
static const NamedObjectCont< MSStoppingPlace * > myEmptyStoppingPlaceCont
Definition MSNet.h:1007
void writeOverheadWireSegmentOutput() const
write the output generated by an overhead wire segment
Definition MSNet.cpp:1420
void writeChargingStationOutput() const
write charging station output
Definition MSNet.cpp:1397
std::pair< bool, NamedRTree > myLanesRTree
An RTree structure holding lane IDs.
Definition MSNet.h:1023
bool checkBidiEdges()
check wether bidirectional edges occur in the network
Definition MSNet.cpp:1613
VehicleState
Definition of a vehicle state.
Definition MSNet.h:604
@ ENDING_PARKING
The vehicle ends to park.
@ STARTING_STOP
The vehicles starts to stop.
@ BUILT
The vehicle was built, but has not yet departed.
@ STARTING_PARKING
The vehicles starts to park.
@ NEWROUTE
The vehicle got a new route.
@ STARTING_TELEPORT
The vehicle started to teleport.
@ ENDING_STOP
The vehicle ends to stop.
@ ENDING_TELEPORT
The vehicle ended being teleported.
@ ARRIVED
The vehicle arrived at his destination (is deleted)
@ DEPARTED
The vehicle has departed (was inserted into the network)
@ COLLISION
The vehicle is involved in a collision.
@ EMERGENCYSTOP
The vehicle had to brake harder than permitted.
@ MANEUVERING
Vehicle maneuvering either entering or exiting a parking space.
int myLogStepPeriod
Period between successive step-log outputs.
Definition MSNet.h:916
MSDetectorControl & getDetectorControl()
Returns the detector control.
Definition MSNet.h:443
SUMOTime myStep
Current time step.
Definition MSNet.h:861
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:183
virtual bool isSelected(const MSTrafficLightLogic *) const
return wheter the given logic (or rather it's wrapper) is selected in the GUI
Definition MSNet.h:588
bool myHasBidiEdges
Whether the network contains bidirectional rail edges.
Definition MSNet.h:974
const CollisionMap & getCollisions() const
Definition MSNet.h:739
MSEventControl * myBeginOfTimestepEvents
Controls events executed at the begin of a time step;.
Definition MSNet.h:894
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition MSNet.h:473
bool addTractionSubstation(MSTractionSubstation *substation)
Adds a traction substation.
Definition MSNet.cpp:1353
std::map< std::string, bool > myWarnedOnce
container to record warnings that shall only be issued once
Definition MSNet.h:1010
static void initStatic()
Place for static initializations of simulation components (called after successful net build)
Definition MSNet.cpp:191
void removeOutdatedCollisions()
remove collisions from the previous simulation step
Definition MSNet.cpp:1328
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
Definition MSNet.h:886
std::vector< std::string > myPeriodicStateFiles
The names of the last K periodic state files (only only K shall be kept)
Definition MSNet.h:942
ShapeContainer * myShapeContainer
A container for geometrical shapes;.
Definition MSNet.h:900
bool hasBidiEdges() const
return whether the network contains bidirectional rail edges
Definition MSNet.h:798
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition MSNet.h:453
std::string myStateDumpSuffix
Definition MSNet.h:947
bool checkElevation()
check all lanes for elevation data
Definition MSNet.cpp:1588
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
Definition MSNet.h:953
bool existTractionSubstation(const std::string &substationId)
return whether given electrical substation exists in the network
Definition MSNet.cpp:1454
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Definition MSNet.h:483
void removeTransportableStateListener(TransportableStateListener *listener)
Removes a transportable states listener.
Definition MSNet.cpp:1276
SimulationState adaptToState(const SimulationState state, const bool isLibsumo=false) const
Called after a simulation step, this method adapts the current simulation state if necessary.
Definition MSNet.cpp:903
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 junctionHigherSpeeds, const MMVersion &version)
Closes the network's building process.
Definition MSNet.cpp:256
bool myLogStepNumber
Information whether the number of the simulation step shall be logged.
Definition MSNet.h:914
MMVersion myVersion
the network version
Definition MSNet.h:980
MSEventControl * myInsertionEvents
Controls insertion events;.
Definition MSNet.h:898
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition MSNet.cpp:1181
MMVersion getNetworkVersion() const
return the network version
Definition MSNet.h:803
SimulationState
Possible states of a simulation - running or stopped with different reasons.
Definition MSNet.h:93
@ SIMSTATE_TOO_MANY_TELEPORTS
The simulation had too many teleports.
Definition MSNet.h:109
@ SIMSTATE_NO_FURTHER_VEHICLES
The simulation does not contain further vehicles.
Definition MSNet.h:101
@ SIMSTATE_LOADING
The simulation is loading.
Definition MSNet.h:95
@ SIMSTATE_ERROR_IN_SIM
An error occurred during the simulation step.
Definition MSNet.h:105
@ SIMSTATE_CONNECTION_CLOSED
The connection to a client was closed by the client.
Definition MSNet.h:103
@ SIMSTATE_INTERRUPTED
An external interrupt occured.
Definition MSNet.h:107
@ SIMSTATE_RUNNING
The simulation is running.
Definition MSNet.h:97
@ SIMSTATE_END_STEP_REACHED
The final simulation step has been performed.
Definition MSNet.h:99
MSEventControl * getInsertionEvents()
Returns the event control for insertion events.
Definition MSNet.h:493
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition MSNet.cpp:1465
std::map< int, MSPedestrianRouter * > myPedestrianRouter
Definition MSNet.h:1019
static const std::string STAGE_MOVEMENTS
Definition MSNet.h:831
bool hasFlow(const std::string &id) const
return whether the given flow is known
Definition MSNet.cpp:388
int myMaxTeleports
Maximum number of teleports.
Definition MSNet.h:867
long mySimStepDuration
Definition MSNet.h:919
PedestrianRouter< MSEdge, MSLane, MSJunction, MSVehicle > MSPedestrianRouter
Definition MSNet.h:112
MSEventControl * myEndOfTimestepEvents
Controls events executed at the end of a time step;.
Definition MSNet.h:896
static std::string getStateMessage(SimulationState state)
Returns the message to show if a certain state occurs.
Definition MSNet.cpp:924
std::string getStoppingPlaceID(const MSLane *lane, const double pos, const SumoXMLTag category) const
Returns the stop of the given category close to the given position.
Definition MSNet.cpp:1372
bool myHasInternalLinks
Whether the network contains internal links/lanes/edges.
Definition MSNet.h:962
void interrupt()
Definition MSNet.h:810
void writeSubstationOutput() const
write electrical substation output
Definition MSNet.cpp:1431
static const std::string STAGE_INSERTIONS
Definition MSNet.h:833
MSJunctionControl & getJunctionControl()
Returns the junctions control.
Definition MSNet.h:463
long long int myPersonsMoved
Definition MSNet.h:929
void quickReload()
reset state to the beginning without reloading the network
Definition MSNet.cpp:1632
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
Definition MSNet.h:878
bool hasJunctionHigherSpeeds() const
return whether the network was built with higher junction speeds
Definition MSNet.h:783
static void clearAll()
Clears all dictionaries.
Definition MSNet.cpp:949
static void cleanupStatic()
Place for static initializations of simulation components (called after successful net build)
Definition MSNet.cpp:198
void setPermissionsFound()
Labels the network to contain vehicle class permissions.
Definition MSNet.h:215
void writeStatistics(const SUMOTime start, const long now) const
write statistic output to (xml) file
Definition MSNet.cpp:559
IntermodalRouter< MSEdge, MSLane, MSJunction, SUMOVehicle > MSIntermodalRouter
Definition MSNet.h:113
void writeSummaryOutput()
write summary-output to (xml) file
Definition MSNet.cpp:609
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition MSNet.h:322
std::map< std::string, std::vector< Collision > > CollisionMap
Definition MSNet.h:128
MSEdgeControl * myEdges
Controls edges, performs vehicle movement;.
Definition MSNet.h:884
std::unique_ptr< MSDynamicShapeUpdater > myDynamicShapeUpdater
Updater for dynamic shapes that are tracking traffic objects (ensures removal of shape dynamics when ...
Definition MSNet.h:1028
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:352
static bool hasInstance()
Returns whether the network was already constructed.
Definition MSNet.h:154
void closeSimulation(SUMOTime start, const std::string &reason="")
Closes the simulation (all files, connections, etc.)
Definition MSNet.cpp:673
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition MSNet.cpp:1363
bool myHasElevation
Whether the network contains elevation data.
Definition MSNet.h:968
static double getTravelTime(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the travel time to pass an edge.
Definition MSNet.cpp:163
MSTransportableControl * myContainerControl
Controls container building and deletion;.
Definition MSNet.h:882
std::vector< TransportableStateListener * > myTransportableStateListeners
Container for transportable state listener.
Definition MSNet.h:995
void writeOutput()
Write netstate, summary and detector output.
Definition MSNet.cpp:1032
virtual void updateGUI() const
update view after simulation.loadState
Definition MSNet.h:592
void setCurrentTimeStep(const SUMOTime step)
Sets the current simulation step (used by state loading)
Definition MSNet.h:330
bool myAmInterrupted
whether an interrupt occured
Definition MSNet.h:870
void simulationStep(const bool onlyMove=false)
Performs a single simulation step.
Definition MSNet.cpp:710
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition MSNet.cpp:1240
void clearState(const SUMOTime step, bool quickReload=false)
Resets events when quick-loading state.
Definition MSNet.cpp:979
void preSimStepOutput() const
Prints the current step number.
Definition MSNet.cpp:1204
void writeCollisions() const
write collision output to (xml) file
Definition MSNet.cpp:537
std::vector< SUMOTime > myStateDumpTimes
Times at which a state shall be written.
Definition MSNet.h:938
MSDynamicShapeUpdater * getDynamicShapeUpdater()
Returns the dynamic shapes updater.
Definition MSNet.h:510
bool hasContainers() const
Returns whether containers are simulated.
Definition MSNet.h:413
void addTransportableStateListener(TransportableStateListener *listener)
Adds a transportable states listener.
Definition MSNet.cpp:1268
std::vector< MSTractionSubstation * > myTractionSubstations
Dictionary of traction substations.
Definition MSNet.h:989
SUMOTime myEdgeDataEndTime
end of loaded edgeData
Definition MSNet.h:983
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net's internal edge travel times/efforts container.
Definition MSNet.cpp:1195
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
Definition MSNet.h:956
std::vector< std::string > myStateDumpFiles
The names for the state files.
Definition MSNet.h:940
void addMesoType(const std::string &typeID, const MESegment::MesoEdgeType &edgeType)
Adds edge type specific meso parameters.
Definition MSNet.cpp:361
void writeRailSignalBlocks() const
write rail signal block output
Definition MSNet.cpp:1408
MSNet & operator=(const MSNet &)
Invalidated assignment operator.
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
Definition MSNet.h:888
bool logSimulationDuration() const
Returns whether duration shall be logged.
Definition MSNet.cpp:1166
bool hasPedestrianNetwork() const
return whether the network contains walkingareas and crossings
Definition MSNet.h:793
long long int myVehiclesMoved
The overall number of vehicle movements.
Definition MSNet.h:928
static const std::string STAGE_REMOTECONTROL
Definition MSNet.h:834
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
Definition MSNet.cpp:1257
bool isInterrupted() const
Definition MSNet.h:814
std::vector< VehicleStateListener * > myVehicleStateListeners
Container for vehicle state listener.
Definition MSNet.h:992
SimulationState simulationState(SUMOTime stopTime) const
This method returns the current simulation state. It should not modify status.
Definition MSNet.cpp:873
bool hasPersons() const
Returns whether persons are simulated.
Definition MSNet.h:397
long myTraCIStepDuration
The last simulation step duration.
Definition MSNet.h:919
TransportableState
Definition of a transportable state.
Definition MSNet.h:681
@ CONTAINER_DEPARTED
The transportable container has departed (was inserted into the network)
@ PERSON_DEPARTED
The transportable person has departed (was inserted into the network)
@ PERSON_ARRIVED
The transportable person arrived at his destination (is deleted)
@ CONTAINER_ARRIVED
The transportable container arrived at his destination (is deleted)
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition MSNet.h:433
MSDetectorControl * myDetectorControl
Controls detectors;.
Definition MSNet.h:892
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition MSNet.h:503
bool myStepCompletionMissing
whether libsumo triggered a partial step (executeMove)
Definition MSNet.h:864
static const std::string STAGE_LANECHANGE
Definition MSNet.h:832
MSNet(const MSNet &)
Invalidated copy constructor.
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
Definition MSNet.cpp:346
bool hasPermissions() const
Returns whether the network has specific vehicle class permissions.
Definition MSNet.h:209
std::map< int, SUMOAbstractRouter< MSEdge, SUMOVehicle > * > myRouterTT
Definition MSNet.h:1017
virtual bool skipFinalReset() const
gui may prevent final meanData reset to keep live data visible
Definition MSNet.h:819
std::map< std::string, MESegment::MesoEdgeType > myMesoEdgeTypes
The edge type specific meso parameters.
Definition MSNet.h:959
static void adaptIntermodalRouter(MSIntermodalRouter &router)
Definition MSNet.cpp:1552
bool myLefthand
Whether the network was built for left-hand traffic.
Definition MSNet.h:977
MSEdgeWeightsStorage * myEdgeWeights
The net's knowledge about edge efforts/travel times;.
Definition MSNet.h:902
MSDynamicShapeUpdater * makeDynamicShapeUpdater()
Creates and returns a dynamic shapes updater.
Definition MSNet.cpp:1189
std::map< int, MSIntermodalRouter * > myIntermodalRouter
Definition MSNet.h:1020
virtual ~MSNet()
Destructor.
Definition MSNet.cpp:291
MSPedestrianRouter & getPedestrianRouter(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition MSNet.cpp:1493
MSTractionSubstation * findTractionSubstation(const std::string &substationId)
find electrical substation by its id
Definition MSNet.cpp:1443
static MSNet * myInstance
Unique instance of MSNet.
Definition MSNet.h:855
virtual void createTLWrapper(MSTrafficLightLogic *)
creates a wrapper for the given logic (see GUINet)
Definition MSNet.h:579
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:380
MSInsertionControl * myInserter
Controls vehicle insertion;.
Definition MSNet.h:890
void postSimStepOutput() const
Prints the statistics of the step at its end.
Definition MSNet.cpp:1210
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition MSNet.cpp:1172
bool registerCollision(const SUMOTrafficObject *collider, const SUMOTrafficObject *victim, const std::string &collisionType, const MSLane *lane, double pos)
register collision and return whether it was the first one involving these vehicles
Definition MSNet.cpp:1296
static const std::string STAGE_EVENTS
string constants for simstep stages
Definition MSNet.h:830
void loadRoutes()
loads routes for the next few steps
Definition MSNet.cpp:437
std::string myStateDumpPrefix
name components for periodic state
Definition MSNet.h:946
bool myJunctionHigherSpeeds
Whether the network was built with higher speed on junctions.
Definition MSNet.h:965
MSEdgeControl & getEdgeControl()
Returns the edge control.
Definition MSNet.h:423
long mySimBeginMillis
The overall simulation duration.
Definition MSNet.h:922
virtual bool isGUINet() const
Returns whether this is a GUI Net.
Definition MSNet.h:140
bool myHasPedestrianNetwork
Whether the network contains pedestrian network elements.
Definition MSNet.h:971
const MESegment::MesoEdgeType & getMesoType(const std::string &typeID)
Returns edge type specific meso parameters if no type specific parameters have been loaded,...
Definition MSNet.cpp:366
void postMoveStep()
Performs the parts of the simulation step which happen after the move.
Definition MSNet.cpp:844
bool hasInternalLinks() const
return whether the network contains internal links
Definition MSNet.h:778
const std::string generateStatistics(const SUMOTime start, const long now)
Writes performance output and running vehicle stats.
Definition MSNet.cpp:443
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterEffort(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition MSNet.cpp:1483
bool checkWalkingarea()
check all lanes for type walkingArea
Definition MSNet.cpp:1602
CollisionMap myCollisions
collisions in the current time step
Definition MSNet.h:998
bool hasElevation() const
return whether the network contains elevation data
Definition MSNet.h:788
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition MSNet.cpp:1386
SimulationState simulate(SUMOTime start, SUMOTime stop)
Simulates from timestep start to stop.
Definition MSNet.cpp:395
A lane area vehicles can halt at.
A class that stores and controls tls and switching of their programs.
Traction substaction powering one or more overhead wire sections.
The parent class for traffic light logics.
The class responsible for building and deletion of vehicles.
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
A map of named object pointers.
A storage for options typed value containers)
Definition OptionsCont.h:89
An upper class for objects with additional parameters.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition SUMOVehicle.h:62
Storage for geometrical objects.
edge type specific meso parameters
Definition MESegment.h:55
collision tracking
Definition MSNet.h:116
double victimSpeed
Definition MSNet.h:121
const MSLane * lane
Definition MSNet.h:123
std::string victimType
Definition MSNet.h:119
std::string type
Definition MSNet.h:122
std::string colliderType
Definition MSNet.h:118
std::string victim
Definition MSNet.h:117
double colliderSpeed
Definition MSNet.h:120
SUMOTime time
Definition MSNet.h:125