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-2017 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 // ===========================================================================
46 MSCFModel_Krauss::MSCFModel_Krauss(const MSVehicleType* vtype, double accel, double decel,
47  double emergencyDecel, double apparentDecel,
48  double dawdle, double headwayTime) :
49  MSCFModel_KraussOrig1(vtype, accel, decel, emergencyDecel, apparentDecel, dawdle, headwayTime) {
50 }
51 
52 
54 
55 
56 double
57 MSCFModel_Krauss::stopSpeed(const MSVehicle* const veh, const double speed, double gap) const {
58  // NOTE: This allows return of smaller values than minNextSpeed().
59  // Only relevant for the ballistic update: We give the argument headway=TS, to assure that
60  // the stopping position is approached with a uniform deceleration also for tau!=TS.
61  return MIN2(maximumSafeStopSpeed(gap, speed, false, TS), maxNextSpeed(speed, veh));
62 }
63 
64 
65 double
66 MSCFModel_Krauss::followSpeed(const MSVehicle* const veh, double speed, double gap, double predSpeed, double predMaxDecel) const {
67  const double vsafe = maximumSafeFollowSpeed(gap, speed, predSpeed, predMaxDecel);
68  const double vmin = minNextSpeed(speed);
69  const double vmax = maxNextSpeed(speed, veh);
71  return MIN2(vsafe, vmax);
72  } else {
73  // ballistic
74  // XXX: the euler variant can break as strong as it wishes immediately! The ballistic cannot, refs. #2575.
75  return MAX2(MIN2(vsafe, vmax), vmin);
76  }
77 }
78 
79 
80 double
81 MSCFModel_Krauss::dawdle(double speed) const {
83  // in case of the ballistic update, negative speeds indicate
84  // a desired stop before the completion of the next timestep.
85  // We do not allow dawdling to overwrite this indication
86  if (speed < 0) {
87  return speed;
88  }
89  }
90  // generate random number out of [0,1)
91  const double random = RandHelper::rand();
92  // Dawdle.
93  if (speed < myAccel) {
94  // we should not prevent vehicles from driving just due to dawdling
95  // if someone is starting, he should definitely start
96  // (but what about slow-to-start?)!!!
97  speed -= ACCEL2SPEED(myDawdle * speed * random);
98  } else {
99  speed -= ACCEL2SPEED(myDawdle * myAccel * random);
100  }
101  return MAX2(0., speed);
102 }
103 
104 
105 MSCFModel*
108 }
109 
110 
111 /****************************************************************************/
double maximumSafeFollowSpeed(double gap, double egoSpeed, double predSpeed, double predMaxDecel, bool onInsertion=false) const
Returns the maximum safe velocity for following the given leader.
Definition: MSCFModel.cpp:590
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
double myApparentDecel
The vehicle&#39;s deceleration as expected by surrounding traffic [m/s^2].
Definition: MSCFModel.h:473
#define ACCEL2SPEED(x)
Definition: SUMOTime.h:61
virtual double minNextSpeed(double 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:198
The car-following model abstraction.
Definition: MSCFModel.h:60
double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel) const
Computes the vehicle&#39;s safe speed (no dawdling) this uses the maximumSafeFollowSpeed.
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
Definition: MSCFModel.cpp:193
The original Krauss (1998) car-following model and parameter.
double myAccel
The vehicle&#39;s maximum acceleration [m/s^2].
Definition: MSCFModel.h:466
T MAX2(T a, T b)
Definition: StdDefs.h:70
~MSCFModel_Krauss()
Destructor.
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) this uses the m...
#define TS
Definition: SUMOTime.h:52
The car-following model and parameter.
Definition: MSVehicleType.h:74
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
static double rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
double myDawdle
The vehicle&#39;s dawdle-parameter. 0 for no dawdling, 1 for max.
T MIN2(T a, T b)
Definition: StdDefs.h:64
double maximumSafeStopSpeed(double gap, double currentSpeed, bool onInsertion=false, double headway=-1) const
Returns the maximum next velocity for stopping within gap.
Definition: MSCFModel.cpp:482
double myDecel
The vehicle&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:469
virtual double vsafe(double gap, double predSpeed, double predMaxDecel) const
Returns the "safe" velocity.
double myEmergencyDecel
The vehicle&#39;s maximum emergency deceleration [m/s^2].
Definition: MSCFModel.h:471
static bool gSemiImplicitEulerUpdate
Definition: MSGlobals.h:63
double myHeadwayTime
The driver&#39;s desired time headway (aka reaction time tau) [s].
Definition: MSCFModel.h:476
MSCFModel_Krauss(const MSVehicleType *vtype, double accel, double decel, double emergencyDecel, double apparentDecel, double dawdle, double headwayTime)
Constructor.
double dawdle(double speed) const
Applies driver imperfection (dawdling / sigma)