SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSCFModel.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // The car-following model abstraction
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSCFModel_h
24 #define MSCFModel_h
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <utils/common/StdDefs.h>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class MSVehicleType;
44 class MSVehicle;
45 class MSLane;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
58 class MSCFModel {
59 public:
60 
62  };
63 
67  MSCFModel(const MSVehicleType* vtype, SUMOReal accel, SUMOReal decel, SUMOReal headwayTime);
68 
69 
71  virtual ~MSCFModel();
72 
73 
76 
82  virtual SUMOReal moveHelper(MSVehicle* const veh, SUMOReal vPos) const;
83 
84 
95  virtual SUMOReal freeSpeed(const MSVehicle* const veh, SUMOReal speed, SUMOReal seen, SUMOReal maxSpeed) const;
96 
97 
107  virtual SUMOReal followSpeed(const MSVehicle* const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const = 0;
108 
109 
118  virtual SUMOReal stopSpeed(const MSVehicle* const veh, const SUMOReal speed, SUMOReal gap2pred) const = 0;
119 
120 
129  virtual SUMOReal interactionGap(const MSVehicle* const veh, SUMOReal vL) const;
130 
131 
135  virtual int getModelID() const = 0;
136 
137 
142  virtual MSCFModel* duplicate(const MSVehicleType* vtype) const = 0;
143 
144 
149  return 0;
150  }
152 
153 
157  inline SUMOReal getMaxAccel() const {
158  return myAccel;
159  }
160 
161 
165  inline SUMOReal getMaxDecel() const {
166  return myDecel;
167  }
168 
169 
172 
176  virtual SUMOReal getImperfection() const {
177  return -1;
178  }
179 
180 
184  virtual SUMOReal getHeadwayTime() const {
185  return myHeadwayTime;
186  }
188 
189 
190 
193 
206  virtual SUMOReal maxNextSpeed(SUMOReal speed, const MSVehicle* const veh) const;
207 
208 
213  inline SUMOReal brakeGap(const SUMOReal speed) const {
214  /* one possiblity to speed this up is to precalculate speedReduction * steps * (steps+1) / 2
215  for small values of steps (up to 10 maybe) and store them in an array */
216  const SUMOReal speedReduction = ACCEL2SPEED(getMaxDecel());
217  const int steps = int(speed / speedReduction);
218  return SPEED2DIST(steps * speed - speedReduction * steps * (steps + 1) / 2) + speed * myHeadwayTime;
219  }
220 
221 
227  inline SUMOReal getSecureGap(const SUMOReal speed, const SUMOReal leaderSpeed, const SUMOReal leaderMaxDecel) const {
228  const int leaderSteps = int(leaderSpeed / ACCEL2SPEED(leaderMaxDecel));
229  const SUMOReal leaderBreak = SPEED2DIST(leaderSteps * leaderSpeed - ACCEL2SPEED(leaderMaxDecel) * leaderSteps * (leaderSteps + 1) / 2);
230  return MAX2((SUMOReal) 0, brakeGap(speed) - leaderBreak);
231  }
232 
233 
239  return MAX2((SUMOReal) 0, v - (SUMOReal) ACCEL2SPEED(myDecel));
240  }
242 
243 
246 
250  virtual void setMaxAccel(SUMOReal accel) {
251  myAccel = accel;
252  }
253 
254 
258  virtual void setMaxDecel(SUMOReal decel) {
259  myDecel = decel;
260  }
261 
262 
266  virtual void setImperfection(SUMOReal imperfection) {
267  UNUSED_PARAMETER(imperfection);
268  }
269 
270 
274  virtual void setHeadwayTime(SUMOReal headwayTime) {
275  myHeadwayTime = headwayTime;
276  }
278 
279 
280 protected:
283 
286 
289 
292 };
293 
294 
295 #endif /* MSCFModel_h */
296