SUMO - Simulation of Urban MObility
MSCFModel_Krauss.cpp
Go to the documentation of this file.
1 /****************************************************************************/
11 // Krauss car-following model, with acceleration decrease and faster start
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
14 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <microsim/MSVehicle.h>
36 #include <microsim/MSLane.h>
37 #include <microsim/MSGlobals.h>
38 #include "MSCFModel_Krauss.h"
41 
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
47  SUMOReal dawdle, SUMOReal headwayTime)
48  : MSCFModel_KraussOrig1(vtype, accel, decel, dawdle, headwayTime) {
49 }
50 
51 
53 
54 
56 MSCFModel_Krauss::stopSpeed(const MSVehicle* const veh, const SUMOReal speed, SUMOReal gap) const {
57  // NOTE: This allows return of smaller values than minNextSpeed().
58  // Only relevant for the ballistic update: We give the argument headway=TS, to assure that
59  // the stopping position is approached with a uniform deceleration also for tau!=TS.
60  return MIN2(maximumSafeStopSpeed(gap, speed, false, TS), maxNextSpeed(speed, veh));
61 }
62 
63 
65 MSCFModel_Krauss::followSpeed(const MSVehicle* const veh, SUMOReal speed, SUMOReal gap, SUMOReal predSpeed, SUMOReal predMaxDecel) const {
66  const SUMOReal vsafe = maximumSafeFollowSpeed(gap, speed, predSpeed, predMaxDecel);
67  const SUMOReal vmin = minNextSpeed(speed);
68  const SUMOReal vmax = maxNextSpeed(speed, veh);
70  return MIN2(vsafe, vmax);
71  } else {
72  // ballistic
73  // XXX: the euler variant can break as strong as it wishes immediately! The ballistic cannot, refs. #2575.
74  return MAX2(MIN2(vsafe, vmax), vmin);
75  }
76 }
77 
78 
82  // in case of the ballistic update, negative speeds indicate
83  // a desired stop before the completion of the next timestep.
84  // We do not allow dawdling to overwrite this indication
85  if (speed < 0) {
86  return speed;
87  }
88  }
89  // generate random number out of [0,1)
90  const SUMOReal random = RandHelper::rand();
91  // Dawdle.
92  if (speed < myAccel) {
93  // we should not prevent vehicles from driving just due to dawdling
94  // if someone is starting, he should definitely start
95  // (but what about slow-to-start?)!!!
96  speed -= ACCEL2SPEED(myDawdle * speed * random);
97  } else {
98  speed -= ACCEL2SPEED(myDawdle * myAccel * random);
99  }
100  return MAX2(SUMOReal(0), speed);
101 }
102 
103 
104 MSCFModel*
106  return new MSCFModel_Krauss(vtype, myAccel, myDecel, myDawdle, myHeadwayTime);
107 }
108 
109 
110 /****************************************************************************/
MSCFModel_Krauss(const MSVehicleType *vtype, SUMOReal accel, SUMOReal decel, SUMOReal dawdle, SUMOReal headwayTime)
Constructor.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:82
#define ACCEL2SPEED(x)
Definition: SUMOTime.h:61
The car-following model abstraction.
Definition: MSCFModel.h:60
SUMOReal myAccel
The vehicle&#39;s maximum acceleration [m/s^2].
Definition: MSCFModel.h:466
static SUMOReal rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
The original Krauss (1998) car-following model and parameter.
T MAX2(T a, T b)
Definition: StdDefs.h:75
~MSCFModel_Krauss()
Destructor.
SUMOReal myHeadwayTime
The driver&#39;s desired time headway (aka reaction time tau) [s].
Definition: MSCFModel.h:472
#define TS
Definition: SUMOTime.h:52
SUMOReal stopSpeed(const MSVehicle *const veh, const SUMOReal speed, SUMOReal gap2pred) const
Computes the vehicle&#39;s safe speed for approaching a non-moving obstacle (no dawdling) this uses the m...
SUMOReal minNextSpeed(SUMOReal speed, const MSVehicle *const veh=0) const
Returns the minimum speed given the current speed (depends on the numerical update scheme and its ste...
Definition: MSCFModel.cpp:195
The car-following model and parameter.
Definition: MSVehicleType.h:74
SUMOReal myDawdle
The vehicle&#39;s dawdle-parameter. 0 for no dawdling, 1 for max.
virtual SUMOReal vsafe(SUMOReal gap, SUMOReal predSpeed, SUMOReal predMaxDecel) const
Returns the "safe" velocity.
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
T MIN2(T a, T b)
Definition: StdDefs.h:69
SUMOReal maximumSafeStopSpeed(SUMOReal gap, SUMOReal currentSpeed, bool onInsertion=false, SUMOReal headway=-1) const
Returns the maximum next velocity for stopping within gap.
Definition: MSCFModel.cpp:477
SUMOReal maximumSafeFollowSpeed(SUMOReal gap, SUMOReal egoSpeed, SUMOReal predSpeed, SUMOReal predMaxDecel, bool onInsertion=false) const
Returns the maximum safe velocity for following the given leader.
Definition: MSCFModel.cpp:585
SUMOReal followSpeed(const MSVehicle *const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const
Computes the vehicle&#39;s safe speed (no dawdling) this uses the maximumSafeFollowSpeed.
SUMOReal dawdle(SUMOReal speed) const
Applies driver imperfection (dawdling / sigma)
#define SUMOReal
Definition: config.h:213
static bool gSemiImplicitEulerUpdate
Definition: MSGlobals.h:63
virtual SUMOReal maxNextSpeed(SUMOReal speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
Definition: MSCFModel.cpp:190
SUMOReal myDecel
The vehicle&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:469