SUMO - Simulation of Urban MObility
MSCFModel_SmartSK.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A smarter SK
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2012-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef MSCFModel_SmartSK_h
23 #define MSCFModel_SmartSK_h
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include "MSCFModel.h"
36 
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
45 class MSCFModel_SmartSK : public MSCFModel {
46 public:
53  MSCFModel_SmartSK(const MSVehicleType* vtype, SUMOReal accel, SUMOReal decel, SUMOReal dawdle, SUMOReal headwayTime,
54  SUMOReal tmp1, SUMOReal tmp2, SUMOReal tmp3, SUMOReal tmp4, SUMOReal tmp5);
55 
56 
59 
60 
63 
69  SUMOReal moveHelper(MSVehicle* const veh, SUMOReal vPos) const;
70 
71 
80  virtual SUMOReal followSpeed(const MSVehicle* const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const;
81 
82 
90  virtual SUMOReal stopSpeed(const MSVehicle* const veh, const SUMOReal speed, SUMOReal gap2pred) const;
91 
92 
97  virtual int getModelID() const {
98  return SUMO_TAG_CF_SMART_SK;
99  }
100 
101 
106  return myDawdle;
107  }
109 
110 
111 
114 
117  void setMaxDecel(SUMOReal decel) {
118  myDecel = decel;
120  }
121 
122 
126  void setImperfection(SUMOReal imperfection) {
127  myDawdle = imperfection;
128  }
129 
130 
134  void setHeadwayTime(SUMOReal headwayTime) {
135  myHeadwayTime = headwayTime;
136  myTauDecel = myDecel * headwayTime;
137  }
139 
140 
145  virtual MSCFModel* duplicate(const MSVehicleType* vtype) const;
146 
147 private:
153  virtual SUMOReal _vsafe(const MSVehicle* const veh, SUMOReal gap, SUMOReal predSpeed) const;
154 
155 
160  virtual SUMOReal dawdle(SUMOReal speed) const;
161 
162  virtual void updateMyHeadway(const MSVehicle* const veh) const {
163  // this is the point were the preferred headway changes slowly:
165  SUMOReal tTau = vars->myHeadway;
166  tTau = tTau + (myHeadwayTime - tTau) * myTmp2 + myTmp3 * tTau * RandHelper::rand(SUMOReal(-1.0), SUMOReal(1.0));
167  if (tTau < TS) { // this ensures the SK safety condition
168  tTau = TS;
169  }
170  vars->myHeadway = tTau;
171  }
172 
175  ret->gOld = 0.0;
176  ret->myHeadway = myHeadwayTime;
177  return ret;
178  }
179 
180 #include <map>
181 
182 private:
184  public:
186  std::map<int, SUMOReal> ggOld;
187  };
188 
189 protected:
192 
195 
198 
203 
204 };
205 
206 #endif /* MSCFModel_SmartSK_H */
207 
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
The car-following model abstraction.
Definition: MSCFModel.h:58
virtual SUMOReal followSpeed(const MSVehicle *const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const
Computes the vehicle's safe speed (no dawdling)
static SUMOReal rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
virtual SUMOReal stopSpeed(const MSVehicle *const veh, const SUMOReal speed, SUMOReal gap2pred) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling) ...
virtual int getModelID() const
Returns the model's name.
~MSCFModel_SmartSK()
Destructor.
SUMOReal myHeadwayTime
The driver's desired time headway (aka reaction time tau) [s].
Definition: MSCFModel.h:298
#define TS
Definition: SUMOTime.h:52
virtual void updateMyHeadway(const MSVehicle *const veh) const
virtual SUMOReal dawdle(SUMOReal speed) const
Applies driver imperfection (dawdling / sigma)
The car-following model and parameter.
Definition: MSVehicleType.h:74
void setMaxDecel(SUMOReal decel)
Sets a new value for maximum deceleration [m/s^2].
MSCFModel_SmartSK(const MSVehicleType *vtype, SUMOReal accel, SUMOReal decel, SUMOReal dawdle, SUMOReal headwayTime, SUMOReal tmp1, SUMOReal tmp2, SUMOReal tmp3, SUMOReal tmp4, SUMOReal tmp5)
Constructor.
SUMOReal myTmp1
temporary (testing) parameter
The original Krauss (1998) car-following model and parameter.
SUMOReal myS2Sspeed
new variables needed in this model; myS2Sspeed is the speed below which the vehicle does not move whe...
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle's car following model variables.
Definition: MSVehicle.h:547
SUMOReal getImperfection() const
Get the driver's imperfection.
SUMOReal moveHelper(MSVehicle *const veh, SUMOReal vPos) const
Applies interaction with stops and lane changing model influences.
virtual MSCFModel::VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting...
void setImperfection(SUMOReal imperfection)
Sets a new value for driver imperfection.
#define SUMOReal
Definition: config.h:215
SUMOReal myTauDecel
The precomputed value for myDecel*myTau.
SUMOReal myDecel
The vehicle's maximum deceleration [m/s^2].
Definition: MSCFModel.h:295
virtual SUMOReal _vsafe(const MSVehicle *const veh, SUMOReal gap, SUMOReal predSpeed) const
Returns the "safe" velocity.
SUMOReal myDawdle
The vehicle's dawdle-parameter. 0 for no dawdling, 1 for max.
virtual MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
void setHeadwayTime(SUMOReal headwayTime)
Sets a new value for driver reaction time [s].