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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A smarter SK
18 /****************************************************************************/
19 #ifndef MSCFModel_SmartSK_h
20 #define MSCFModel_SmartSK_h
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include "MSCFModel.h"
29 
30 
31 // ===========================================================================
32 // class definitions
33 // ===========================================================================
38 class MSCFModel_SmartSK : public MSCFModel {
39 public:
43  MSCFModel_SmartSK(const MSVehicleType* vtype);
44 
45 
48 
49 
52 
58  double finalizeSpeed(MSVehicle* const veh, double vPos) const;
59 
60 
69  virtual double followSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle* const pred = 0) const;
70 
71 
79  virtual double stopSpeed(const MSVehicle* const veh, const double speed, double gap2pred) const;
80 
81 
86  virtual int getModelID() const {
87  return SUMO_TAG_CF_SMART_SK;
88  }
89 
90 
94  double getImperfection() const {
95  return myDawdle;
96  }
98 
99 
100 
103 
106  void setMaxDecel(double decel) {
107  myDecel = decel;
109  }
110 
111 
115  void setImperfection(double imperfection) {
116  myDawdle = imperfection;
117  }
118 
119 
123  void setHeadwayTime(double headwayTime) {
124  myHeadwayTime = headwayTime;
125  myTauDecel = myDecel * headwayTime;
126  }
128 
129 
134  virtual MSCFModel* duplicate(const MSVehicleType* vtype) const;
135 
136 private:
142  virtual double _vsafe(const MSVehicle* const veh, double gap, double predSpeed) const;
143 
144 
149  virtual double dawdle(double speed) const;
150 
151  virtual void updateMyHeadway(const MSVehicle* const veh) const {
152  // this is the point were the preferred headway changes slowly:
154  double tTau = vars->myHeadway;
155  tTau = tTau + (myHeadwayTime - tTau) * myTmp2 + myTmp3 * tTau * RandHelper::rand(double(-1.0), double(1.0));
156  if (tTau < TS) { // this ensures the SK safety condition
157  tTau = TS;
158  }
159  vars->myHeadway = tTau;
160  }
161 
164  ret->gOld = 0.0;
165  ret->myHeadway = myHeadwayTime;
166  return ret;
167  }
168 
169 #include <map>
170 
171 private:
173  public:
174  double gOld, myHeadway;
175  std::map<int, double> ggOld;
176  };
177 
178 protected:
180  double myDawdle;
181 
183  double myTauDecel;
184 
187 
192 
193 };
194 
195 #endif /* MSCFModel_SmartSK_H */
196 
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:79
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle&#39;s car following model variables.
Definition: MSVehicle.h:909
virtual int getModelID() const
Returns the model&#39;s name.
The car-following model abstraction.
Definition: MSCFModel.h:57
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:61
~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:45
The car-following model and parameter.
Definition: MSVehicleType.h:66
MSCFModel_SmartSK(const MSVehicleType *vtype)
Constructor.
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.
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const
Computes the vehicle&#39;s safe speed (no dawdling)
double myDecel
The vehicle&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:593
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:602
double myS2Sspeed
new variables needed in this model; myS2Sspeed is the speed below which the vehicle does not move whe...
double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences.
double myTmp1
temporary (testing) parameter