SUMO - Simulation of Urban MObility
MSCFModel_Wiedemann.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // The psycho-physical model of Wiedemann
10 // references:
11 // Andre Stebens - Traffic simulation with the Wiedemann model
12 // Werner - Integration von Fahrzeugfolge- und Fahrstreifenwechselmodellen in die Nachtfahrsimulation LucidDrive
13 // Olstam, Tapani - Comparison of Car-following models
14 /****************************************************************************/
15 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
16 // Copyright (C) 2011-2016 DLR (http://www.dlr.de/) and contributors
17 /****************************************************************************/
18 //
19 // This file is part of SUMO.
20 // SUMO is free software: you can redistribute it and/or modify
21 // it under the terms of the GNU General Public License as published by
22 // the Free Software Foundation, either version 3 of the License, or
23 // (at your option) any later version.
24 //
25 /****************************************************************************/
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <cmath>
38 #include "MSCFModel_Wiedemann.h"
39 #include <microsim/MSVehicle.h>
40 #include <microsim/MSLane.h>
42 
43 
44 // ===========================================================================
45 // static members
46 // ===========================================================================
47 
48 // magic constant proposed by Wiedemann (based on real world measurements)
50 
51 
52 // ===========================================================================
53 // method definitions
54 // ===========================================================================
56  SUMOReal accel, SUMOReal decel,
57  SUMOReal security, SUMOReal estimation) :
58  MSCFModel(vtype, accel, decel, 1.0),
59  mySecurity(security),
60  myEstimation(estimation),
61  myAX(vtype->getLength() + 1. + 2. * security),
62  myCX(25. *(1. + security + estimation)),
63  myMinAccel(0.2 * myAccel) { // +noise?
64 }
65 
66 
68 
69 
72  const SUMOReal vNext = MSCFModel::moveHelper(veh, vPos);
74  vars->accelSign = vNext > veh->getSpeed() ? 1. : -1.;
75  return vNext;
76 }
77 
78 
80 MSCFModel_Wiedemann::followSpeed(const MSVehicle* const veh, SUMOReal /* speed */, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal /*predMaxDecel*/) const {
81  return _v(veh, predSpeed, gap2pred);
82 }
83 
84 
86 MSCFModel_Wiedemann::stopSpeed(const MSVehicle* const veh, const SUMOReal speed, SUMOReal gap) const {
87  /* Wiedemann does not handle approaching junctions or stops very well:
88  * regime approaching() fails when dv = 0 (i.e. a vehicle inserted with speed 0 does not accelerate to reach a stop)
89  * for dv ~ 0 the standard decision tree will switch to following() which
90  * does a lousy job of closing in on a stop / junction
91  * hence we borrow from Krauss here
92  */
93  return MAX2(getSpeedAfterMaxDecel(speed), MIN2(krauss_vsafe(gap, 0), maxNextSpeed(speed, veh)));
94 }
95 
96 
99  UNUSED_PARAMETER(vL);
100  return D_MAX;
101 }
102 
103 
104 MSCFModel*
107 }
108 
109 
110 SUMOReal
111 MSCFModel_Wiedemann::_v(const MSVehicle* veh, SUMOReal predSpeed, SUMOReal gap) const {
113  const SUMOReal dx = gap + myType->getLength(); // wiedemann uses brutto gap
114  const SUMOReal v = veh->getSpeed();
115  const SUMOReal vpref = veh->getMaxSpeed();
116  const SUMOReal dv = v - predSpeed;
117  const SUMOReal bx = myAX + (1 + 7 * mySecurity) * sqrt(v); // Harding propose a factor of *.8 here
118  const SUMOReal ex = 2 - myEstimation; // + RandHelper::randNorm(0.5, 0.15)
119  const SUMOReal sdx = myAX + ex * (bx - myAX);
120  const SUMOReal sdv_root = (dx - myAX) / myCX;
121  const SUMOReal sdv = sdv_root * sdv_root;
122  const SUMOReal cldv = sdv * ex * ex;
123  const SUMOReal opdv = cldv * (-1 - 2 * RandHelper::randNorm(0.5, 0.15));
124  // select the regime, get new acceleration, compute new speed based
125  SUMOReal accel;
126  if (dx <= bx) {
127  accel = emergency(dv, dx);
128  } else if (dx < sdx) {
129  if (dv > cldv) {
130  accel = approaching(dv, dx, bx);
131  } else if (dv > opdv) {
132  accel = following(vars->accelSign);
133  } else {
134  accel = fullspeed(v, vpref, dx, bx);
135  }
136  } else {
137  if (dv > sdv && dx < D_MAX) { //@note other versions have an disjunction instead of conjunction
138  accel = approaching(dv, dx, bx);
139  } else {
140  accel = fullspeed(v, vpref, dx, bx);
141  }
142  }
143  // since we have hard constrainst on accel we may as well use them here
144  accel = MAX2(MIN2(accel, myAccel), -myDecel);
145  const SUMOReal vNew = MAX2(SUMOReal(0), v + ACCEL2SPEED(accel)); // don't allow negative speeds
146  return vNew;
147 }
148 
149 
150 SUMOReal
152  SUMOReal bmax = 0.2 + 0.8 * myAccel * (7 - sqrt(v));
153  // if veh just drifted out of a 'following' process the acceleration is reduced
154  SUMOReal accel = dx <= 2 * bx ? MIN2(myMinAccel, bmax * (dx - bx) / bx) : bmax;
155  if (v > vpref) {
156  accel = - accel;
157  }
158  return accel;
159 }
160 
161 
162 SUMOReal
164  return myMinAccel * sign;
165 }
166 
167 
168 SUMOReal
170  // there is singularity in the formula. we do the sanity check outside
171  return 0.5 * dv * dv / (bx - dx); // + predAccel at t-reaction_time if this is value is above a treshold
172 }
173 
174 
175 SUMOReal
177  /* emergency according to A.Stebens
178  // wiedemann assumes that dx will always be larger than myAX (sumo may
179  // violate this assumption when crashing (-:
180  if (dx > myAX) {
181  SUMOReal accel = 0.5 * dv * dv / (myAX - dx); // + predAccel at t-reaction_time if this is value is above a treshold
182  // one would assume that in an emergency accel must be negative. However the
183  // wiedemann formula allows for accel = 0 whenever dv = 0
184  assert(accel <= 0);
185  return accel;
186  } else {
187  return = -myDecel;
188  }
189  */
190 
191  // emergency according to C.Werner
192  return -myDecel;
193 }
194 
195 
196 SUMOReal
198  if (predSpeed == 0 && gap < 0.01) {
199  return 0;
200  }
201  const SUMOReal tauDecel = myDecel * myHeadwayTime;
202  const SUMOReal speedReduction = ACCEL2SPEED(myDecel);
203  const int predSteps = int(predSpeed / speedReduction);
204  const SUMOReal leaderContrib = 2. * myDecel * (gap + SPEED2DIST(predSteps * predSpeed - speedReduction * predSteps * (predSteps + 1) / 2));
205  return (SUMOReal)(-tauDecel + sqrt(tauDecel * tauDecel + leaderContrib));
206 }
static SUMOReal randNorm(SUMOReal mean, SUMOReal variance, MTRand *rng=0)
Access to a random number from a normal distribution.
Definition: RandHelper.h:102
SUMOReal getSpeedAfterMaxDecel(SUMOReal v) const
Returns the velocity after maximum deceleration.
Definition: MSCFModel.h:285
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
const MSVehicleType * myType
The type to which this model definition belongs to.
Definition: MSCFModel.h:344
#define SPEED2DIST(x)
Definition: SUMOTime.h:55
MSCFModel_Wiedemann(const MSVehicleType *vtype, SUMOReal accel, SUMOReal decel, SUMOReal security, SUMOReal estimation)
Constructor.
#define ACCEL2SPEED(x)
Definition: SUMOTime.h:61
SUMOReal getMaxSpeed() const
Returns the maximum speed.
SUMOReal emergency(SUMOReal dv, SUMOReal dx) const
virtual SUMOReal maxNextSpeed(SUMOReal speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
Definition: MSCFModel.cpp:89
The car-following model abstraction.
Definition: MSCFModel.h:59
SUMOReal myAccel
The vehicle&#39;s maximum acceleration [m/s^2].
Definition: MSCFModel.h:347
SUMOReal moveHelper(MSVehicle *const veh, SUMOReal vPos) const
Applies interaction with stops and lane changing model influences.
SUMOReal getLength() const
Get vehicle&#39;s length [m].
T MAX2(T a, T b)
Definition: StdDefs.h:75
SUMOReal approaching(SUMOReal dv, SUMOReal dx, SUMOReal bx) const
const SUMOReal myAX
front-bumper to front-bumper distance
SUMOReal myHeadwayTime
The driver&#39;s desired time headway (aka reaction time tau) [s].
Definition: MSCFModel.h:353
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
The car-following model and parameter.
Definition: MSVehicleType.h:74
SUMOReal accelSign
state variable for remembering the drift direction
static const SUMOReal D_MAX
free-flow distance in m
SUMOReal followSpeed(const MSVehicle *const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const
Computes the vehicle&#39;s safe speed (no dawdling)
const SUMOReal myEstimation
The driver&#39;s estimation parameter // also &#39;ZF2&#39;.
SUMOReal stopSpeed(const MSVehicle *const veh, const SUMOReal speed, SUMOReal gap) const
Computes the vehicle&#39;s safe speed for approaching a non-moving obstacle (no dawdling) ...
const SUMOReal myMinAccel
The vehicle&#39;s minimum acceleration [m/s^2].
SUMOReal fullspeed(SUMOReal v, SUMOReal vpref, SUMOReal dx, SUMOReal bx) const
~MSCFModel_Wiedemann()
Destructor.
T MIN2(T a, T b)
Definition: StdDefs.h:69
SUMOReal following(SUMOReal sign) const
const SUMOReal myCX
perception threshold modifier
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle&#39;s car following model variables.
Definition: MSVehicle.h:636
virtual SUMOReal moveHelper(MSVehicle *const veh, SUMOReal vPos) const
Applies interaction with stops and lane changing model influences.
Definition: MSCFModel.cpp:59
const SUMOReal mySecurity
The driver&#39;s security parameter // also &#39;ZF1&#39;.
#define sign(a)
Definition: polyfonts.c:68
SUMOReal krauss_vsafe(SUMOReal gap, SUMOReal predSpeed) const
vsafe from krauss since Wiedemann is deficient at approaching
SUMOReal getSpeed() const
Returns the vehicle&#39;s current speed.
Definition: MSVehicle.h:348
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
#define SUMOReal
Definition: config.h:213
SUMOReal _v(const MSVehicle *veh, SUMOReal predSpeed, SUMOReal gap) const
SUMOReal interactionGap(const MSVehicle *const , SUMOReal vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
SUMOReal myDecel
The vehicle&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:350