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-2012 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 <cassert>
36 #include <string>
37 #include <utils/common/StdDefs.h>
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class MSVehicleType;
45 class MSVehicle;
46 class MSLane;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
59 class MSCFModel {
60 public:
61 
63  };
64 
68  MSCFModel(const MSVehicleType* vtype, SUMOReal accel, SUMOReal decel, SUMOReal headwayTime);
69 
70 
72  virtual ~MSCFModel();
73 
74 
77 
83  virtual SUMOReal moveHelper(MSVehicle* const veh, SUMOReal vPos) const;
84 
85 
96  virtual SUMOReal freeSpeed(const MSVehicle* const veh, SUMOReal speed, SUMOReal seen, SUMOReal maxSpeed) const {
97  return followSpeed(veh, speed, seen, maxSpeed, 0);
98  }
99 
100 
110  virtual SUMOReal followSpeed(const MSVehicle* const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const = 0;
111 
112 
121  virtual SUMOReal stopSpeed(const MSVehicle* const veh, SUMOReal gap2pred) const = 0;
122 
123 
132  virtual SUMOReal interactionGap(const MSVehicle* const veh, SUMOReal vL) const;
133 
134 
138  virtual void saveState(std::ostream& os);
139 
140 
144  virtual int getModelID() const = 0;
145 
146 
151  virtual MSCFModel* duplicate(const MSVehicleType* vtype) const = 0;
152 
153 
158  return 0;
159  }
161 
162 
165 
169  virtual SUMOReal getMaxAccel() const {
170  return myAccel;
171  }
172 
173 
177  virtual SUMOReal getMaxDecel() const {
178  return myDecel;
179  }
180 
181 
185  virtual SUMOReal getImperfection() const {
186  return -1;
187  }
188 
189 
193  virtual SUMOReal getHeadwayTime() const {
194  return myHeadwayTime;
195  }
197 
198 
199 
202 
210  void leftVehicleVsafe(const MSVehicle* const ego, const MSVehicle* const neigh, SUMOReal& vSafe) const;
211 
212 
224  SUMOReal maxNextSpeed(SUMOReal speed) const;
225 
226 
231  SUMOReal brakeGap(SUMOReal speed) const;
232 
233 
239  SUMOReal getSecureGap(const SUMOReal speed, const SUMOReal leaderSpeed, const SUMOReal leaderMaxDecel) const {
240  const int leaderSteps = int(leaderSpeed / ACCEL2SPEED(leaderMaxDecel));
241  const SUMOReal leaderBreak = SPEED2DIST(leaderSteps * leaderSpeed - ACCEL2SPEED(leaderMaxDecel) * leaderSteps * (leaderSteps + 1) / 2);
242  return MAX2((SUMOReal) 0, brakeGap(speed) - leaderBreak);
243  }
244 
245 
251  return MAX2((SUMOReal) 0, v - (SUMOReal) ACCEL2SPEED(myDecel));
252  }
254 
255 
258 
262  virtual void setMaxAccel(SUMOReal accel) {
263  myAccel = accel;
264  }
265 
266 
270  virtual void setMaxDecel(SUMOReal decel) {
271  myDecel = decel;
272  }
273 
274 
278  virtual void setImperfection(SUMOReal imperfection) {
279  UNUSED_PARAMETER(imperfection);
280  }
281 
282 
286  virtual void setHeadwayTime(SUMOReal headwayTime) {
287  myHeadwayTime = headwayTime;
288  }
290 
291 
292 protected:
295 
298 
301 
304 };
305 
306 
307 #endif /* MSCFModel_h */
308