SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSCFModel_SmartSK.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // A smarter SK
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef MSCFModel_SmartSK_h
21 #define MSCFModel_SmartSK_h
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include "MSCFModel.h"
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
43 class MSCFModel_SmartSK : public MSCFModel {
44 public:
51  MSCFModel_SmartSK(const MSVehicleType* vtype, SUMOReal accel, SUMOReal decel, SUMOReal dawdle, SUMOReal headwayTime,
52  SUMOReal tmp1, SUMOReal tmp2, SUMOReal tmp3, SUMOReal tmp4, SUMOReal tmp5);
53 
54 
57 
58 
61 
67  SUMOReal moveHelper(MSVehicle* const veh, SUMOReal vPos) const;
68 
69 
78  virtual SUMOReal followSpeed(const MSVehicle* const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const;
79 
80 
88  virtual SUMOReal stopSpeed(const MSVehicle* const veh, const SUMOReal speed, SUMOReal gap2pred) const;
89 
90 
95  virtual int getModelID() const {
96  return SUMO_TAG_CF_SMART_SK;
97  }
98 
99 
104  return myDawdle;
105  }
107 
108 
109 
112 
115  void setMaxDecel(SUMOReal decel) {
116  myDecel = decel;
118  }
119 
120 
124  void setImperfection(SUMOReal imperfection) {
125  myDawdle = imperfection;
126  }
127 
128 
132  void setHeadwayTime(SUMOReal headwayTime) {
133  myHeadwayTime = headwayTime;
134  myTauDecel = myDecel * headwayTime;
135  }
137 
138 
143  virtual MSCFModel* duplicate(const MSVehicleType* vtype) const;
144 
145 private:
151  virtual SUMOReal _vsafe(const MSVehicle* const veh, SUMOReal gap, SUMOReal predSpeed) const;
152 
153 
158  virtual SUMOReal dawdle(SUMOReal speed) const;
159 
160  virtual void updateMyHeadway(const MSVehicle* const veh) const {
161  // this is the point were the preferred headway changes slowly:
163  SUMOReal tTau = vars->myHeadway;
164  tTau = tTau + (myHeadwayTime - tTau) * myTmp2 + myTmp3 * tTau * RandHelper::rand(SUMOReal(-1.0), SUMOReal(1.0));
165  if (tTau < TS) { // this ensures the SK safety condition
166  tTau = TS;
167  }
168  vars->myHeadway = tTau;
169  }
170 
173  ret->gOld = 0.0;
174  ret->myHeadway = myHeadwayTime;
175  return ret;
176  }
177 
178 #include <map>
179 
180 private:
182  public:
184  std::map<int, SUMOReal> ggOld;
185  };
186 
187 protected:
190 
193 
196 
201 
202 };
203 
204 #endif /* MSCFModel_SmartSK_H */
205 
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&#39;s safe speed (no dawdling)
static SUMOReal rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:61
virtual SUMOReal stopSpeed(const MSVehicle *const veh, const SUMOReal speed, SUMOReal gap2pred) const
Computes the vehicle&#39;s safe speed for approaching a non-moving obstacle (no dawdling) ...
virtual int getModelID() const
Returns the model&#39;s name.
~MSCFModel_SmartSK()
Destructor.
SUMOReal myHeadwayTime
The driver&#39;s desired time headway (aka reaction time tau) [s].
Definition: MSCFModel.h:291
#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&#39;s car following model variables.
Definition: MSVehicle.h:522
SUMOReal getImperfection() const
Get the driver&#39;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:221
SUMOReal myTauDecel
The precomputed value for myDecel*myTau.
SUMOReal myDecel
The vehicle&#39;s maximum deceleration [m/s^2].
Definition: MSCFModel.h:288
virtual SUMOReal _vsafe(const MSVehicle *const veh, SUMOReal gap, SUMOReal predSpeed) const
Returns the &quot;safe&quot; velocity.
SUMOReal myDawdle
The vehicle&#39;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].