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.sourceforge.net/
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, 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 
156 
160  virtual SUMOReal getMaxAccel() const {
161  return myAccel;
162  }
163 
164 
168  virtual SUMOReal getMaxDecel() const {
169  return myDecel;
170  }
171 
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 
201  void leftVehicleVsafe(const MSVehicle* const ego, const MSVehicle* const neigh, SUMOReal& vSafe) const;
202 
203 
216  virtual SUMOReal maxNextSpeed(SUMOReal speed, const MSVehicle* const veh) const;
217 
218 
223  SUMOReal brakeGap(SUMOReal speed) const;
224 
225 
231  SUMOReal getSecureGap(const SUMOReal speed, const SUMOReal leaderSpeed, const SUMOReal leaderMaxDecel) const {
232  const int leaderSteps = int(leaderSpeed / ACCEL2SPEED(leaderMaxDecel));
233  const SUMOReal leaderBreak = SPEED2DIST(leaderSteps * leaderSpeed - ACCEL2SPEED(leaderMaxDecel) * leaderSteps * (leaderSteps + 1) / 2);
234  return MAX2((SUMOReal) 0, brakeGap(speed) - leaderBreak);
235  }
236 
237 
243  return MAX2((SUMOReal) 0, v - (SUMOReal) ACCEL2SPEED(myDecel));
244  }
246 
247 
250 
254  virtual void setMaxAccel(SUMOReal accel) {
255  myAccel = accel;
256  }
257 
258 
262  virtual void setMaxDecel(SUMOReal decel) {
263  myDecel = decel;
264  }
265 
266 
270  virtual void setImperfection(SUMOReal imperfection) {
271  UNUSED_PARAMETER(imperfection);
272  }
273 
274 
278  virtual void setHeadwayTime(SUMOReal headwayTime) {
279  myHeadwayTime = headwayTime;
280  }
282 
283 
284 protected:
287 
290 
293 
296 };
297 
298 
299 #endif /* MSCFModel_h */
300