Eclipse SUMO - Simulation of Urban MObility
MSCFModel_EIDM.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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(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 outputed 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 };
277
278private:
279
286 double patchSpeedBeforeLCEIDM(const MSVehicle* veh, double vMin, double vMax, const VehicleVariables* vars) const;
287
288 // @brief calculates the slow to start term when driving off
289 double slowToStartTerm(MSVehicle* const veh, const double newSpeed, const double currentSpeed, const double vMax, VehicleVariables* vars) const;
290
291 // @brief contains the main CF-model calculations
292 double _v(const MSVehicle* const veh, const double gap2pred, const double mySpeed,
293 const double predSpeed, const double desSpeed, const bool respectMinGap, const int update, const CalcReason usage) const;
294
295 // @brief calculates the internal desired speed for the vehicle depending on myTpreview and upcoming turns, intersections and speed limit changes
296 void internalspeedlimit(MSVehicle* const veh, const double oldV) const;
297
298 // @brief calculates the SecureGap similar to the MSCFModel-SecureGap-function, yet adding a targetDecel to decelerate with
299 double internalsecuregap(const MSVehicle* const veh, const double speed, const double leaderSpeed, const double targetDecel) const;
300
301private:
302 // @brief The IDM delta exponent
303 const double myDelta;
304
305 // @brief A computational shortcut
307
308 // @brief The number of iterations in speed calculations
309 const int myIterations;
310
311 // @brief Correlation time of the Wiener Process for the driving error
312 const double myTPersDrive;
313
314 // @brief The maximal reaction time
315 const double myTreaction;
316
317 // @brief The preview distance time for the desired speed
318 const double myTpreview;
319
320 // @brief Correlation time of the Wiener Process for the estimation errors
321 const double myTPersEstimate;
322
323 // @brief Coolness Parameter of the Enhanced Intelligent Driver Model
324 const double myCcoolness;
325
326 // @brief Estimation error magnitude of the leading vehicle's speed
327 const double mySigmaleader;
328
329 // @brief Estimation error magnitude of the distance to the leading vehicle / next stop
330 const double mySigmagap;
331
332 // @brief Driving error magnitude
333 const double mySigmaerror;
334
335 // @brief Maximal jerk value
336 const double myJerkmax;
337
338 // @brief Maximal negative acceleration value before reacting instantaneously to the change in intended acceleration
339 const double myEpsilonacc;
340
341 // @brief Time until the maximal acceleration when driving off
342 const double myTaccmax;
343
344 // @brief Flatness of the drive off acceleration term
345 const double myMflatness;
346
347 // @brief Shift of the drive off acceleration term
348 const double myMbegin;
349
350 // @brief 1=simulate with the acceleration depending on the vehicle dynamics, 0=don't
352
353 // @brief number of vehicles in front, that are used to update the acceleration
354 //const int myMaxVehPreview;
355
356private:
359};
360
361#endif /* MSCFMODEL_EIDM_H */
@ SUMO_TAG_CF_EIDM
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
T MAX2(T a, T b)
Definition: StdDefs.h:77
std::vector< std::pair< double, double > > stop
The Extended Intelligent Driver Model (EIDM) car-following model.
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
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
const double myTwoSqrtAccelDecel
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.
double maximumLaneSpeedCF(double maxSpeed, double) const
Returns the maximum velocity the CF-model wants to achieve in the next step.
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:55
CalcReason
What the return value of stop/follow/free-Speed is used for.
Definition: MSCFModel.h:77
double myDecel
The vehicle's maximum deceleration [m/s^2].
Definition: MSCFModel.h:686
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
Definition: MSCFModel.h:373
static bool gComputeLC
whether the simulationLoop is in the lane changing phase
Definition: MSGlobals.h:136
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
The car-following model and parameter.
Definition: MSVehicleType.h:63