SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
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-2014 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
>
37
#include <
utils/common/FileHelpers.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
61
class
VehicleVariables
{
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
148
virtual
VehicleVariables
*
createVehicleVariables
()
const
{
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
return
brakeGap
(speed,
myDecel
,
myHeadwayTime
);
215
}
216
217
218
inline
static
SUMOReal
brakeGap
(
const
SUMOReal
speed,
const
SUMOReal
decel,
const
SUMOReal
headwayTime) {
219
/* one possiblity to speed this up is to precalculate speedReduction * steps * (steps+1) / 2
220
for small values of steps (up to 10 maybe) and store them in an array */
221
const
SUMOReal
speedReduction =
ACCEL2SPEED
(decel);
222
const
int
steps =
int
(speed / speedReduction);
223
return
SPEED2DIST
(steps * speed - speedReduction * steps * (steps + 1) / 2) + speed * headwayTime;
224
}
225
226
232
inline
SUMOReal
getSecureGap
(
const
SUMOReal
speed,
const
SUMOReal
leaderSpeed,
const
SUMOReal
leaderMaxDecel)
const
{
233
// The solution approach leaderBrakeGap >= followerBrakeGap is not
234
// secure when the follower can brake harder than the leader because the paths may still cross.
235
// As a workaround we lower the value of followerDecel which errs on the side of caution
236
const
SUMOReal
followDecel =
MIN2
(
myDecel
, leaderMaxDecel);
237
return
MAX2
((
SUMOReal
) 0,
brakeGap
(speed, followDecel,
myHeadwayTime
) -
brakeGap
(leaderSpeed, leaderMaxDecel, 0));
238
}
239
240
245
inline
SUMOReal
getSpeedAfterMaxDecel
(
SUMOReal
v)
const
{
246
return
MAX2
((
SUMOReal
) 0, v - (
SUMOReal
)
ACCEL2SPEED
(
myDecel
));
247
}
249
250
253
257
virtual
void
setMaxAccel
(
SUMOReal
accel) {
258
myAccel
= accel;
259
}
260
261
265
virtual
void
setMaxDecel
(
SUMOReal
decel) {
266
myDecel
= decel;
267
}
268
269
273
virtual
void
setImperfection
(
SUMOReal
imperfection) {
274
UNUSED_PARAMETER
(imperfection);
275
}
276
277
281
virtual
void
setHeadwayTime
(
SUMOReal
headwayTime) {
282
myHeadwayTime
= headwayTime;
283
}
285
286
287
protected
:
289
const
MSVehicleType
*
myType
;
290
292
SUMOReal
myAccel
;
293
295
SUMOReal
myDecel
;
296
298
SUMOReal
myHeadwayTime
;
299
};
300
301
302
#endif
/* MSCFModel_h */
303
tmp
buildd
sumo-0.21.0+dfsg
src
microsim
cfmodels
MSCFModel.h
Generated on Thu Nov 20 2014 19:49:54 for SUMO - Simulation of Urban MObility by
1.8.1.2