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_Daniel1.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// The original Krauss (1998) car-following model and parameter
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2012-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_Daniel1.h
"
36
#include <
microsim/MSAbstractLaneChangeModel.h
>
37
#include <
utils/common/RandHelper.h
>
38
39
40
// ===========================================================================
41
// method definitions
42
// ===========================================================================
43
MSCFModel_Daniel1::MSCFModel_Daniel1
(
const
MSVehicleType
* vtype,
SUMOReal
accel,
SUMOReal
decel,
44
SUMOReal
dawdle,
SUMOReal
headwayTime,
45
SUMOReal
tmp1,
SUMOReal
tmp2,
SUMOReal
tmp3,
SUMOReal
tmp4,
SUMOReal
tmp5)
46
:
MSCFModel
(vtype, accel, decel, headwayTime), myDawdle(dawdle), myTauDecel(decel* headwayTime),
47
myTmp1(tmp1), myTmp2(tmp2), myTmp3(tmp3), myTmp4(tmp4), myTmp5(tmp5) {
48
}
49
50
51
MSCFModel_Daniel1::~MSCFModel_Daniel1
() {}
52
53
54
SUMOReal
55
MSCFModel_Daniel1::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
const
SUMOReal
vMax =
MIN3
(veh->
getLane
()->
getVehicleMaxSpeed
(veh),
maxNextSpeed
(oldV, veh), vSafe);
64
#ifdef _DEBUG
65
if
(vMin > vMax) {
66
WRITE_WARNING
(
"Vehicle's '"
+ veh->
getID
() +
"' maximum speed is lower than the minimum speed (min: "
+
toString
(vMin) +
", max: "
+
toString
(vMax) +
")."
);
67
}
68
#endif
69
return
veh->
getLaneChangeModel
().
patchSpeed
(vMin,
MAX2
(vMin,
dawdle
(vMax)), vMax, *
this
);
70
}
71
72
73
SUMOReal
74
MSCFModel_Daniel1::followSpeed
(
const
MSVehicle
*
const
veh,
SUMOReal
speed,
SUMOReal
gap,
SUMOReal
predSpeed,
SUMOReal
/*predMaxDecel*/
)
const
{
75
return
MIN2
(
_vsafe
(gap, predSpeed),
maxNextSpeed
(speed, veh));
76
}
77
78
79
SUMOReal
80
MSCFModel_Daniel1::stopSpeed
(
const
MSVehicle
*
const
veh,
const
SUMOReal
speed,
SUMOReal
gap)
const
{
81
return
MIN2
(
_vsafe
(gap, 0),
maxNextSpeed
(speed, veh));
82
}
83
84
85
SUMOReal
86
MSCFModel_Daniel1::dawdle
(
SUMOReal
speed)
const
{
87
return
MAX2
(
SUMOReal
(0), speed -
ACCEL2SPEED
(
myDawdle
*
myAccel
*
RandHelper::rand
()));
88
}
89
90
92
SUMOReal
MSCFModel_Daniel1::_vsafe
(
SUMOReal
gap,
SUMOReal
predSpeed)
const
{
93
if
(predSpeed == 0 && gap < 0.01) {
94
return
0;
95
}
96
SUMOReal
vsafe = (
SUMOReal
)(-1. *
myTauDecel
97
+ sqrt(
98
myTauDecel
*
myTauDecel
99
+ (predSpeed * predSpeed)
100
+ (2. *
myDecel
* gap)
101
));
102
assert(vsafe >= 0);
103
return
vsafe;
104
}
105
106
107
MSCFModel
*
108
MSCFModel_Daniel1::duplicate
(
const
MSVehicleType
* vtype)
const
{
109
return
new
MSCFModel_Daniel1
(vtype,
myAccel
,
myDecel
,
myDawdle
,
myHeadwayTime
,
110
myTmp1
,
myTmp2
,
myTmp3
,
myTmp4
,
myTmp5
);
111
}
tmp
buildd
sumo-0.21.0+dfsg
src
microsim
cfmodels
MSCFModel_Daniel1.cpp
Generated on Thu Nov 20 2014 19:49:54 for SUMO - Simulation of Urban MObility by
1.8.1.2