SUMO - Simulation of Urban MObility
MSCFModel_SmartSK.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2012-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A smarter SK
20 /****************************************************************************/
21 #ifndef MSCFModel_SmartSK_h
22 #define MSCFModel_SmartSK_h
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "MSCFModel.h"
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
44 class MSCFModel_SmartSK : public MSCFModel {
45 public:
54  MSCFModel_SmartSK(const MSVehicleType* vtype, double accel,
55  double decel, double emergencyDecel, double apparentDecel,
56  double dawdle, double headwayTime,
57  double tmp1, double tmp2, double tmp3, double tmp4, double tmp5);
58 
59 
62 
63 
66 
72  double moveHelper(MSVehicle* const veh, double vPos) const;
73 
74 
83  virtual double followSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel) const;
84 
85 
93  virtual double stopSpeed(const MSVehicle* const veh, const double speed, double gap2pred) const;
94 
95 
100  virtual int getModelID() const {
101  return SUMO_TAG_CF_SMART_SK;
102  }
103 
104 
108  double getImperfection() const {
109  return myDawdle;
110  }
112 
113 
114 
117 
120  void setMaxDecel(double decel) {
121  myDecel = decel;
123  }
124 
125 
129  void setImperfection(double imperfection) {
130  myDawdle = imperfection;
131  }
132 
133 
137  void setHeadwayTime(double headwayTime) {
138  myHeadwayTime = headwayTime;
139  myTauDecel = myDecel * headwayTime;
140  }
142 
143 
148  virtual MSCFModel* duplicate(const MSVehicleType* vtype) const;
149 
150 private:
156  virtual double _vsafe(const MSVehicle* const veh, double gap, double predSpeed) const;
157 
158 
163  virtual double dawdle(double speed) const;
164 
165  virtual void updateMyHeadway(const MSVehicle* const veh) const {
166  // this is the point were the preferred headway changes slowly:
168  double tTau = vars->myHeadway;
169  tTau = tTau + (myHeadwayTime - tTau) * myTmp2 + myTmp3 * tTau * RandHelper::rand(double(-1.0), double(1.0));
170  if (tTau < TS) { // this ensures the SK safety condition
171  tTau = TS;
172  }
173  vars->myHeadway = tTau;
174  }
175 
178  ret->gOld = 0.0;
179  ret->myHeadway = myHeadwayTime;
180  return ret;
181  }
182 
183 #include <map>
184 
185 private:
187  public:
188  double gOld, myHeadway;
189  std::map<int, double> ggOld;
190  };
191 
192 protected:
194  double myDawdle;
195 
197  double myTauDecel;
198 
201 
206 
207 };
208 
209 #endif /* MSCFModel_SmartSK_H */
210 
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:891
virtual int getModelID() const
Returns the model&#39;s name.
The car-following model abstraction.
Definition: MSCFModel.h:59
virtual MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:64
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:51
The car-following model and parameter.
Definition: MSVehicleType.h:72
void setHeadwayTime(double headwayTime)
Sets a new value for desired headway [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.
double myDecel
The vehicle&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:537
virtual double dawdle(double speed) const
Applies driver imperfection (dawdling / sigma)
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 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:544
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