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 /****************************************************************************/
16 // A smarter SK
17 /****************************************************************************/
18 #ifndef MSCFModel_SmartSK_h
19 #define MSCFModel_SmartSK_h
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include "MSCFModel.h"
28 
29 
30 // ===========================================================================
31 // class definitions
32 // ===========================================================================
37 class MSCFModel_SmartSK : public MSCFModel {
38 public:
42  MSCFModel_SmartSK(const MSVehicleType* vtype);
43 
44 
47 
48 
51 
57  double finalizeSpeed(MSVehicle* const veh, double vPos) const;
58 
59 
68  virtual double followSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle* const pred = 0) const;
69 
70 
78  virtual double stopSpeed(const MSVehicle* const veh, const double speed, double gap2pred) const;
79 
80 
85  virtual int getModelID() const {
86  return SUMO_TAG_CF_SMART_SK;
87  }
88 
89 
93  double getImperfection() const {
94  return myDawdle;
95  }
97 
98 
99 
102 
105  void setMaxDecel(double decel) {
106  myDecel = decel;
108  }
109 
110 
114  void setImperfection(double imperfection) {
115  myDawdle = imperfection;
116  }
117 
118 
122  void setHeadwayTime(double headwayTime) {
123  myHeadwayTime = headwayTime;
124  myTauDecel = myDecel * headwayTime;
125  }
127 
129  double patchSpeedBeforeLC(const MSVehicle* veh, double vMin, double vMax) const;
130 
135  virtual MSCFModel* duplicate(const MSVehicleType* vtype) const;
136 
137 private:
143  virtual double _vsafe(const MSVehicle* const veh, double gap, double predSpeed) const;
144 
145 
150  virtual double dawdle(double speed, std::mt19937* rng) const;
151 
152  virtual void updateMyHeadway(const MSVehicle* const veh) const {
153  // this is the point were the preferred headway changes slowly:
155  double tTau = vars->myHeadway;
156  tTau = tTau + (myHeadwayTime - tTau) * myTmp2 + myTmp3 * tTau * RandHelper::rand(double(-1.0), double(1.0), veh->getRNG());
157  if (tTau < TS) { // this ensures the SK safety condition
158  tTau = TS;
159  }
160  vars->myHeadway = tTau;
161  }
162 
165  ret->gOld = 0.0;
166  ret->myHeadway = myHeadwayTime;
167  return ret;
168  }
169 
170 #include <map>
171 
172 private:
174  public:
175  double gOld, myHeadway;
176  std::map<int, double> ggOld;
177  };
178 
179 protected:
181  double myDawdle;
182 
184  double myTauDecel;
185 
188 
193 
194 };
195 
196 #endif /* MSCFModel_SmartSK_H */
197 
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:65
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:94
MSCFModel_SmartSK::finalizeSpeed
double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences.
Definition: MSCFModel_SmartSK.cpp:76
MSCFModel_SmartSK::SSKVehicleVariables::gOld
double gOld
Definition: MSCFModel_SmartSK.h:175
MSCFModel_SmartSK::duplicate
virtual MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
Definition: MSCFModel_SmartSK.cpp:166
MSCFModel_SmartSK::SSKVehicleVariables::myHeadway
double myHeadway
Definition: MSCFModel_SmartSK.h:175
MSCFModel_SmartSK::SSKVehicleVariables
Definition: MSCFModel_SmartSK.h:173
MSCFModel_SmartSK::setImperfection
void setImperfection(double imperfection)
Sets a new value for driver imperfection.
Definition: MSCFModel_SmartSK.h:114
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:192
MSCFModel_SmartSK::~MSCFModel_SmartSK
~MSCFModel_SmartSK()
Destructor.
Definition: MSCFModel_SmartSK.cpp:72
MSCFModel_SmartSK::myTmp1
double myTmp1
temporary (testing) parameter
Definition: MSCFModel_SmartSK.h:187
MSCFModel_SmartSK::getModelID
virtual int getModelID() const
Returns the model's name.
Definition: MSCFModel_SmartSK.h:85
MSVehicle::getCarFollowVariables
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle's car following model variables.
Definition: MSVehicle.h:910
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:53
MSCFModel_SmartSK::getImperfection
double getImperfection() const
Get the driver's imperfection.
Definition: MSCFModel_SmartSK.h:93
MSCFModel_SmartSK::myTmp4
double myTmp4
Definition: MSCFModel_SmartSK.h:187
TS
#define TS
Definition: SUMOTime.h:43
MSCFModel_SmartSK::dawdle
virtual double dawdle(double speed, std::mt19937 *rng) const
Applies driver imperfection (dawdling / sigma)
Definition: MSCFModel_SmartSK.cpp:140
MSCFModel::myHeadwayTime
double myHeadwayTime
The driver's desired time headway (aka reaction time tau) [s].
Definition: MSCFModel.h:629
MSCFModel_SmartSK::myDawdle
double myDawdle
The vehicle's dawdle-parameter. 0 for no dawdling, 1 for max.
Definition: MSCFModel_SmartSK.h:181
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:119
MSCFModel_SmartSK::_vsafe
virtual double _vsafe(const MSVehicle *const veh, double gap, double predSpeed) const
Returns the "safe" velocity.
Definition: MSCFModel_SmartSK.cpp:146
MSCFModel_SmartSK::patchSpeedBeforeLC
double patchSpeedBeforeLC(const MSVehicle *veh, double vMin, double vMax) const
apply dawdling
Definition: MSCFModel_SmartSK.cpp:135
MSCFModel_SmartSK::setMaxDecel
void setMaxDecel(double decel)
Sets a new value for maximum deceleration [m/s^2].
Definition: MSCFModel_SmartSK.h:105
MSCFModel_SmartSK::myTauDecel
double myTauDecel
The precomputed value for myDecel*myTau.
Definition: MSCFModel_SmartSK.h:184
MSCFModel::VehicleVariables
Definition: MSCFModel.h:60
MSCFModel_SmartSK::setHeadwayTime
void setHeadwayTime(double headwayTime)
Sets a new value for desired headway [s].
Definition: MSCFModel_SmartSK.h:122
MSCFModel_SmartSK::myTmp5
double myTmp5
Definition: MSCFModel_SmartSK.h:187
MSCFModel_SmartSK::updateMyHeadway
virtual void updateMyHeadway(const MSVehicle *const veh) const
Definition: MSCFModel_SmartSK.h:152
MSCFModel::myDecel
double myDecel
The vehicle's maximum deceleration [m/s^2].
Definition: MSCFModel.h:620
MSCFModel.h
MSCFModel_SmartSK
The original Krauss (1998) car-following model and parameter.
Definition: MSCFModel_SmartSK.h:37
MSCFModel_SmartSK::myTmp2
double myTmp2
Definition: MSCFModel_SmartSK.h:187
MSCFModel
The car-following model abstraction.
Definition: MSCFModel.h:56
config.h
MSCFModel_SmartSK::MSCFModel_SmartSK
MSCFModel_SmartSK(const MSVehicleType *vtype)
Constructor.
Definition: MSCFModel_SmartSK.cpp:38
SUMO_TAG_CF_SMART_SK
@ SUMO_TAG_CF_SMART_SK
Definition: SUMOXMLDefinitions.h:279
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:163
MSCFModel_SmartSK::myTmp3
double myTmp3
Definition: MSCFModel_SmartSK.h:187
MSCFModel_SmartSK::SSKVehicleVariables::ggOld
std::map< int, double > ggOld
Definition: MSCFModel_SmartSK.h:176
SUMOXMLDefinitions.h
MSCFModel_SmartSK::maxDeltaGap
double maxDeltaGap
Definition: MSCFModel_SmartSK.h:192
MSBaseVehicle::getRNG
std::mt19937 * getRNG() const
Definition: MSBaseVehicle.cpp:758
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79