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-sim.org/
14
// Copyright (C) 2001-2014 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
const
SUMOReal
vMin =
getSpeedAfterMaxDecel
(oldV);
63
// do not exceed max decel even if it is unsafe
64
SUMOReal
vMax =
MAX2
(vMin,
65
MIN3
(veh->
getLane
()->
getVehicleMaxSpeed
(veh),
maxNextSpeed
(oldV, veh), vSafe));
66
#ifdef _DEBUG
67
//if (vMin > vMax) {
68
// WRITE_WARNING("Vehicle's '" + veh->getID() + "' maximum speed is lower than the minimum speed (min: " + toString(vMin) + ", max: " + toString(vMax) + ").");
69
//}
70
#endif
71
return
veh->
getLaneChangeModel
().
patchSpeed
(vMin,
MAX2
(vMin,
dawdle
(vMax)), vMax, *
this
);
72
}
73
74
75
SUMOReal
76
MSCFModel_KraussOrig1::followSpeed
(
const
MSVehicle
*
const
veh,
SUMOReal
speed,
SUMOReal
gap,
SUMOReal
predSpeed,
SUMOReal
/*predMaxDecel*/
)
const
{
77
return
MIN2
(
_vsafe
(gap, predSpeed),
maxNextSpeed
(speed, veh));
78
}
79
80
81
SUMOReal
82
MSCFModel_KraussOrig1::stopSpeed
(
const
MSVehicle
*
const
veh,
const
SUMOReal
speed,
SUMOReal
gap)
const
{
83
return
MIN2
(
_vsafe
(gap, 0),
maxNextSpeed
(speed, veh));
84
}
85
86
87
SUMOReal
88
MSCFModel_KraussOrig1::dawdle
(
SUMOReal
speed)
const
{
89
return
MAX2
(
SUMOReal
(0), speed -
ACCEL2SPEED
(
myDawdle
*
myAccel
*
RandHelper::rand
()));
90
}
91
92
94
SUMOReal
MSCFModel_KraussOrig1::_vsafe
(
SUMOReal
gap,
SUMOReal
predSpeed)
const
{
95
if
(predSpeed == 0 && gap < 0.01) {
96
return
0;
97
}
98
SUMOReal
vsafe = (
SUMOReal
)(-1. *
myTauDecel
99
+ sqrt(
100
myTauDecel
*
myTauDecel
101
+ (predSpeed * predSpeed)
102
+ (2. *
myDecel
* gap)
103
));
104
assert(vsafe >= 0);
105
return
vsafe;
106
}
107
108
109
MSCFModel
*
110
MSCFModel_KraussOrig1::duplicate
(
const
MSVehicleType
* vtype)
const
{
111
return
new
MSCFModel_KraussOrig1
(vtype,
myAccel
,
myDecel
,
myDawdle
,
myHeadwayTime
);
112
}
tmp
buildd
sumo-0.21.0+dfsg
src
microsim
cfmodels
MSCFModel_KraussOrig1.cpp
Generated on Thu Nov 20 2014 19:49:54 for SUMO - Simulation of Urban MObility by
1.8.1.2