Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSCFModel_EIDM.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/****************************************************************************/
17
24// The Extended Intelligent Driver Model (EIDM) car-following model
25//
26// Publication: Salles, Dominik, S. Kaufmann and H. Reuss. “Extending the Intelligent Driver
27// Model in SUMO and Verifying the Drive Off Trajectories with Aerial
28// Measurements.” (2020).
29/****************************************************************************/
30#ifndef MSCFMODEL_EIDM_H
31#define MSCFMODEL_EIDM_H
32
33// ===========================================================================
34// included modules
35// ===========================================================================
36#include <config.h>
37
38#include "MSCFModel.h"
39#include <microsim/MSLane.h>
40#include <microsim/MSVehicle.h>
44
45
46// ===========================================================================
47// class definitions
48// ===========================================================================
53class MSCFModel_EIDM : public MSCFModel {
54public:
58 MSCFModel_EIDM(const MSVehicleType* vtype);
59
62
65
78 double insertionFollowSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle* const pred = 0) const;
79
80
90 double insertionStopSpeed(const MSVehicle* const veh, double speed, double gap) const;
91
92
101 double maximumSafeFollowSpeed(double gap, double egoSpeed, double predSpeed, double predMaxDecel, bool onInsertion = false, const CalcReason usage = CalcReason::CURRENT) const;
102
103
110 double maximumSafeStopSpeed(double gap, double decel, double currentSpeed, bool onInsertion = false, double headway = -1) const;
111
112
118 double finalizeSpeed(MSVehicle* const veh, double vPos) const;
119
120
129 double followSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed,
130 double predMaxDecel, const MSVehicle* const pred = 0, const CalcReason usage = CalcReason::CURRENT) const;
131
132
140 double stopSpeed(const MSVehicle* const veh, const double speed, double gap, double decel, const CalcReason usage = CalcReason::CURRENT) const;
141
142
155 double freeSpeed(const MSVehicle* const veh, double speed, double seen,
156 double maxSpeed, const bool onInsertion = false, const CalcReason usage = CalcReason::CURRENT) const;
157
158 static double freeSpeed(const double currentSpeed, const double decel, const double dist, const double maxSpeed, const bool onInsertion);
159
169 double interactionGap(const MSVehicle* const, double vL) const;
170
176 double getSecureGap(const MSVehicle* const veh, const MSVehicle* const /*pred*/, const double speed, const double leaderSpeed, const double leaderMaxDecel) const;
177
183 double brakeGap(const double speed, const double decel, const double headwayTime) const {
185 return MSCFModel::brakeGap(speed, decel, headwayTime);
186 } else {
187 // myDecel + 1.0 does not work correctly with the junction model and impatience > 0.
188 // Vehicles may first be disregarded because their own arrivalTimeBraking is high (TIME2STEPS(30)).
189 // This is amplified by this brakeGap-Term, because they "think" they could still brake in time (low brakeGap),
190 // but actually 1.0 was only added for braking at traffic lights. But then when seen < brakeGap(v) happens (see MSVehicle: arrivalTimeBraking),
191 // they realize, that they will soon arrive at the junction and other vehicles are notified to maybe then brake hard!
192 return MSCFModel::brakeGap(speed, MAX2(decel, myDecel + 1.0), headwayTime);
193 }
194 }
195
201 double maxNextSafeMin(double speed, const MSVehicle* const veh = 0) const {
202 UNUSED_PARAMETER(speed);
203 UNUSED_PARAMETER(veh);
204 return 0;
205 }
206
211 double maximumLaneSpeedCF(const MSVehicle* const /*veh*/, double maxSpeed, double /*maxSpeedLane*/) const {
212 return maxSpeed;
213 }
214
219 int getModelID() const {
220 return SUMO_TAG_CF_EIDM;
221 }
222
227 MSCFModel* duplicate(const MSVehicleType* vtype) const;
228
229 // @brief Variables that are stored throughout a call to the car-following functions
232 ret->minaccel = 100;
233 ret->wouldacc = 100;
234 ret->lastacc = 0;
235 ret->realacc = 100;
236 ret->lastrealacc = 0;
237 ret->realleaderacc = 100;
238 ret->lastleaderacc = 0;
239 ret->v0_int = 0;
240 ret->v0_old = 0;
241 ret->t_off = -10.;
242 ret->myw_gap = 0.;
243 ret->myw_speed = 0.;
244 ret->myw_error = 0.;
245 ret->myv_est_l = 0.;
246 ret->myv_est = 0.;
247 ret->mys_est = 0.;
248 ret->myrespectMinGap = true;
249 ret->myap_update = 0;
250 return ret;
251 }
252
253
254private:
256 public:
257 double minaccel; // @brief saves the intended accel-value between multiple stopSpeed/followSpeed calls to then check which call actually updated the vehicles acceleration (accel-value is without coolness and drive-off)
258 double wouldacc; // @brief saves the intended accel-value the CF-model would output, if there is no reaction time (accel-value is without coolness and drive-off)
259 double lastacc; // @brief saves the intended accel-value when the driver was last updated (reaction time) (accel-value is without coolness and drive-off)
260 double realacc; // @brief saves the resulting accel-value between multiple stopSpeed/followSpeed calls that the CF-model will eventually output
261 double lastrealacc; // @brief saves the resulting accel-value the CF-model eventually outputted when the driver was last updated (reaction time)
262 double realleaderacc; // @brief saves the leader accel-value from the call that resulted in the new speed
263 double lastleaderacc; // @brief saves the leader accel-value from the call that resulted in the new speed when the driver was last updated (reaction time)
264 double v0_int; // @brief is the internal desired speed of the vehicle
265 double v0_old; // @brief is the previous desired speed of the vehicle needed for calculation purpose
266 double t_off; // @brief is the time when the vehicle starts driving off
267 double myw_gap; // @brief is the Wiener Process for the gap error calculation
268 double myw_speed; // @brief is the Wiener Process for the speed error calculation
269 double myw_error; // @brief is the Wiener Process for the driving error calculation
270 double myv_est_l; // @brief saves the speed of the leading vehicle / 0 for a stop at the last driver update (reaction time)
271 double myv_est; // @brief saves the speed of the vehicle at the last driver update (reaction time)
272 double mys_est; // @brief saves the gap to leading vehicle / next stop at the last driver update (reaction time)
273 bool myrespectMinGap; // @brief saves the information, if minGap was added to the desired gap s* at the last driver update (reaction time)
274 int myap_update; // @brief is a number counting the simulation steps since the last driver/vehicle update (reaction time)
275 std::vector<std::pair<double, double>> stop; // @brief saves the intended accelerations and distances from all stopSpeed-calculations of the current time step
276
280 void saveState(OutputDevice& out, const MSCFModel& cfm) const;
281
285 void loadState(const SUMOSAXAttributes& attrs);
286 };
287
288private:
289
296 double patchSpeedBeforeLCEIDM(const MSVehicle* veh, double vMin, double vMax, const VehicleVariables* vars) const;
297
298 // @brief calculates the slow to start term when driving off
299 double slowToStartTerm(MSVehicle* const veh, const double newSpeed, const double currentSpeed, const double vMax, VehicleVariables* vars) const;
300
301 // @brief contains the main CF-model calculations
302 double _v(const MSVehicle* const veh, const double gap2pred, const double mySpeed,
303 const double predSpeed, const double desSpeed, const bool respectMinGap, const int update, const CalcReason usage) const;
304
305 // @brief calculates the internal desired speed for the vehicle depending on myTpreview and upcoming turns, intersections and speed limit changes
306 void internalspeedlimit(MSVehicle* const veh, const double oldV) const;
307
308 // @brief calculates the SecureGap similar to the MSCFModel-SecureGap-function, yet adding a targetDecel to decelerate with
309 double internalsecuregap(const MSVehicle* const veh, const double speed, const double leaderSpeed, const double targetDecel) const;
310
311private:
312 // @brief The IDM delta exponent
313 const double myDelta;
314
315 // @brief The number of iterations in speed calculations
316 const int myIterations;
317
318 // @brief Correlation time of the Wiener Process for the driving error
319 const double myTPersDrive;
320
321 // @brief The maximal reaction time
322 const double myTreaction;
323
324 // @brief The preview distance time for the desired speed
325 const double myTpreview;
326
327 // @brief Correlation time of the Wiener Process for the estimation errors
328 const double myTPersEstimate;
329
330 // @brief Coolness Parameter of the Enhanced Intelligent Driver Model
331 const double myCcoolness;
332
333 // @brief Estimation error magnitude of the leading vehicle's speed
334 const double mySigmaleader;
335
336 // @brief Estimation error magnitude of the distance to the leading vehicle / next stop
337 const double mySigmagap;
338
339 // @brief Driving error magnitude
340 const double mySigmaerror;
341
342 // @brief Maximal jerk value
343 const double myJerkmax;
344
345 // @brief Maximal negative acceleration value before reacting instantaneously to the change in intended acceleration
346 const double myEpsilonacc;
347
348 // @brief Time until the maximal acceleration when driving off
349 const double myTaccmax;
350
351 // @brief Flatness of the drive off acceleration term
352 const double myMflatness;
353
354 // @brief Shift of the drive off acceleration term
355 const double myMbegin;
356
357 // @brief 1=simulate with the acceleration depending on the vehicle dynamics, 0=don't
359
360 // @brief number of vehicles in front, that are used to update the acceleration
361 //const int myMaxVehPreview;
362
363private:
366};
367
368#endif /* MSCFMODEL_EIDM_H */
@ SUMO_TAG_CF_EIDM
T MAX2(T a, T b)
Definition StdDefs.h:86
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the vehicle variables from the given description.
std::vector< std::pair< double, double > > stop
void saveState(OutputDevice &out, const MSCFModel &cfm) const
Saves the vehicle variables.
const double myTPersEstimate
double patchSpeedBeforeLCEIDM(const MSVehicle *veh, double vMin, double vMax, const VehicleVariables *vars) const
Applies dawdling / driving error.
const double myTPersDrive
const bool myUseVehDynamics
~MSCFModel_EIDM()
Destructor.
const double myDelta
const double myCcoolness
const double myTaccmax
double maximumLaneSpeedCF(const MSVehicle *const, double maxSpeed, double) const
Returns the maximum velocity the CF-model wants to achieve in the next step.
const double mySigmaleader
MSCFModel_EIDM & operator=(const MSCFModel_EIDM &s)
Invalidated assignment operator.
const double myEpsilonacc
double slowToStartTerm(MSVehicle *const veh, const double newSpeed, const double currentSpeed, const double vMax, VehicleVariables *vars) const
double maximumSafeFollowSpeed(double gap, double egoSpeed, double predSpeed, double predMaxDecel, bool onInsertion=false, const CalcReason usage=CalcReason::CURRENT) const
Returns the maximum safe velocity for following the given leader.
double maximumSafeStopSpeed(double gap, double decel, double currentSpeed, bool onInsertion=false, double headway=-1) const
Returns the maximum next velocity for stopping within gap.
double insertionFollowSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const
Computes the vehicle's safe speed (no dawdling) This method is used during the insertion stage....
double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences.
const double myTreaction
const double myMbegin
double stopSpeed(const MSVehicle *const veh, const double speed, double gap, double decel, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed for approaching a non-moving obstacle.
MSCFModel_EIDM(const MSVehicleType *vtype)
Constructor.
double insertionStopSpeed(const MSVehicle *const veh, double speed, double gap) const
Computes the vehicle's safe speed for approaching an obstacle at insertion without constraints due to...
VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting.
double freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion=false, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed without a leader.
int getModelID() const
Returns the model's name.
double brakeGap(const double speed, const double decel, const double headwayTime) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
double internalsecuregap(const MSVehicle *const veh, const double speed, const double leaderSpeed, const double targetDecel) const
const double mySigmagap
double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed.
void internalspeedlimit(MSVehicle *const veh, const double oldV) const
double getSecureGap(const MSVehicle *const veh, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0).
const double myMflatness
double maxNextSafeMin(double speed, const MSVehicle *const veh=0) const
Returns the maximum speed given the current speed and regarding driving dynamics.
const double myJerkmax
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
double interactionGap(const MSVehicle *const, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
const double mySigmaerror
const double myTpreview
const int myIterations
double _v(const MSVehicle *const veh, const double gap2pred, const double mySpeed, const double predSpeed, const double desSpeed, const bool respectMinGap, const int update, const CalcReason usage) const
The car-following model abstraction.
Definition MSCFModel.h:59
CalcReason
What the return value of stop/follow/free-Speed is used for.
Definition MSCFModel.h:95
@ CURRENT
the return value is used for calculating the next speed
Definition MSCFModel.h:97
MSCFModel(const MSVehicleType *vtype)
Constructor.
Definition MSCFModel.cpp:55
double myDecel
The vehicle's maximum deceleration [m/s^2].
Definition MSCFModel.h:762
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
Definition MSCFModel.h:424
static bool gComputeLC
whether the simulationLoop is in the lane changing phase
Definition MSGlobals.h:140
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
The car-following model and parameter.
Static storage of an output device and its base (abstract) implementation.
Encapsulated SAX-Attributes.
#define UNUSED_PARAMETER(x)