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_Krauss.cpp
Go to the documentation of this file.
1
/****************************************************************************/
11
// Krauss car-following model, with acceleration decrease and faster start
12
/****************************************************************************/
13
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
14
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
15
/****************************************************************************/
16
//
17
// This file is part of SUMO.
18
// SUMO is free software: you can redistribute it and/or modify
19
// it under the terms of the GNU General Public License as published by
20
// the Free Software Foundation, either version 3 of the License, or
21
// (at your option) any later version.
22
//
23
/****************************************************************************/
24
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 <
microsim/MSVehicle.h
>
36
#include <
microsim/MSLane.h
>
37
#include "
MSCFModel_Krauss.h
"
38
#include <
microsim/MSAbstractLaneChangeModel.h
>
39
#include <
utils/common/RandHelper.h
>
40
41
42
// ===========================================================================
43
// method definitions
44
// ===========================================================================
45
MSCFModel_Krauss::MSCFModel_Krauss
(
const
MSVehicleType
* vtype,
SUMOReal
accel,
SUMOReal
decel,
46
SUMOReal
dawdle,
SUMOReal
headwayTime)
47
:
MSCFModel_KraussOrig1
(vtype, accel, decel, dawdle, headwayTime) {
48
}
49
50
51
MSCFModel_Krauss::~MSCFModel_Krauss
() {}
52
53
54
SUMOReal
55
MSCFModel_Krauss::followSpeed
(
const
MSVehicle
*
const
/*veh*/
,
SUMOReal
speed,
SUMOReal
gap,
SUMOReal
predSpeed,
SUMOReal
predMaxDecel)
const
{
56
return
MIN2
(
_vsafe
(gap, predSpeed, predMaxDecel),
maxNextSpeed
(speed));
57
}
58
59
60
SUMOReal
61
MSCFModel_Krauss::stopSpeed
(
const
MSVehicle
*
const
veh,
SUMOReal
gap)
const
{
62
return
MIN2
(
_vsafe
(gap, 0, 0),
maxNextSpeed
(veh->
getSpeed
()));
63
}
64
65
66
SUMOReal
67
MSCFModel_Krauss::dawdle
(
SUMOReal
speed)
const
{
68
// generate random number out of [0,1]
69
SUMOReal
random =
RandHelper::rand
();
70
// Dawdle.
71
if
(speed <
myAccel
) {
72
// we should not prevent vehicles from driving just due to dawdling
73
// if someone is starting, he should definitely start
74
// (but what about slow-to-start?)!!!
75
speed -=
ACCEL2SPEED
(
myDawdle
* speed * random);
76
}
else
{
77
speed -=
ACCEL2SPEED
(
myDawdle
*
myAccel
* random);
78
}
79
return
MAX2
(
SUMOReal
(0), speed);
80
}
81
82
84
SUMOReal
85
MSCFModel_Krauss::_vsafe
(
SUMOReal
gap,
SUMOReal
predSpeed,
SUMOReal
predMaxDecel)
const
{
86
if
(predSpeed < predMaxDecel) {
87
// avoid discretization error at low speeds
88
predSpeed = 0;
89
}
90
if
(predSpeed == 0) {
91
if
(gap < 0.01) {
92
return
0;
93
}
94
return
(
SUMOReal
)(-
myTauDecel
+ sqrt(
myTauDecel
*
myTauDecel
+ 2. *
myDecel
* gap));
95
}
96
if
(predMaxDecel == 0) {
97
// adapt speed to succeeding lane, no reaction time is involved
98
// g = (x-v)/b * (x+v)/2
99
return
(
SUMOReal
)sqrt(2 * gap *
myDecel
+ predSpeed * predSpeed);
100
101
}
102
// follow
103
// g + (v^2 - a*v)/(2*a) = x*t + (x^2 - b*x)/(2*b) + 0.5
104
return
(
SUMOReal
)(0.5 * sqrt(4.0 *
myDecel
* (2.0 * gap + predSpeed * predSpeed / predMaxDecel - predSpeed - 1.0) +
105
(
myDecel
* (2.0 *
myHeadwayTime
- 1.0))
106
* (
myDecel
* (2.0 *
myHeadwayTime
- 1.0)))
107
+
myDecel
* (0.5 -
myHeadwayTime
));
108
}
109
110
111
MSCFModel
*
112
MSCFModel_Krauss::duplicate
(
const
MSVehicleType
* vtype)
const
{
113
return
new
MSCFModel_Krauss
(vtype,
myAccel
,
myDecel
,
myDawdle
,
myHeadwayTime
);
114
}
115
116
117
//void MSCFModel::saveState(std::ostream &os) {}
118
build
buildd
sumo-0.16.0~dfsg
src
microsim
cfmodels
MSCFModel_Krauss.cpp
Generated on Tue Apr 16 2013 01:32:17 for SUMO - Simulation of Urban MObility by
1.8.3.1