/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file MSNet.h14/// @author Christian Roessel15/// @author Jakob Erdmann16/// @author Daniel Krajzewicz17/// @author Thimor Bohn18/// @author Eric Nicolay19/// @author Clemens Honomichl20/// @author Michael Behrisch21/// @author Leonhard Luecken22/// @date Mon, 12 Mar 200123///24// The simulated network and simulation performer25/****************************************************************************/26#pragma once27#include <config.h>2829#include <typeinfo>30#include <vector>31#include <map>32#include <string>33#include <fstream>34#include <iostream>35#include <cmath>36#include <iomanip>37#include <memory>38#include <utils/common/SUMOTime.h>39#include <utils/common/UtilExceptions.h>40#include <utils/common/NamedObjectCont.h>41#include <utils/common/NamedRTree.h>42#include <utils/router/SUMOAbstractRouter.h>43#include <mesosim/MESegment.h>44#include "MSRouterDefs.h"45#include "MSJunction.h"464748// ===========================================================================49// class declarations50// ===========================================================================51class MSEdge;52class MSEdgeControl;53class MSEventControl;54class MSVehicleControl;55class MSJunctionControl;56class MSInsertionControl;57class SUMORouteLoaderControl;58class MSTransportableControl;59class MSTransportable;60class MSVehicle;61class MSRoute;62class MSLane;63class MSTLLogicControl;64class MSTrafficLightLogic;65class MSDetectorControl;66class ShapeContainer;67class MSDynamicShapeUpdater;68class PolygonDynamics;69class MSEdgeWeightsStorage;70class SUMOVehicle;71class SUMOTrafficObject;72class MSTractionSubstation;73class MSStoppingPlace;74template<class E, class L, class N, class V>75class IntermodalRouter;76template<class E, class L, class N, class V>77class PedestrianRouter;78class OptionsCont;798081// ===========================================================================82// class definitions83// ===========================================================================84/**85* @class MSNet86* @brief The simulated network and simulation perfomer87*/88class MSNet : public Parameterised {89public:90/** @enum SimulationState91* @brief Possible states of a simulation - running or stopped with different reasons92*/93enum SimulationState {94/// @brief The simulation is loading95SIMSTATE_LOADING,96/// @brief The simulation is running97SIMSTATE_RUNNING,98/// @brief The final simulation step has been performed99SIMSTATE_END_STEP_REACHED,100/// @brief The simulation does not contain further vehicles101SIMSTATE_NO_FURTHER_VEHICLES,102/// @brief The connection to a client was closed by the client103SIMSTATE_CONNECTION_CLOSED,104/// @brief An error occurred during the simulation step105SIMSTATE_ERROR_IN_SIM,106/// @brief An external interrupt occurred107SIMSTATE_INTERRUPTED,108/// @brief The simulation had too many teleports109SIMSTATE_TOO_MANY_TELEPORTS110};111112/// @brief collision tracking113struct Collision {114std::string victim;115std::string colliderType;116std::string victimType;117double colliderSpeed;118double victimSpeed;119Position colliderFront;120Position victimFront;121Position colliderBack;122Position victimBack;123std::string type;124const MSLane* lane;125double pos;126SUMOTime time;127SUMOTime continuationTime;128};129130typedef std::map<std::string, std::vector<Collision> > CollisionMap;131typedef std::map<const MSEdge*, RouterProhibition> Prohibitions;132133public:134/** @brief Returns the pointer to the unique instance of MSNet (singleton).135* @return Pointer to the unique MSNet-instance136* @exception ProcessError If a network was not yet constructed137*/138static MSNet* getInstance();139140/**141* @brief Returns whether this is a GUI Net142*/143virtual bool isGUINet() const {144return false;145}146147/// @brief Place for static initializations of simulation components (called after successful net build)148static void initStatic();149150/// @brief Place for static initializations of simulation components (called after successful net build)151static void cleanupStatic();152153154/** @brief Returns whether the network was already constructed155* @return whether the network was already constructed156*/157static bool hasInstance() {158return myInstance != nullptr;159}160161162/** @brief Constructor163*164* This constructor builds a net of which only some basic structures are initialised.165* It prepares the network for being filled while loading.166* As soon as all edge/junction/traffic lights and other containers are build, they167* must be initialised using "closeBuilding".168* @param[in] vc The vehicle control to use169* @param[in] beginOfTimestepEvents The event control to use for simulation step begin events170* @param[in] endOfTimestepEvents The event control to use for simulation step end events171* @param[in] insertionEvents The event control to use for insertion events172* @param[in] shapeCont The shape container to use173* @exception ProcessError If a network was already constructed174* @see closeBuilding175*/176MSNet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,177MSEventControl* endOfTimestepEvents,178MSEventControl* insertionEvents,179ShapeContainer* shapeCont = 0);180181182/// @brief Destructor183virtual ~MSNet();184185186/** @brief Closes the network's building process187*188* Assigns the structures built while loading to this network.189* @param[in] oc The options to use190* @param[in] edges The control of edges which belong to this network191* @param[in] junctions The control of junctions which belong to this network192* @param[in] routeLoaders The route loaders used193* @param[in] tlc The control of traffic lights which belong to this network194* @param[in] stateDumpTimes List of time steps at which state shall be written195* @param[in] stateDumpFiles Filenames for states196* @param[in] hasInternalLinks Whether the network actually contains internal links197* @param[in] junctionHigherSpeeds Whether the network was built with higher junction speeds198* @param[in] version The network version199* @todo Try to move all this to the constructor?200*/201void closeBuilding(const OptionsCont& oc, MSEdgeControl* edges, MSJunctionControl* junctions,202SUMORouteLoaderControl* routeLoaders, MSTLLogicControl* tlc,203std::vector<SUMOTime> stateDumpTimes, std::vector<std::string> stateDumpFiles,204bool hasInternalLinks,205bool junctionHigherSpeeds,206const MMVersion& version);207208209/** @brief Returns whether the network has specific vehicle class permissions210* @return whether permissions are present211*/212bool hasPermissions() const {213return myHavePermissions;214}215216217/// @brief Labels the network to contain vehicle class permissions218void setPermissionsFound() {219myHavePermissions = true;220}221222223/** @brief Adds a restriction for an edge type224* @param[in] id The id of the type225* @param[in] svc The vehicle class the restriction refers to226* @param[in] speed The restricted speed227*/228void addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed);229230231/** @brief Returns the restrictions for an edge type232* If no restrictions are present, 0 is returned.233* @param[in] id The id of the type234* @return The mapping of vehicle classes to maximum speeds235*/236const std::map<SUMOVehicleClass, double>* getRestrictions(const std::string& id) const;237238/// @brief retriefe edge type specific routing preference239double getPreference(const std::string& routingType, const SUMOVTypeParameter& pars) const;240241/// @brief add edge type specific routing preference242void addPreference(const std::string& routingType, SUMOVehicleClass svc, double prio);243/// @brief add edge type specific routing preference244void addPreference(const std::string& routingType, std::string vType, double prio);245246/** @brief Adds edge type specific meso parameters247* @param[in] id The id of the type248* @param[in] edgeType The parameter object249*/250void addMesoType(const std::string& typeID, const MESegment::MesoEdgeType& edgeType);251252/** @brief Returns edge type specific meso parameters253* if no type specific parameters have been loaded, default values are returned254*/255const MESegment::MesoEdgeType& getMesoType(const std::string& typeID);256257/** @brief Clears all dictionaries258* @todo Try to move all this to the destructor259*/260static void clearAll();261262/// @brief return whether the given flow is known263bool hasFlow(const std::string& id) const;264265/** @brief Simulates from timestep start to stop266* @param[in] start The begin time step of the simulation267* @param[in] stop The end time step of the simulation268* @return Returns always 0269* @todo Recheck return value270* @todo What exceptions may occure?271*/272SimulationState simulate(SUMOTime start, SUMOTime stop);273274275/** @brief Performs a single simulation step276* @todo Which exceptions may occur?277*/278void simulationStep(const bool onlyMove = false);279280/** @brief loads routes for the next few steps */281void loadRoutes();282283284/** @brief Writes performance output and running vehicle stats285*286* @param[in] start The step the simulation was started with287*/288const std::string generateStatistics(const SUMOTime start, const long now);289290/// @brief write collision output to (xml) file291void writeCollisions() const;292293/// @brief write statistic output to (xml) file294void writeStatistics(const SUMOTime start, const long now) const;295296/// @brief write summary-output to (xml) file297void writeSummaryOutput(bool finalStep = false);298299/** @brief Closes the simulation (all files, connections, etc.)300*301* Writes also performance output302*303* @param[in] start The step the simulation was started with304*/305void closeSimulation(SUMOTime start, const std::string& reason = "");306307308/** @brief This method returns the current simulation state. It should not modify status.309* @param[in] stopTime The time the simulation shall stop at310* @return The current simulation state311* @see SimulationState312*/313SimulationState simulationState(SUMOTime stopTime) const;314315316/** @brief Called after a simulation step, this method adapts the current simulation state if necessary317* @param[in] state The current simulation state318* @return The new simulation state319* @see SimulationState320*/321SimulationState adaptToState(const SimulationState state, const bool isLibsumo = false) const;322323324/** @brief Returns the message to show if a certain state occurs325* @return Readable description of the state326*/327static std::string getStateMessage(SimulationState state);328329330/** @brief Returns the current simulation step331* @return the current simulation step332*/333inline SUMOTime getCurrentTimeStep() const {334return myStep;335}336337338/** @brief Sets the current simulation step (used by state loading)339* @param step the current simulation step340*/341inline void setCurrentTimeStep(const SUMOTime step) {342myStep = step;343}344345346/** @brief Resets events when quick-loading state347* @param step The new simulation step348*/349void clearState(const SUMOTime step, bool quickReload = false);350351/** @brief Write netstate, summary and detector output352* @todo Which exceptions may occur?353*/354void writeOutput();355356357/** @brief Returns whether duration shall be logged358* @return Whether duration shall be logged359*/360bool logSimulationDuration() const;361362363364/// @name Output during the simulation365//@{366367/** @brief Prints the current step number368*369* Called on the begin of a simulation step370*/371void preSimStepOutput() const;372373374/** @brief Prints the statistics of the step at its end375*376* Called on the end of a simulation step377*/378void postSimStepOutput() const;379//}380381382383/// @name Retrieval of references to substructures384/// @{385386/** @brief Returns the vehicle control387* @return The vehicle control388* @see MSVehicleControl389* @see myVehicleControl390*/391MSVehicleControl& getVehicleControl() {392return *myVehicleControl;393}394395396/** @brief Returns the person control397*398* If the person control does not exist, yet, it is created.399*400* @return The person control401* @see MSPersonControl402* @see myPersonControl403*/404virtual MSTransportableControl& getPersonControl();405406/** @brief Returns whether persons are simulated407*/408bool hasPersons() const {409return myPersonControl != nullptr;410}411412/** @brief Returns the container control413*414* If the container control does not exist, yet, it is created.415*416* @return The container control417* @see MSContainerControl418* @see myContainerControl419*/420virtual MSTransportableControl& getContainerControl();421422/** @brief Returns whether containers are simulated423*/424bool hasContainers() const {425return myContainerControl != nullptr;426}427428429/** @brief Returns the edge control430* @return The edge control431* @see MSEdgeControl432* @see myEdges433*/434MSEdgeControl& getEdgeControl() {435return *myEdges;436}437438439/** @brief Returns the insertion control440* @return The insertion control441* @see MSInsertionControl442* @see myInserter443*/444MSInsertionControl& getInsertionControl() {445return *myInserter;446}447448449/** @brief Returns the detector control450* @return The detector control451* @see MSDetectorControl452* @see myDetectorControl453*/454MSDetectorControl& getDetectorControl() {455return *myDetectorControl;456}457458459/** @brief Returns the tls logics control460* @return The tls logics control461* @see MSTLLogicControl462* @see myLogics463*/464MSTLLogicControl& getTLSControl() {465return *myLogics;466}467468469/** @brief Returns the junctions control470* @return The junctions control471* @see MSJunctionControl472* @see myJunctions473*/474MSJunctionControl& getJunctionControl() {475return *myJunctions;476}477478479/** @brief Returns the event control for events executed at the begin of a time step480* @return The control responsible for events that are executed at the begin of a time step481* @see MSEventControl482* @see myBeginOfTimestepEvents483*/484MSEventControl* getBeginOfTimestepEvents() {485return myBeginOfTimestepEvents;486}487488489/** @brief Returns the event control for events executed at the end of a time step490* @return The control responsible for events that are executed at the end of a time step491* @see MSEventControl492* @see myEndOfTimestepEvents493*/494MSEventControl* getEndOfTimestepEvents() {495return myEndOfTimestepEvents;496}497498499/** @brief Returns the event control for insertion events500* @return The control responsible for insertion events501* @see MSEventControl502* @see myInsertionEvents503*/504MSEventControl* getInsertionEvents() {505return myInsertionEvents;506}507508509/** @brief Returns the shapes container510* @return The shapes container511* @see ShapeContainer512* @see myShapeContainer513*/514ShapeContainer& getShapeContainer() {515return *myShapeContainer;516}517518/** @brief Returns the dynamic shapes updater519* @see PolygonDynamics520*/521MSDynamicShapeUpdater* getDynamicShapeUpdater() {522return myDynamicShapeUpdater.get();523}524525/** @brief Creates and returns a dynamic shapes updater526* @see PolygonDynamics527*/528MSDynamicShapeUpdater* makeDynamicShapeUpdater();529530/** @brief Returns the net's internal edge travel times/efforts container531*532* If the net does not have such a container, it is built.533* @return The net's knowledge about edge weights534*/535MSEdgeWeightsStorage& getWeightsStorage();536/// @}537538/// @name Insertion and retrieval of stopping places539/// @{540541/** @brief Adds a stopping place542*543* If another stop with the same id and category exists, false is returned.544* Otherwise, the stop is added to the internal stopping place container.545*546* This control gets responsible for deletion of the added stop.547*548* @param[in] stop The stop to add549* @return Whether the stop could be added550*/551bool addStoppingPlace(SumoXMLTag category, MSStoppingPlace* stop);552553554/** @brief Adds a traction substation555*556* If another traction substation with the same id and category exists, false is returned.557* Otherwise, the traction substation is added to the internal substations container.558*559* @param[in] substation The traction substation to add560* @return Whether the stop could be added561*/562bool addTractionSubstation(MSTractionSubstation* substation);563564565/** @brief Returns the named stopping place of the given category566* @param[in] id The id of the stop to return.567* @param[in] category The type of stop568* @return The named stop, or 0 if no such stop exists569*/570MSStoppingPlace* getStoppingPlace(const std::string& id, const SumoXMLTag category) const;571572/** @brief Returns the named stopping place by looking through all categories573* @param[in] id The id of the stop to return.574* @return The named stop, or 0 if no such stop exists575*/576MSStoppingPlace* getStoppingPlace(const std::string& id) const;577578/** @brief Returns the stop of the given category close to the given position579* @param[in] lane the lane of the stop to return.580* @param[in] pos the position of the stop to return.581* @param[in] category The type of stop582* @return The stop id on the location, or "" if no such stop exists583*/584std::string getStoppingPlaceID(const MSLane* lane, const double pos, const SumoXMLTag category) const;585586/* @brief returns all stopping places of that category with the same (non-empty) name attribute587*/588const std::vector<MSStoppingPlace*>& getStoppingPlaceAlternatives(const std::string& name, SumoXMLTag category) const;589/// @}590591const NamedObjectCont<MSStoppingPlace*>& getStoppingPlaces(SumoXMLTag category) const;592593/// @brief write charging station output594void writeChargingStationOutput() const;595596/// @brief write rail signal block output597void writeRailSignalBlocks() const;598599/// @brief creates a wrapper for the given logic (see GUINet)600virtual void createTLWrapper(MSTrafficLightLogic*) {};601602/// @brief write the output generated by an overhead wire segment603void writeOverheadWireSegmentOutput() const;604605/// @brief write electrical substation output606void writeSubstationOutput() const;607608/// @brief return wheter the given logic (or rather its wrapper) is selected in the GUI609virtual bool isSelected(const MSTrafficLightLogic*) const {610return false;611}612/// @brief update view after simulation.loadState613virtual void updateGUI() const { }614615/// @brief load state from file and return new time616SUMOTime loadState(const std::string& fileName, const bool catchExceptions);617618/// @brief reset state to the beginning without reloading the network619void quickReload();620621/// @name Notification about vehicle state changes622/// @{623624/// @brief Definition of a vehicle state625enum class VehicleState {626/// @brief The vehicle was built, but has not yet departed627BUILT,628/// @brief The vehicle has departed (was inserted into the network)629DEPARTED,630/// @brief The vehicle started to teleport631STARTING_TELEPORT,632/// @brief The vehicle ended being teleported633ENDING_TELEPORT,634/// @brief The vehicle arrived at his destination (is deleted)635ARRIVED,636/// @brief The vehicle got a new route637NEWROUTE,638/// @brief The vehicles starts to park639STARTING_PARKING,640/// @brief The vehicle ends to park641ENDING_PARKING,642/// @brief The vehicles starts to stop643STARTING_STOP,644/// @brief The vehicle ends to stop645ENDING_STOP,646/// @brief The vehicle is involved in a collision647COLLISION,648/// @brief The vehicle had to brake harder than permitted649EMERGENCYSTOP,650/// @brief Vehicle maneuvering either entering or exiting a parking space651MANEUVERING652};653654655/** @class VehicleStateListener656* @brief Interface for objects listening to vehicle state changes657*/658class VehicleStateListener {659public:660/// @brief Constructor661VehicleStateListener() { }662663/// @brief Destructor664virtual ~VehicleStateListener() { }665666/** @brief Called if a vehicle changes its state667* @param[in] vehicle The vehicle which changed its state668* @param[in] to The state the vehicle has changed to669* @param[in] info Additional information on the state change670*/671virtual void vehicleStateChanged(const SUMOVehicle* const vehicle, VehicleState to, const std::string& info = "") = 0;672673};674675676/** @brief Adds a vehicle states listener677* @param[in] listener The listener to add678*/679void addVehicleStateListener(VehicleStateListener* listener);680681682/** @brief Removes a vehicle states listener683* @param[in] listener The listener to remove684*/685void removeVehicleStateListener(VehicleStateListener* listener);686687688/** @brief Informs all added listeners about a vehicle's state change689* @param[in] vehicle The vehicle which changed its state690* @param[in] to The state the vehicle has changed to691* @param[in] info Information regarding the replacement692* @see VehicleStateListener:vehicleStateChanged693*/694void informVehicleStateListener(const SUMOVehicle* const vehicle, VehicleState to, const std::string& info = "");695/// @}696697698/// @name Notification about transportable state changes699/// @{700701/// @brief Definition of a transportable state702enum class TransportableState {703/// @brief The transportable person has departed (was inserted into the network)704PERSON_DEPARTED,705/// @brief The transportable person arrived at his destination (is deleted)706PERSON_ARRIVED,707/// @brief The transportable container has departed (was inserted into the network)708CONTAINER_DEPARTED,709/// @brief The transportable container arrived at his destination (is deleted)710CONTAINER_ARRIVED711};712713714/** @class TransportableStateListener715* @brief Interface for objects listening to transportable state changes716*/717class TransportableStateListener {718public:719/// @brief Constructor720TransportableStateListener() { }721722/// @brief Destructor723virtual ~TransportableStateListener() { }724725/** @brief Called if a transportable changes its state726* @param[in] transportable The transportable which changed its state727* @param[in] to The state the transportable has changed to728* @param[in] info Additional information on the state change729*/730virtual void transportableStateChanged(const MSTransportable* const transportable, TransportableState to, const std::string& info = "") = 0;731732};733734735/** @brief Adds a transportable states listener736* @param[in] listener The listener to add737*/738void addTransportableStateListener(TransportableStateListener* listener);739740741/** @brief Removes a transportable states listener742* @param[in] listener The listener to remove743*/744void removeTransportableStateListener(TransportableStateListener* listener);745746747/** @brief Informs all added listeners about a transportable's state change748* @param[in] transportable The transportable which changed its state749* @param[in] to The state the transportable has changed to750* @param[in] info Information regarding the replacement751* @see TransportableStateListener:TransportableStateChanged752*/753void informTransportableStateListener(const MSTransportable* const transportable, TransportableState to, const std::string& info = "");754/// @}755756757/// @brief register collision and return whether it was the first one involving these vehicles758bool registerCollision(const SUMOTrafficObject* collider, const SUMOTrafficObject* victim, const std::string& collisionType, const MSLane* lane, double pos);759760const CollisionMap& getCollisions() const {761return myCollisions;762}763764765/** @brief Returns the travel time to pass an edge766* @param[in] e The edge for which the travel time to be passed shall be returned767* @param[in] v The vehicle that is rerouted768* @param[in] t The time for which the travel time shall be returned [s]769* @return The travel time for an edge770* @see DijkstraRouter_ByProxi771*/772static double getTravelTime(const MSEdge* const e, const SUMOVehicle* const v, double t);773774775/** @brief Returns the effort to pass an edge776* @param[in] e The edge for which the effort to be passed shall be returned777* @param[in] v The vehicle that is rerouted778* @param[in] t The time for which the effort shall be returned [s]779* @return The effort (abstract) for an edge780* @see DijkstraRouter_ByProxi781*/782static double getEffort(const MSEdge* const e, const SUMOVehicle* const v, double t);783784785/* @brief get the router, initialize on first use786* @param[in] prohibited The vector of forbidden edges (optional)787*/788MSVehicleRouter& getRouterTT(int rngIndex, const Prohibitions& prohibited = {}) const;789MSVehicleRouter& getRouterEffort(int rngIndex, const Prohibitions& prohibited = {}) const;790MSPedestrianRouter& getPedestrianRouter(int rngIndex, const Prohibitions& prohibited = {}) const;791MSTransportableRouter& getIntermodalRouter(int rngIndex, const int routingMode = 0, const Prohibitions& prohibited = {}) const;792793static void adaptIntermodalRouter(MSTransportableRouter& router);794795796/// @brief return whether the network contains internal links797bool hasInternalLinks() const {798return myHasInternalLinks;799}800801/// @brief return whether the network was built with higher junction speeds802bool hasJunctionHigherSpeeds() const {803return myJunctionHigherSpeeds;804}805806/// @brief return whether the network contains elevation data807bool hasElevation() const {808return myHasElevation;809}810811/// @brief return whether the network contains walkingareas and crossings812bool hasPedestrianNetwork() const {813return myHasPedestrianNetwork;814815}816/// @brief return whether the network contains bidirectional rail edges817bool hasBidiEdges() const {818return myHasBidiEdges;819}820821/// @brief return the network version822MMVersion getNetworkVersion() const {823return myVersion;824}825826/// @brief return whether a warning regarding the given object shall be issued827bool warnOnce(const std::string& typeAndID);828829void interrupt() {830myAmInterrupted = true;831}832833bool isInterrupted() const {834return myAmInterrupted;835}836837/// @brief gui may prevent final meanData reset to keep live data visible838virtual bool skipFinalReset() const {839return false;840}841842MSMapMatcher* getMapMatcher() const;843844/// @brief find electrical substation by its id845MSTractionSubstation* findTractionSubstation(const std::string& substationId);846847/// @brief return whether given electrical substation exists in the network848bool existTractionSubstation(const std::string& substationId);849850/// @brief string constants for simstep stages851static const std::string STAGE_EVENTS;852static const std::string STAGE_MOVEMENTS;853static const std::string STAGE_LANECHANGE;854static const std::string STAGE_INSERTIONS;855static const std::string STAGE_REMOTECONTROL;856857protected:858/// @brief check all lanes for elevation data859bool checkElevation();860861/// @brief check all lanes for type walkingArea862bool checkWalkingarea();863864/// @brief check wether bidirectional edges occur in the network865bool checkBidiEdges();866867/// @brief remove collisions from the previous simulation step868void removeOutdatedCollisions();869870/** @brief Performs the parts of the simulation step which happen after the move871*/872void postMoveStep();873874protected:875/// @brief Unique instance of MSNet876static MSNet* myInstance;877878/// @brief Route loader for dynamic loading of routes879SUMORouteLoaderControl* myRouteLoaders;880881/// @brief Current time step882SUMOTime myStep;883884/// @brief whether libsumo triggered a partial step (executeMove)885bool myStepCompletionMissing = false;886887/// @brief Maximum number of teleports.888int myMaxTeleports;889890/// @brief whether an interrupt occurred891bool myAmInterrupted;892893894895/// @name Substructures896/// @{897898/// @brief Controls vehicle building and deletion; @see MSVehicleControl899MSVehicleControl* myVehicleControl;900/// @brief Controls person building and deletion; @see MSTransportableControl901MSTransportableControl* myPersonControl;902/// @brief Controls container building and deletion; @see MSTransportableControl903MSTransportableControl* myContainerControl;904/// @brief Controls edges, performs vehicle movement; @see MSEdgeControl905MSEdgeControl* myEdges;906/// @brief Controls junctions, realizes right-of-way rules; @see MSJunctionControl907MSJunctionControl* myJunctions;908/// @brief Controls tls logics, realizes waiting on tls rules; @see MSJunctionControl909MSTLLogicControl* myLogics;910/// @brief Controls vehicle insertion; @see MSInsertionControl911MSInsertionControl* myInserter;912/// @brief Controls detectors; @see MSDetectorControl913MSDetectorControl* myDetectorControl;914/// @brief Controls events executed at the begin of a time step; @see MSEventControl915MSEventControl* myBeginOfTimestepEvents;916/// @brief Controls events executed at the end of a time step; @see MSEventControl917MSEventControl* myEndOfTimestepEvents;918/// @brief Controls insertion events; @see MSEventControl919MSEventControl* myInsertionEvents;920/// @brief A container for geometrical shapes; @see ShapeContainer921ShapeContainer* myShapeContainer;922/// @brief The net's knowledge about edge efforts/travel times; @see MSEdgeWeightsStorage923MSEdgeWeightsStorage* myEdgeWeights;924/// @}925926927928/// @name data needed for computing performance values929/// @{930931/// @brief Information whether the simulation duration shall be logged932bool myLogExecutionTime;933934/// @brief Information whether the number of the simulation step shall be logged935bool myLogStepNumber;936/// @brief Period between successive step-log outputs937int myLogStepPeriod;938939/// @brief The last simulation step duration940long myTraCIStepDuration = 0, mySimStepDuration = 0;941942/// @brief The overall simulation duration943long mySimBeginMillis;944945/// @brief The overall time spent waiting for traci operations including946long myTraCIMillis;947948/// @brief The overall number of vehicle movements949long long int myVehiclesMoved;950long long int myPersonsMoved;951//}952953954955/// @name State output variables956/// @{957958/// @brief Times at which a state shall be written959std::vector<SUMOTime> myStateDumpTimes;960/// @brief The names for the state files961std::vector<std::string> myStateDumpFiles;962/// @brief The names of the last K periodic state files (only only K shall be kept)963std::vector<std::string> myPeriodicStateFiles;964/// @brief The period for writing state965SUMOTime myStateDumpPeriod;966/// @brief name components for periodic state967std::string myStateDumpPrefix;968std::string myStateDumpSuffix;969/// @}970971972973/// @brief Whether the network contains edges which not all vehicles may pass974bool myHavePermissions;975976/// @brief The vehicle class specific speed restrictions977std::map<std::string, std::map<SUMOVehicleClass, double> > myRestrictions;978979/// @brief Preferences for routing980std::map<SUMOVehicleClass, std::map<std::string, double> > myVClassPreferences;981std::map<std::string, std::map<std::string, double> > myVTypePreferences;982983/// @brief The edge type specific meso parameters984std::map<std::string, MESegment::MesoEdgeType> myMesoEdgeTypes;985986/// @brief Whether the network contains internal links/lanes/edges987bool myHasInternalLinks;988989/// @brief Whether the network was built with higher speed on junctions990bool myJunctionHigherSpeeds;991992/// @brief Whether the network contains elevation data993bool myHasElevation;994995/// @brief Whether the network contains pedestrian network elements996bool myHasPedestrianNetwork;997998/// @brief Whether the network contains bidirectional rail edges999bool myHasBidiEdges;10001001/// @brief Whether the network was built for left-hand traffic1002bool myLefthand;10031004/// @brief the network version1005MMVersion myVersion;10061007/// @brief end of loaded edgeData1008SUMOTime myEdgeDataEndTime;10091010/// @brief Dictionary of bus / container stops1011std::map<SumoXMLTag, NamedObjectCont<MSStoppingPlace*> > myStoppingPlaces;10121013/// @brief dictionary of named stopping places1014std::map<SumoXMLTag, std::map<std::string, std::vector<MSStoppingPlace*> > > myNamedStoppingPlaces;10151016/// @brief Dictionary of traction substations1017std::vector<MSTractionSubstation*> myTractionSubstations;10181019/// @brief Container for vehicle state listener1020std::vector<VehicleStateListener*> myVehicleStateListeners;10211022/// @brief Container for transportable state listener1023std::vector<TransportableStateListener*> myTransportableStateListeners;10241025/// @brief collisions in the current time step1026CollisionMap myCollisions;10271028#ifdef HAVE_FOX1029/// @brief to avoid concurrent access to the state update function1030FXMutex myVehicleStateListenerMutex;10311032/// @brief to avoid concurrent access to the state update function1033FXMutex myTransportableStateListenerMutex;1034#endif1035static const NamedObjectCont<MSStoppingPlace*> myEmptyStoppingPlaceCont;1036static const std::vector<MSStoppingPlace*> myEmptyStoppingPlaceVector;10371038/// @brief container to record warnings that shall only be issued once1039std::map<std::string, bool> myWarnedOnce;10401041/* @brief The router instance for routing by trigger and by traci1042* @note MSDevice_Routing has its own instance since it uses a different weight function1043* @note we provide one member for every switchable router type1044* because the class structure makes it inconvenient to use a superclass1045*/1046mutable std::map<int, MSVehicleRouter*> myRouterTT;1047mutable std::map<int, MSVehicleRouter*> myRouterEffort;1048mutable std::map<int, MSPedestrianRouter*> myPedestrianRouter;1049mutable std::map<int, MSTransportableRouter*> myIntermodalRouter;10501051/// @brief An RTree structure holding lane IDs1052mutable std::pair<bool, NamedRTree> myLanesRTree;10531054/// @brief Updater for dynamic shapes that are tracking traffic objects1055/// (ensures removal of shape dynamics when the objects are removed)1056/// @see utils/shapes/PolygonDynamics1057std::unique_ptr<MSDynamicShapeUpdater> myDynamicShapeUpdater;10581059private:1060/// @brief Invalidated copy constructor.1061MSNet(const MSNet&);10621063/// @brief Invalidated assignment operator.1064MSNet& operator=(const MSNet&);106510661067};106810691070