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:
54  MSCFModel_SmartSK(const MSVehicleType* vtype, double accel, double decel, double emergencyDecel, double dawdle, double headwayTime,
55  double tmp1, double tmp2, double tmp3, double tmp4, double tmp5);
56 
57 
60 
61 
64 
70  double moveHelper(MSVehicle* const veh, double vPos) const;
71 
72 
81  virtual double followSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel) const;
82 
83 
91  virtual double stopSpeed(const MSVehicle* const veh, const double speed, double gap2pred) const;
92 
93 
98  virtual int getModelID() const {
99  return SUMO_TAG_CF_SMART_SK;
100  }
101 
102 
106  double getImperfection() const {
107  return myDawdle;
108  }
110 
111 
112 
115 
118  void setMaxDecel(double decel) {
119  myDecel = decel;
121  }
122 
123 
127  void setImperfection(double imperfection) {
128  myDawdle = imperfection;
129  }
130 
131 
135  void setHeadwayTime(double headwayTime) {
136  myHeadwayTime = headwayTime;
137  myTauDecel = myDecel * headwayTime;
138  }
140 
141 
146  virtual MSCFModel* duplicate(const MSVehicleType* vtype) const;
147 
148 private:
154  virtual double _vsafe(const MSVehicle* const veh, double gap, double predSpeed) const;
155 
156 
161  virtual double dawdle(double speed) const;
162 
163  virtual void updateMyHeadway(const MSVehicle* const veh) const {
164  // this is the point were the preferred headway changes slowly:
166  double tTau = vars->myHeadway;
167  tTau = tTau + (myHeadwayTime - tTau) * myTmp2 + myTmp3 * tTau * RandHelper::rand(double(-1.0), double(1.0));
168  if (tTau < TS) { // this ensures the SK safety condition
169  tTau = TS;
170  }
171  vars->myHeadway = tTau;
172  }
173 
176  ret->gOld = 0.0;
177  ret->myHeadway = myHeadwayTime;
178  return ret;
179  }
180 
181 #include <map>
182 
183 private:
185  public:
186  double gOld, myHeadway;
187  std::map<int, double> ggOld;
188  };
189 
190 protected:
192  double myDawdle;
193 
195  double myTauDecel;
196 
199 
204 
205 };
206 
207 #endif /* MSCFModel_SmartSK_H */
208 
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) ...
void setImperfection(double imperfection)
Sets a new value for driver imperfection.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle&#39;s car following model variables.
Definition: MSVehicle.h:805
virtual int getModelID() const
Returns the model&#39;s name.
The car-following model abstraction.
Definition: MSCFModel.h:60
virtual MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
double moveHelper(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences.
~MSCFModel_SmartSK()
Destructor.
virtual double _vsafe(const MSVehicle *const veh, double gap, double predSpeed) const
Returns the "safe" velocity.
void setMaxDecel(double decel)
Sets a new value for maximum deceleration [m/s^2].
#define TS
Definition: SUMOTime.h:52
The car-following model and parameter.
Definition: MSVehicleType.h:74
void setHeadwayTime(double headwayTime)
Sets a new value for driver reaction time [s].
virtual MSCFModel::VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting...
The original Krauss (1998) car-following model and parameter.
static double rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
double myDecel
The vehicle&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:469
MSCFModel_SmartSK(const MSVehicleType *vtype, double accel, double decel, double emergencyDecel, double dawdle, double headwayTime, double tmp1, double tmp2, double tmp3, double tmp4, double tmp5)
Constructor.
virtual double dawdle(double speed) const
Applies driver imperfection (dawdling / sigma)
double getImperfection() const
Get the driver&#39;s imperfection.
double myDawdle
The vehicle&#39;s dawdle-parameter. 0 for no dawdling, 1 for max.
double myTauDecel
The precomputed value for myDecel*myTau.
virtual void updateMyHeadway(const MSVehicle *const veh) const
double myHeadwayTime
The driver&#39;s desired time headway (aka reaction time tau) [s].
Definition: MSCFModel.h:476
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)
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