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>
41 #include <microsim/MSVehicleType.h>
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
53 class MSCFModel_EIDM : public MSCFModel {
54 public:
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;
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, double predMaxDecel, const MSVehicle* const pred = 0) const;
130 
131 
139  double stopSpeed(const MSVehicle* const veh, const double speed, double gap, double decel) const;
140 
141 
154  double freeSpeed(const MSVehicle* const veh, double speed, double seen,
155  double maxSpeed, const bool onInsertion = false) const;
156 
157  static double freeSpeed(const double currentSpeed, const double decel, const double dist, const double maxSpeed, const bool onInsertion);
158 
168  double interactionGap(const MSVehicle* const, double vL) const;
169 
175  double getSecureGap(const MSVehicle* const veh, const MSVehicle* const /*pred*/, const double speed, const double leaderSpeed, const double leaderMaxDecel) const;
176 
182  double brakeGap(const double speed, const double decel, const double headwayTime) const {
183  if (MSGlobals::gComputeLC) {
184  return MSCFModel::brakeGap(speed, decel, headwayTime);
185  } else {
186  // myDecel + 1.0 does not work correctly with the junction model and impatience > 0.
187  // Vehicles may first be disregarded because their own arrivalTimeBraking is high (TIME2STEPS(30)).
188  // This is amplified by this brakeGap-Term, because they "think" they could still brake in time (low brakeGap),
189  // but actually 1.0 was only added for braking at traffic lights. But then when seen < brakeGap(v) happens (see MSVehicle: arrivalTimeBraking),
190  // they realize, that they will soon arrive at the junction and other vehicles are notified to maybe then brake hard!
191  return MSCFModel::brakeGap(speed, MAX2(decel, myDecel + 1.0), headwayTime);
192  }
193  }
194 
199  double maximumLaneSpeedCF(double maxSpeed, double /*maxSpeedLane*/) const {
200  return maxSpeed;
201  }
202 
207  int getModelID() const {
208  return SUMO_TAG_CF_EIDM;
209  }
210 
215  MSCFModel* duplicate(const MSVehicleType* vtype) const;
216 
217  // @brief Variables that are stored throughout a call to the car-following functions
219  VehicleVariables* ret = new VehicleVariables();
220  ret->minaccel = 100;
221  ret->wouldacc = 100;
222  ret->lastacc = 0;
223  ret->realacc = 100;
224  ret->lastrealacc = 0;
225  ret->realleaderacc = 100;
226  ret->lastleaderacc = 0;
227  ret->v0_int = 0;
228  ret->v0_old = 0;
229  ret->t_off = -10.;
230  ret->myw_gap = 0.;
231  ret->myw_speed = 0.;
232  ret->myw_error = 0.;
233  ret->myv_est_l = 0.;
234  ret->myv_est = 0.;
235  ret->mys_est = 0.;
236  ret->myap_update = 0;
237  return ret;
238  }
239 
240 
241 private:
243  public:
244  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)
245  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)
246  double lastacc; // @brief saves the intended accel-value when the driver was last updated (reaction time) (accel-value is without coolness and drive-off)
247  double realacc; // @brief saves the resulting accel-value between multiple stopSpeed/followSpeed calls that the CF-model will eventually output
248  double lastrealacc; // @brief saves the resulting accel-value the CF-model eventually outputed when the driver was last updated (reaction time)
249  double realleaderacc; // @brief saves the leader accel-value from the call that resulted in the new speed
250  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)
251  double v0_int; // @brief is the internal desired speed of the vehicle
252  double v0_old; // @brief is the previous desired speed of the vehicle needed for calculation purpose
253  double t_off; // @brief is the time when the vehicle starts driving off
254  double myw_gap; // @brief is the Wiener Process for the gap error calculation
255  double myw_speed; // @brief is the Wiener Process for the speed error calculation
256  double myw_error; // @brief is the Wiener Process for the driving error calculation
257  double myv_est_l; // @brief saves the speed of the leading vehicle / 0 for a stop at the last driver update (reaction time)
258  double myv_est; // @brief saves the speed of the vehicle at the last driver update (reaction time)
259  double mys_est; // @brief saves the gap to leading vehicle / next stop at the last driver update (reaction time)
260  int myap_update; // @brief is a number counting the simulation steps since the last driver/vehicle update (reaction time)
261  std::vector<std::pair<double, double>> stop; // @brief saves the intended accelerations and distances from all stopSpeed-calculations of the current time step
262  };
263 
264 private:
265 
272  double patchSpeedBeforeLCEIDM(const MSVehicle* veh, double vMin, double vMax, VehicleVariables* vars) const;
273 
274  // @brief contains the main CF-model calculations
275  double _v(const MSVehicle* const veh, const double gap2pred, const double mySpeed,
276  const double predSpeed, const double desSpeed, const bool respectMinGap, const int update) const;
277 
278  // @brief calculates the internal desired speed for the vehicle depending on myTpreview and upcoming turns, intersections and speed limit changes
279  void internalspeedlimit(MSVehicle* const veh, const double oldV) const;
280 
281  // @brief calculates the SecureGap similar to the MSCFModel-SecureGap-function, yet adding a targetDecel to decelerate with
282  double internalsecuregap(const MSVehicle* const veh, const double speed, const double leaderSpeed, const double targetDecel) const;
283 
284 private:
285  // @brief The IDM delta exponent
286  const double myDelta;
287 
288  // @brief A computational shortcut
289  const double myTwoSqrtAccelDecel;
290 
291  // @brief The number of iterations in speed calculations
292  const int myIterations;
293 
294  // @brief Correlation time of the Wiener Process for the driving error
295  const double myTPersDrive;
296 
297  // @brief The maximal reaction time
298  const double myTreaction;
299 
300  // @brief The preview distance time for the desired speed
301  const double myTpreview;
302 
303  // @brief Correlation time of the Wiener Process for the estimation errors
304  const double myTPersEstimate;
305 
306  // @brief Coolness Parameter of the Enhanced Intelligent Driver Model
307  const double myCcoolness;
308 
309  // @brief Estimation error magnitude of the leading vehicle's speed
310  const double mySigmaleader;
311 
312  // @brief Estimation error magnitude of the distance to the leading vehicle / next stop
313  const double mySigmagap;
314 
315  // @brief Driving error magnitude
316  const double mySigmaerror;
317 
318  // @brief Maximal jerk value
319  const double myJerkmax;
320 
321  // @brief Maximal negative acceleration value before reacting instantaneously to the change in intended acceleration
322  const double myEpsilonacc;
323 
324  // @brief Time until the maximal acceleration when driving off
325  const double myTaccmax;
326 
327  // @brief Flatness of the drive off acceleration term
328  const double myMflatness;
329 
330  // @brief Shift of the drive off acceleration term
331  const double myMbegin;
332 
333  // @brief 1=simulate with the acceleration depending on the vehicle dynamics, 0=don't
334  const bool myUseVehDynamics;
335 
336  // @brief number of vehicles in front, that are used to update the acceleration
337  //const int myMaxVehPreview;
338 
339 private:
342 };
343 
344 #endif /* MSCFMODEL_EIDM_H */
@ SUMO_TAG_CF_EIDM
T MAX2(T a, T b)
Definition: StdDefs.h:80
std::vector< std::pair< double, double > > stop
The Extended Intelligent Driver Model (EIDM) car-following model.
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
const double myTPersEstimate
double maximumSafeFollowSpeed(double gap, double egoSpeed, double predSpeed, double predMaxDecel, bool onInsertion=false) const
Returns the maximum safe velocity for following the given leader.
const double myTPersDrive
const bool myUseVehDynamics
~MSCFModel_EIDM()
Destructor.
const double myDelta
const double myCcoolness
double stopSpeed(const MSVehicle *const veh, const double speed, double gap, double decel) const
Computes the vehicle's safe speed for approaching a non-moving obstacle.
const double myTaccmax
const double mySigmaleader
const double myEpsilonacc
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
double freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion=false) const
Computes the vehicle's safe speed without a leader.
const double myMbegin
const double myTwoSqrtAccelDecel
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...
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
double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const
Computes the vehicle's safe speed.
MSCFModel_EIDM & operator=(const MSCFModel_EIDM &s)
Invalidated assignment operator.
const double mySigmagap
double maximumLaneSpeedCF(double maxSpeed, double) const
Returns the maximum velocity the CF-model wants to achieve in the next step.
VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting.
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
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 patchSpeedBeforeLCEIDM(const MSVehicle *veh, double vMin, double vMax, VehicleVariables *vars) const
Applies dawdling / driving error.
The car-following model abstraction.
Definition: MSCFModel.h:55
virtual double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
Definition: MSCFModel.h:334
double myDecel
The vehicle's maximum deceleration [m/s^2].
Definition: MSCFModel.h:647
static bool gComputeLC
whether the simulationLoop is in the lane changing phase
Definition: MSGlobals.h:127
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:75
The car-following model and parameter.
Definition: MSVehicleType.h:62