SUMO - Simulation of Urban MObility
MSCFModel_SmartSK.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A smarter SK
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2012-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 #ifndef MSCFModel_SmartSK_h
23 #define MSCFModel_SmartSK_h
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include "MSCFModel.h"
36 
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
45 class MSCFModel_SmartSK : public MSCFModel {
46 public:
55  MSCFModel_SmartSK(const MSVehicleType* vtype, double accel,
56  double decel, double emergencyDecel, double apparentDecel,
57  double dawdle, double headwayTime,
58  double tmp1, double tmp2, double tmp3, double tmp4, double tmp5);
59 
60 
63 
64 
67 
73  double moveHelper(MSVehicle* const veh, double vPos) const;
74 
75 
84  virtual double followSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel) const;
85 
86 
94  virtual double stopSpeed(const MSVehicle* const veh, const double speed, double gap2pred) const;
95 
96 
101  virtual int getModelID() const {
102  return SUMO_TAG_CF_SMART_SK;
103  }
104 
105 
109  double getImperfection() const {
110  return myDawdle;
111  }
113 
114 
115 
118 
121  void setMaxDecel(double decel) {
122  myDecel = decel;
124  }
125 
126 
130  void setImperfection(double imperfection) {
131  myDawdle = imperfection;
132  }
133 
134 
138  void setHeadwayTime(double headwayTime) {
139  myHeadwayTime = headwayTime;
140  myTauDecel = myDecel * headwayTime;
141  }
143 
144 
149  virtual MSCFModel* duplicate(const MSVehicleType* vtype) const;
150 
151 private:
157  virtual double _vsafe(const MSVehicle* const veh, double gap, double predSpeed) const;
158 
159 
164  virtual double dawdle(double speed) const;
165 
166  virtual void updateMyHeadway(const MSVehicle* const veh) const {
167  // this is the point were the preferred headway changes slowly:
169  double tTau = vars->myHeadway;
170  tTau = tTau + (myHeadwayTime - tTau) * myTmp2 + myTmp3 * tTau * RandHelper::rand(double(-1.0), double(1.0));
171  if (tTau < TS) { // this ensures the SK safety condition
172  tTau = TS;
173  }
174  vars->myHeadway = tTau;
175  }
176 
179  ret->gOld = 0.0;
180  ret->myHeadway = myHeadwayTime;
181  return ret;
182  }
183 
184 #include <map>
185 
186 private:
188  public:
189  double gOld, myHeadway;
190  std::map<int, double> ggOld;
191  };
192 
193 protected:
195  double myDawdle;
196 
198  double myTauDecel;
199 
202 
207 
208 };
209 
210 #endif /* MSCFModel_SmartSK_H */
211 
double getImperfection() const
Get the driver&#39;s imperfection.
void setImperfection(double imperfection)
Sets a new value for driver imperfection.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
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
virtual int getModelID() const
Returns the model&#39;s name.
~MSCFModel_SmartSK()
Destructor.
void setMaxDecel(double decel)
Sets a new value for maximum deceleration [m/s^2].
#define TS
Definition: SUMOTime.h:52
virtual void updateMyHeadway(const MSVehicle *const veh) const
The car-following model and parameter.
Definition: MSVehicleType.h:73
void setHeadwayTime(double headwayTime)
Sets a new value for desired headway [s].
The original Krauss (1998) car-following model and parameter.
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel) const
Computes the vehicle&#39;s safe speed (no dawdling)
virtual 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
double moveHelper(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences.
virtual double _vsafe(const MSVehicle *const veh, double gap, double predSpeed) const
Returns the "safe" velocity.
virtual double dawdle(double speed) const
Applies driver imperfection (dawdling / sigma)
virtual MSCFModel::VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting...
MSCFModel_SmartSK(const MSVehicleType *vtype, double accel, double decel, double emergencyDecel, double apparentDecel, double dawdle, double headwayTime, double tmp1, double tmp2, double tmp3, double tmp4, double tmp5)
Constructor.
double myDawdle
The vehicle&#39;s dawdle-parameter. 0 for no dawdling, 1 for max.
double myTauDecel
The precomputed value for myDecel*myTau.
double myHeadwayTime
The driver&#39;s desired time headway (aka reaction time tau) [s].
Definition: MSCFModel.h:534
double myS2Sspeed
new variables needed in this model; myS2Sspeed is the speed below which the vehicle does not move whe...
double myTmp1
temporary (testing) parameter
virtual MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.