SUMO - Simulation of Urban MObility
MSCFModel_Kerner.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // car-following model by B. Kerner
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <microsim/MSVehicle.h>
34 #include <microsim/MSLane.h>
35 #include "MSCFModel_Kerner.h"
37 
38 
39 // ===========================================================================
40 // method definitions
41 // ===========================================================================
43  double decel, double emergencyDecel, double apparentDecel,
44  double headwayTime, double k, double phi) :
45  MSCFModel(vtype, accel, decel, emergencyDecel, apparentDecel, headwayTime),
46  myK(k), myPhi(phi),
47  myTauDecel(decel * headwayTime) {
48 }
49 
50 
52 
53 
54 double
55 MSCFModel_Kerner::moveHelper(MSVehicle* const veh, double vPos) const {
56  const double vNext = MSCFModel::moveHelper(veh, vPos);
58  vars->rand = RandHelper::rand();
59  return vNext;
60 }
61 
62 
63 double
64 MSCFModel_Kerner::followSpeed(const MSVehicle* const veh, double speed, double gap, double predSpeed, double /*predMaxDecel*/) const {
65  return MIN2(_v(veh, speed, maxNextSpeed(speed, veh), gap, predSpeed), maxNextSpeed(speed, veh));
66 }
67 
68 
69 double
70 MSCFModel_Kerner::stopSpeed(const MSVehicle* const veh, const double speed, double gap) const {
71  return MIN2(_v(veh, speed, maxNextSpeed(speed, veh), gap, 0), maxNextSpeed(speed, veh));
72 }
73 
74 
78  ret->rand = RandHelper::rand();
79  return ret;
80 }
81 
82 
83 double
84 MSCFModel_Kerner::_v(const MSVehicle* const veh, double speed, double vfree, double gap, double predSpeed) const {
85  if (predSpeed == 0 && gap < 0.01) {
86  return 0;
87  }
88  // !!! in the following, the prior step is not considered!!!
89  double G = MAX2((double) 0, (double)(SPEED2DIST(myK * speed) + myPhi / myAccel * speed * (speed - predSpeed)));
90  double vcond = gap > G ? speed + ACCEL2SPEED(myAccel) : speed + MAX2(ACCEL2SPEED(-myDecel), MIN2(ACCEL2SPEED(myAccel), predSpeed - speed));
91  double vsafe = (double)(-1. * myTauDecel + sqrt(myTauDecel * myTauDecel + (predSpeed * predSpeed) + (2. * myDecel * gap)));
93  double va = MAX2((double) 0, MIN3(vfree, vsafe, vcond)) + vars->rand;
94  double v = MAX2((double) 0, MIN4(vfree, va, speed + ACCEL2SPEED(myAccel), vsafe));
95  return v;
96 }
97 
98 
99 MSCFModel*
102 }
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
#define SPEED2DIST(x)
Definition: SUMOTime.h:55
double myApparentDecel
The vehicle&#39;s deceleration as expected by surrounding traffic [m/s^2].
Definition: MSCFModel.h:531
#define ACCEL2SPEED(x)
Definition: SUMOTime.h:61
virtual double moveHelper(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences.
Definition: MSCFModel.cpp:153
double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel) const
Computes the vehicle&#39;s safe speed (no dawdling)
T MIN4(T a, T b, T c, T d)
Definition: StdDefs.h:95
The car-following model abstraction.
Definition: MSCFModel.h:60
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:65
double myAccel
The vehicle&#39;s maximum acceleration [m/s^2].
Definition: MSCFModel.h:524
T MAX2(T a, T b)
Definition: StdDefs.h:74
The car-following model and parameter.
Definition: MSVehicleType.h:73
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
double _v(const MSVehicle *const veh, double speed, double vfree, double gap, double predSpeed) const
Returns the "safe" velocity.
T MIN2(T a, T b)
Definition: StdDefs.h:68
double myPhi
Kerner&#39;s phi.
double stopSpeed(const MSVehicle *const veh, const double speed, double gap2pred) const
Computes the vehicle&#39;s safe speed for approaching a non-moving obstacle (no dawdling) ...
double myDecel
The vehicle&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:527
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle&#39;s car following model variables.
Definition: MSVehicle.h:805
MSCFModel_Kerner(const MSVehicleType *vtype, double accel, double decel, double emergencyDecel, double apparentDecel, double headwayTime, double k, double phi)
Constructor.
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
Definition: MSCFModel.cpp:200
double moveHelper(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences.
double myEmergencyDecel
The vehicle&#39;s maximum emergency deceleration [m/s^2].
Definition: MSCFModel.h:529
MSCFModel::VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting...
double myTauDecel
The precomputed value for myDecel*myTau.
T MIN3(T a, T b, T c)
Definition: StdDefs.h:81
double myHeadwayTime
The driver&#39;s desired time headway (aka reaction time tau) [s].
Definition: MSCFModel.h:534
#define G
~MSCFModel_Kerner()
Destructor.