Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MELoop.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-2026 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/****************************************************************************/
18// The main mesocopic simulation loop
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <vector>
24#include <map>
27
28
29// ===========================================================================
30// class declarations
31// ===========================================================================
32class MESegment;
33class MEVehicle;
34class MSEdge;
35class MSLink;
37class OptionsCont;
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
47class MELoop {
48public:
50 MELoop(const SUMOTime recheckInterval);
51
52 ~MELoop();
53
60 void simulate(SUMOTime tMax);
61
67 void addLeaderCar(MEVehicle* veh, MSLink* link);
68
74
77
79 static bool isEnteringRoundabout(const MSEdge& e);
80
82 static int numSegmentsFor(const double length, const double slength);
83
88 void buildSegmentsFor(const MSEdge& e, const OptionsCont& oc);
89
96 MESegment* getSegmentForEdge(const MSEdge& e, double pos = 0);
97
102 SUMOTime changeSegment(MEVehicle* veh, SUMOTime leaveTime, MESegment* const toSegment,
103 MSMoveReminder::Notification reason, const bool ignoreLink = false) const;
104
106 void clearState();
107
108private:
116 void checkCar(MEVehicle* veh);
117
130
131
136 void teleportVehicle(MEVehicle* veh, MESegment* const toSegment, bool disconnected);
137
138private:
140 std::map<SUMOTime, std::vector<MEVehicle*> > myLeaderCars;
141
143 std::vector<MESegment*> myEdges2FirstSegments;
144
147
150
151private:
153 MELoop(const MELoop&);
154
157};
long long int SUMOTime
Definition GUI.h:36
The main mesocopic simulation loop.
Definition MELoop.h:47
MESegment * nextSegment(MESegment *s, MEVehicle *v)
Retrieve next segment.
Definition MELoop.cpp:274
static bool isEnteringRoundabout(const MSEdge &e)
whether the given edge is entering a roundabout
Definition MELoop.cpp:347
MELoop(const MELoop &)
Invalidated copy constructor.
SUMOTime changeSegment(MEVehicle *veh, SUMOTime leaveTime, MESegment *const toSegment, MSMoveReminder::Notification reason, const bool ignoreLink=false) const
change to the next segment this handles combinations of the following cases: (ending / continuing rou...
Definition MELoop.cpp:79
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition MELoop.cpp:330
MELoop & operator=(const MELoop &)
Invalidated assignment operator.
const SUMOTime myLinkRecheckInterval
the interval at which to recheck at blocked junctions (<=0 means asap)
Definition MELoop.h:149
void simulate(SUMOTime tMax)
Perform simulation up to the given time.
Definition MELoop.cpp:61
bool removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
Definition MELoop.cpp:251
const SUMOTime myFullRecheckInterval
the interval at which to recheck at full segments (<=0 means asap)
Definition MELoop.h:146
void vaporizeCar(MEVehicle *v, MSMoveReminder::Notification reason)
remove the given car and clean up the relevant data structures
Definition MELoop.cpp:266
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
Definition MELoop.cpp:238
void clearState()
Remove all vehicles before quick-loading state.
Definition MELoop.cpp:245
std::vector< MESegment * > myEdges2FirstSegments
mapping from internal edge ids to their initial segments
Definition MELoop.h:143
std::map< SUMOTime, std::vector< MEVehicle * > > myLeaderCars
leader cars in the segments sorted by exit time
Definition MELoop.h:140
~MELoop()
Definition MELoop.cpp:49
void checkCar(MEVehicle *veh)
Check whether the vehicle may move.
Definition MELoop.cpp:135
void teleportVehicle(MEVehicle *veh, MESegment *const toSegment, bool disconnected)
teleports a vehicle or continues a teleport
Definition MELoop.cpp:177
static int numSegmentsFor(const double length, const double slength)
Compute number of segments per edge (best value stay close to the configured segment length)
Definition MELoop.cpp:293
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
Definition MELoop.cpp:304
A single mesoscopic segment (cell)
Definition MESegment.h:50
A vehicle from the mesoscopic point of view.
Definition MEVehicle.h:42
A road/street connecting two junctions.
Definition MSEdge.h:77
Notification
Definition of a vehicle state.
The class responsible for building and deletion of vehicles.
A storage for options typed value containers)
Definition OptionsCont.h:89