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_KraussOrig1.cpp
Go to the documentation of this file.
1
/****************************************************************************/
11
// The original Krauss (1998) car-following model and parameter
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_KraussOrig1.h
"
38
#include <
microsim/MSAbstractLaneChangeModel.h
>
39
#include <
utils/common/RandHelper.h
>
40
41
42
// ===========================================================================
43
// method definitions
44
// ===========================================================================
45
MSCFModel_KraussOrig1::MSCFModel_KraussOrig1
(
const
MSVehicleType
* vtype,
SUMOReal
accel,
SUMOReal
decel,
46
SUMOReal
dawdle,
SUMOReal
headwayTime)
47
:
MSCFModel
(vtype, accel, decel, headwayTime), myDawdle(dawdle), myTauDecel(decel* headwayTime) {
48
}
49
50
51
MSCFModel_KraussOrig1::~MSCFModel_KraussOrig1
() {}
52
53
54
SUMOReal
55
MSCFModel_KraussOrig1::moveHelper
(
MSVehicle
*
const
veh,
SUMOReal
vPos)
const
{
56
const
SUMOReal
oldV = veh->
getSpeed
();
// save old v for optional acceleration computation
57
const
SUMOReal
vSafe =
MIN2
(vPos, veh->
processNextStop
(vPos));
// process stops
58
// we need the acceleration for emission computation;
59
// in this case, we neglect dawdling, nonetheless, using
60
// vSafe does not incorporate speed reduction due to interaction
61
// on lane changing
62
veh->
setPreDawdleAcceleration
(
SPEED2ACCEL
(vSafe - oldV));
63
const
SUMOReal
vMin =
MAX2
((
SUMOReal
) 0, oldV -
ACCEL2SPEED
(
myDecel
));
64
const
SUMOReal
vMax =
MIN3
(veh->
getLane
()->
getMaxSpeed
(),
maxNextSpeed
(oldV), vSafe);
65
#ifdef _DEBUG
66
if
(vMin > vMax) {
67
WRITE_WARNING
(
"Vehicle's '"
+ veh->
getID
() +
"' maximum speed is lower than the minimum speed (min: "
+
toString
(vMin) +
", max: "
+
toString
(vMax) +
")."
);
68
}
69
#endif
70
return
veh->
getLaneChangeModel
().
patchSpeed
(vMin,
MAX2
(vMin,
dawdle
(vMax)), vMax, *
this
);
71
}
72
73
74
SUMOReal
75
MSCFModel_KraussOrig1::followSpeed
(
const
MSVehicle
*
const
/*veh*/
,
SUMOReal
speed,
SUMOReal
gap,
SUMOReal
predSpeed,
SUMOReal
/*predMaxDecel*/
)
const
{
76
return
MIN2
(
_vsafe
(gap, predSpeed),
maxNextSpeed
(speed));
77
}
78
79
80
SUMOReal
81
MSCFModel_KraussOrig1::stopSpeed
(
const
MSVehicle
*
const
veh,
SUMOReal
gap)
const
{
82
return
MIN2
(
_vsafe
(gap, 0),
maxNextSpeed
(veh->
getSpeed
()));
83
}
84
85
86
SUMOReal
87
MSCFModel_KraussOrig1::dawdle
(
SUMOReal
speed)
const
{
88
return
MAX2
(
SUMOReal
(0), speed -
ACCEL2SPEED
(
myDawdle
*
myAccel
*
RandHelper::rand
()));
89
}
90
91
93
SUMOReal
MSCFModel_KraussOrig1::_vsafe
(
SUMOReal
gap,
SUMOReal
predSpeed)
const
{
94
if
(predSpeed == 0 && gap < 0.01) {
95
return
0;
96
}
97
SUMOReal
vsafe = (
SUMOReal
)(-1. *
myTauDecel
98
+ sqrt(
99
myTauDecel
*
myTauDecel
100
+ (predSpeed * predSpeed)
101
+ (2. *
myDecel
* gap)
102
));
103
assert(vsafe >= 0);
104
return
vsafe;
105
}
106
107
108
MSCFModel
*
109
MSCFModel_KraussOrig1::duplicate
(
const
MSVehicleType
* vtype)
const
{
110
return
new
MSCFModel_KraussOrig1
(vtype,
myAccel
,
myDecel
,
myDawdle
,
myHeadwayTime
);
111
}
build
buildd
sumo-0.15.0~dfsg
src
microsim
cfmodels
MSCFModel_KraussOrig1.cpp
Generated on Wed Jul 18 2012 22:58:32 for SUMO - Simulation of Urban MObility by
1.8.1.1