Eclipse 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-2019 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 
130  double patchSpeedBeforeLC(const MSVehicle* veh, double vMin, double vMax) const;
131 
136  virtual MSCFModel* duplicate(const MSVehicleType* vtype) const;
137 
138 private:
144  virtual double _vsafe(const MSVehicle* const veh, double gap, double predSpeed) const;
145 
146 
151  virtual double dawdle(double speed, std::mt19937* rng) const;
152 
153  virtual void updateMyHeadway(const MSVehicle* const veh) const {
154  // this is the point were the preferred headway changes slowly:
156  double tTau = vars->myHeadway;
157  tTau = tTau + (myHeadwayTime - tTau) * myTmp2 + myTmp3 * tTau * RandHelper::rand(double(-1.0), double(1.0), veh->getRNG());
158  if (tTau < TS) { // this ensures the SK safety condition
159  tTau = TS;
160  }
161  vars->myHeadway = tTau;
162  }
163 
166  ret->gOld = 0.0;
167  ret->myHeadway = myHeadwayTime;
168  return ret;
169  }
170 
171 #include <map>
172 
173 private:
175  public:
176  double gOld, myHeadway;
177  std::map<int, double> ggOld;
178  };
179 
180 protected:
182  double myDawdle;
183 
185  double myTauDecel;
186 
189 
194 
195 };
196 
197 #endif /* MSCFModel_SmartSK_H */
198 
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:80
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle&#39;s car following model variables.
Definition: MSVehicle.h:911
virtual int getModelID() const
Returns the model&#39;s name.
std::mt19937 * getRNG() const
The car-following model abstraction.
Definition: MSCFModel.h:57
virtual double dawdle(double speed, std::mt19937 *rng) const
Applies driver imperfection (dawdling / sigma)
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:60
~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:44
double patchSpeedBeforeLC(const MSVehicle *veh, double vMin, double vMax) const
apply dawdling
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:619
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:628
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