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 <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  return followSpeed(veh, speed, seen, maxSpeed, 0);
97  }
98 
99 
109  virtual SUMOReal followSpeed(const MSVehicle* const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const = 0;
110 
111 
120  virtual SUMOReal stopSpeed(const MSVehicle* const veh, SUMOReal gap2pred) const = 0;
121 
122 
131  virtual SUMOReal interactionGap(const MSVehicle* const veh, SUMOReal vL) const;
132 
133 
137  virtual void saveState(std::ostream& os);
138 
139 
143  virtual int getModelID() const = 0;
144 
145 
150  virtual MSCFModel* duplicate(const MSVehicleType* vtype) const = 0;
151 
152 
157  return 0;
158  }
160 
161 
164 
168  virtual SUMOReal getMaxAccel() const {
169  return myAccel;
170  }
171 
172 
176  virtual SUMOReal getMaxDecel() const {
177  return myDecel;
178  }
179 
180 
184  virtual SUMOReal getImperfection() const {
185  return -1;
186  }
187 
188 
192  virtual SUMOReal getHeadwayTime() const {
193  return myHeadwayTime;
194  }
196 
197 
198 
201 
209  void leftVehicleVsafe(const MSVehicle* const ego, const MSVehicle* const neigh, SUMOReal& vSafe) const;
210 
211 
223  SUMOReal maxNextSpeed(SUMOReal speed) const;
224 
225 
230  SUMOReal brakeGap(SUMOReal speed) const;
231 
232 
238  SUMOReal getSecureGap(const SUMOReal speed, const SUMOReal leaderSpeed, const SUMOReal leaderMaxDecel) const {
239  const int leaderSteps = int(leaderSpeed / ACCEL2SPEED(leaderMaxDecel));
240  const SUMOReal leaderBreak = SPEED2DIST(leaderSteps * leaderSpeed - ACCEL2SPEED(leaderMaxDecel) * leaderSteps * (leaderSteps + 1) / 2);
241  return MAX2((SUMOReal) 0, brakeGap(speed) - leaderBreak);
242  }
243 
244 
250  return MAX2((SUMOReal) 0, v - (SUMOReal) ACCEL2SPEED(myDecel));
251  }
253 
254 
257 
261  virtual void setMaxAccel(SUMOReal accel) {
262  myAccel = accel;
263  }
264 
265 
269  virtual void setMaxDecel(SUMOReal decel) {
270  myDecel = decel;
271  }
272 
273 
277  virtual void setImperfection(SUMOReal imperfection) {
278  UNUSED_PARAMETER(imperfection);
279  }
280 
281 
285  virtual void setHeadwayTime(SUMOReal headwayTime) {
286  myHeadwayTime = headwayTime;
287  }
289 
290 
291 protected:
294 
297 
300 
303 };
304 
305 
306 #endif /* MSCFModel_h */
307