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
/****************************************************************************/
7
// The original Krauss (1998) car-following model and parameter
8
/****************************************************************************/
9
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
10
// Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11
/****************************************************************************/
12
//
13
// This file is part of SUMO.
14
// SUMO is free software: you can redistribute it and/or modify
15
// it under the terms of the GNU General Public License as published by
16
// the Free Software Foundation, either version 3 of the License, or
17
// (at your option) any later version.
18
//
19
/****************************************************************************/
20
21
22
// ===========================================================================
23
// included modules
24
// ===========================================================================
25
#ifdef _MSC_VER
26
#include <
windows_config.h
>
27
#else
28
#include <
config.h
>
29
#endif
30
31
#include <
microsim/MSVehicle.h
>
32
#include <
microsim/MSLane.h
>
33
#include "
MSCFModel_Daniel1.h
"
34
#include <
microsim/MSAbstractLaneChangeModel.h
>
35
#include <
utils/common/RandHelper.h
>
36
37
38
// ===========================================================================
39
// method definitions
40
// ===========================================================================
41
MSCFModel_Daniel1::MSCFModel_Daniel1
(
const
MSVehicleType
* vtype,
SUMOReal
accel,
SUMOReal
decel,
42
SUMOReal
dawdle,
SUMOReal
headwayTime,
43
SUMOReal
tmp1,
SUMOReal
tmp2,
SUMOReal
tmp3,
SUMOReal
tmp4,
SUMOReal
tmp5)
44
:
MSCFModel
(vtype, accel, decel, headwayTime), myDawdle(dawdle), myTauDecel(decel* headwayTime),
45
myTmp1(tmp1), myTmp2(tmp2), myTmp3(tmp3), myTmp4(tmp4), myTmp5(tmp5) {
46
}
47
48
49
MSCFModel_Daniel1::~MSCFModel_Daniel1
() {}
50
51
52
SUMOReal
53
MSCFModel_Daniel1::moveHelper
(
MSVehicle
*
const
veh,
SUMOReal
vPos)
const
{
54
const
SUMOReal
oldV = veh->
getSpeed
();
// save old v for optional acceleration computation
55
const
SUMOReal
vSafe =
MIN2
(vPos, veh->
processNextStop
(vPos));
// process stops
56
// we need the acceleration for emission computation;
57
// in this case, we neglect dawdling, nonetheless, using
58
// vSafe does not incorporate speed reduction due to interaction
59
// on lane changing
60
const
SUMOReal
vMin =
getSpeedAfterMaxDecel
(oldV);
61
const
SUMOReal
vMax =
MIN3
(veh->
getLane
()->
getVehicleMaxSpeed
(veh),
maxNextSpeed
(oldV, veh), vSafe);
62
#ifdef _DEBUG
63
if
(vMin > vMax) {
64
WRITE_WARNING
(
"Vehicle's '"
+ veh->
getID
() +
"' maximum speed is lower than the minimum speed (min: "
+
toString
(vMin) +
", max: "
+
toString
(vMax) +
")."
);
65
}
66
#endif
67
return
veh->
getLaneChangeModel
().
patchSpeed
(vMin,
MAX2
(vMin,
dawdle
(vMax)), vMax, *
this
);
68
}
69
70
71
SUMOReal
72
MSCFModel_Daniel1::followSpeed
(
const
MSVehicle
*
const
veh,
SUMOReal
speed,
SUMOReal
gap,
SUMOReal
predSpeed,
SUMOReal
/*predMaxDecel*/
)
const
{
73
return
MIN2
(
_vsafe
(gap, predSpeed),
maxNextSpeed
(speed, veh));
74
}
75
76
77
SUMOReal
78
MSCFModel_Daniel1::stopSpeed
(
const
MSVehicle
*
const
veh,
SUMOReal
gap)
const
{
79
return
MIN2
(
_vsafe
(gap, 0),
maxNextSpeed
(veh->
getSpeed
(), veh));
80
}
81
82
83
SUMOReal
84
MSCFModel_Daniel1::dawdle
(
SUMOReal
speed)
const
{
85
return
MAX2
(
SUMOReal
(0), speed -
ACCEL2SPEED
(
myDawdle
*
myAccel
*
RandHelper::rand
()));
86
}
87
88
90
SUMOReal
MSCFModel_Daniel1::_vsafe
(
SUMOReal
gap,
SUMOReal
predSpeed)
const
{
91
if
(predSpeed == 0 && gap < 0.01) {
92
return
0;
93
}
94
SUMOReal
vsafe = (
SUMOReal
)(-1. *
myTauDecel
95
+ sqrt(
96
myTauDecel
*
myTauDecel
97
+ (predSpeed * predSpeed)
98
+ (2. *
myDecel
* gap)
99
));
100
assert(vsafe >= 0);
101
return
vsafe;
102
}
103
104
105
MSCFModel
*
106
MSCFModel_Daniel1::duplicate
(
const
MSVehicleType
* vtype)
const
{
107
return
new
MSCFModel_Daniel1
(vtype,
myAccel
,
myDecel
,
myDawdle
,
myHeadwayTime
,
108
myTmp1
,
myTmp2
,
myTmp3
,
myTmp4
,
myTmp5
);
109
}
home
gladk
tmp
05
sumo-0.17.1~dfsg
src
microsim
cfmodels
MSCFModel_Daniel1.cpp
Generated on Sun Jun 16 2013 07:07:28 for SUMO - Simulation of Urban MObility by
1.8.1.2