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 
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:66
MSCFModel_SmartSK::followSpeed
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const
Computes the vehicle's safe speed (no dawdling)
Definition: MSCFModel_SmartSK.cpp:95
MSCFModel_SmartSK::finalizeSpeed
double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences.
Definition: MSCFModel_SmartSK.cpp:77
MSCFModel_SmartSK::SSKVehicleVariables::gOld
double gOld
Definition: MSCFModel_SmartSK.h:176
MSCFModel_SmartSK::duplicate
virtual MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
Definition: MSCFModel_SmartSK.cpp:167
MSCFModel_SmartSK::SSKVehicleVariables::myHeadway
double myHeadway
Definition: MSCFModel_SmartSK.h:176
MSCFModel_SmartSK::SSKVehicleVariables
Definition: MSCFModel_SmartSK.h:174
MSCFModel_SmartSK::setImperfection
void setImperfection(double imperfection)
Sets a new value for driver imperfection.
Definition: MSCFModel_SmartSK.h:115
MSCFModel_SmartSK::myS2Sspeed
double myS2Sspeed
new variables needed in this model; myS2Sspeed is the speed below which the vehicle does not move whe...
Definition: MSCFModel_SmartSK.h:193
MSCFModel_SmartSK::~MSCFModel_SmartSK
~MSCFModel_SmartSK()
Destructor.
Definition: MSCFModel_SmartSK.cpp:73
MSCFModel_SmartSK::myTmp1
double myTmp1
temporary (testing) parameter
Definition: MSCFModel_SmartSK.h:188
MSCFModel_SmartSK::getModelID
virtual int getModelID() const
Returns the model's name.
Definition: MSCFModel_SmartSK.h:86
MSVehicle::getCarFollowVariables
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle's car following model variables.
Definition: MSVehicle.h:911
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:60
MSCFModel_SmartSK::getImperfection
double getImperfection() const
Get the driver's imperfection.
Definition: MSCFModel_SmartSK.h:94
MSCFModel_SmartSK::myTmp4
double myTmp4
Definition: MSCFModel_SmartSK.h:188
TS
#define TS
Definition: SUMOTime.h:44
MSCFModel_SmartSK::dawdle
virtual double dawdle(double speed, std::mt19937 *rng) const
Applies driver imperfection (dawdling / sigma)
Definition: MSCFModel_SmartSK.cpp:141
MSCFModel::myHeadwayTime
double myHeadwayTime
The driver's desired time headway (aka reaction time tau) [s].
Definition: MSCFModel.h:628
MSCFModel_SmartSK::myDawdle
double myDawdle
The vehicle's dawdle-parameter. 0 for no dawdling, 1 for max.
Definition: MSCFModel_SmartSK.h:182
MSCFModel_SmartSK::stopSpeed
virtual double stopSpeed(const MSVehicle *const veh, const double speed, double gap2pred) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
Definition: MSCFModel_SmartSK.cpp:120
MSCFModel_SmartSK::_vsafe
virtual double _vsafe(const MSVehicle *const veh, double gap, double predSpeed) const
Returns the "safe" velocity.
Definition: MSCFModel_SmartSK.cpp:147
MSCFModel_SmartSK::patchSpeedBeforeLC
double patchSpeedBeforeLC(const MSVehicle *veh, double vMin, double vMax) const
apply dawdling
Definition: MSCFModel_SmartSK.cpp:136
MSCFModel_SmartSK::setMaxDecel
void setMaxDecel(double decel)
Sets a new value for maximum deceleration [m/s^2].
Definition: MSCFModel_SmartSK.h:106
MSCFModel_SmartSK::myTauDecel
double myTauDecel
The precomputed value for myDecel*myTau.
Definition: MSCFModel_SmartSK.h:185
MSCFModel::VehicleVariables
Definition: MSCFModel.h:61
MSCFModel_SmartSK::setHeadwayTime
void setHeadwayTime(double headwayTime)
Sets a new value for desired headway [s].
Definition: MSCFModel_SmartSK.h:123
MSCFModel_SmartSK::myTmp5
double myTmp5
Definition: MSCFModel_SmartSK.h:188
MSCFModel_SmartSK::updateMyHeadway
virtual void updateMyHeadway(const MSVehicle *const veh) const
Definition: MSCFModel_SmartSK.h:153
MSCFModel::myDecel
double myDecel
The vehicle's maximum deceleration [m/s^2].
Definition: MSCFModel.h:619
MSCFModel.h
MSCFModel_SmartSK
The original Krauss (1998) car-following model and parameter.
Definition: MSCFModel_SmartSK.h:38
MSCFModel_SmartSK::myTmp2
double myTmp2
Definition: MSCFModel_SmartSK.h:188
MSCFModel
The car-following model abstraction.
Definition: MSCFModel.h:57
config.h
MSCFModel_SmartSK::MSCFModel_SmartSK
MSCFModel_SmartSK(const MSVehicleType *vtype)
Constructor.
Definition: MSCFModel_SmartSK.cpp:39
SUMO_TAG_CF_SMART_SK
Definition: SUMOXMLDefinitions.h:280
MSCFModel_SmartSK::createVehicleVariables
virtual MSCFModel::VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting.
Definition: MSCFModel_SmartSK.h:164
MSCFModel_SmartSK::myTmp3
double myTmp3
Definition: MSCFModel_SmartSK.h:188
MSCFModel_SmartSK::SSKVehicleVariables::ggOld
std::map< int, double > ggOld
Definition: MSCFModel_SmartSK.h:177
SUMOXMLDefinitions.h
MSCFModel_SmartSK::maxDeltaGap
double maxDeltaGap
Definition: MSCFModel_SmartSK.h:193
MSBaseVehicle::getRNG
std::mt19937 * getRNG() const
Definition: MSBaseVehicle.cpp:712
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80