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_Kerner.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// car-following model by B. Kerner
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
13
/****************************************************************************/
14
//
15
// This file is part of SUMO.
16
// SUMO is free software: you can redistribute it and/or modify
17
// it under the terms of the GNU General Public License as published by
18
// the Free Software Foundation, either version 3 of the License, or
19
// (at your option) any later version.
20
//
21
/****************************************************************************/
22
23
24
// ===========================================================================
25
// included modules
26
// ===========================================================================
27
#ifdef _MSC_VER
28
#include <
windows_config.h
>
29
#else
30
#include <
config.h
>
31
#endif
32
33
#include <
microsim/MSVehicle.h
>
34
#include <
microsim/MSLane.h
>
35
#include "
MSCFModel_Kerner.h
"
36
#include <
utils/common/RandHelper.h
>
37
38
39
// ===========================================================================
40
// method definitions
41
// ===========================================================================
42
MSCFModel_Kerner::MSCFModel_Kerner
(
const
MSVehicleType
* vtype,
SUMOReal
accel,
43
SUMOReal
decel,
SUMOReal
headwayTime,
SUMOReal
k,
SUMOReal
phi)
44
:
MSCFModel
(vtype, accel, decel, headwayTime), myK(k), myPhi(phi),
45
myTauDecel(decel* headwayTime) {
46
}
47
48
49
MSCFModel_Kerner::~MSCFModel_Kerner
() {}
50
51
52
SUMOReal
53
MSCFModel_Kerner::moveHelper
(
MSVehicle
*
const
veh,
SUMOReal
vPos)
const
{
54
const
SUMOReal
vNext =
MSCFModel::moveHelper
(veh, vPos);
55
VehicleVariables
* vars = (
VehicleVariables
*)veh->
getCarFollowVariables
();
56
vars->rand =
RandHelper::rand
();
57
return
vNext;
58
}
59
60
61
SUMOReal
62
MSCFModel_Kerner::followSpeed
(
const
MSVehicle
*
const
veh,
SUMOReal
speed,
SUMOReal
gap,
SUMOReal
predSpeed,
SUMOReal
/*predMaxDecel*/
)
const
{
63
return
MIN2
(
_v
(veh, speed,
maxNextSpeed
(speed, veh), gap, predSpeed),
maxNextSpeed
(speed, veh));
64
}
65
66
67
SUMOReal
68
MSCFModel_Kerner::stopSpeed
(
const
MSVehicle
*
const
veh,
const
SUMOReal
speed,
SUMOReal
gap)
const
{
69
return
MIN2
(
_v
(veh, speed,
maxNextSpeed
(speed, veh), gap, 0),
maxNextSpeed
(speed, veh));
70
}
71
72
73
MSCFModel::VehicleVariables
*
74
MSCFModel_Kerner::createVehicleVariables
()
const
{
75
VehicleVariables
* ret =
new
VehicleVariables
();
76
ret->rand =
RandHelper::rand
();
77
return
ret;
78
}
79
80
81
SUMOReal
82
MSCFModel_Kerner::_v
(
const
MSVehicle
*
const
veh,
SUMOReal
speed,
SUMOReal
vfree,
SUMOReal
gap,
SUMOReal
predSpeed)
const
{
83
if
(predSpeed == 0 && gap < 0.01) {
84
return
0;
85
}
86
// !!! in the following, the prior step is not considered!!!
87
SUMOReal
G =
MAX2
((
SUMOReal
) 0, (
SUMOReal
)(
SPEED2DIST
(
myK
* speed) +
myPhi
/
myAccel
* speed * (speed - predSpeed)));
88
SUMOReal
vcond = gap > G ? speed +
ACCEL2SPEED
(
myAccel
) : speed +
MAX2
(
ACCEL2SPEED
(-
myDecel
),
MIN2
(
ACCEL2SPEED
(
myAccel
), predSpeed - speed));
89
SUMOReal
vsafe = (
SUMOReal
)(-1. *
myTauDecel
+ sqrt(
myTauDecel
*
myTauDecel
+ (predSpeed * predSpeed) + (2. *
myDecel
* gap)));
90
VehicleVariables
* vars = (
VehicleVariables
*)veh->
getCarFollowVariables
();
91
SUMOReal
va =
MAX2
((
SUMOReal
) 0,
MIN3
(vfree, vsafe, vcond)) + vars->rand;
92
SUMOReal
v =
MAX2
((
SUMOReal
) 0,
MIN4
(vfree, va, speed +
ACCEL2SPEED
(
myAccel
), vsafe));
93
return
v;
94
}
95
96
97
MSCFModel
*
98
MSCFModel_Kerner::duplicate
(
const
MSVehicleType
* vtype)
const
{
99
return
new
MSCFModel_Kerner
(vtype,
myAccel
,
myDecel
,
myHeadwayTime
,
myK
,
myPhi
);
100
}
tmp
buildd
sumo-0.21.0+dfsg
src
microsim
cfmodels
MSCFModel_Kerner.cpp
Generated on Thu Nov 20 2014 19:49:54 for SUMO - Simulation of Urban MObility by
1.8.1.2