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.cpp
Go to the documentation of this file.
1
/****************************************************************************/
11
// The car-following model abstraction
12
/****************************************************************************/
13
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
14
// Copyright (C) 2001-2013 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 <math.h>
36
#include <
microsim/MSVehicleType.h
>
37
#include <
microsim/MSVehicle.h
>
38
#include <
microsim/MSLane.h
>
39
#include <
microsim/MSAbstractLaneChangeModel.h
>
40
#include "
MSCFModel.h
"
41
42
43
// ===========================================================================
44
// method definitions
45
// ===========================================================================
46
MSCFModel::MSCFModel
(
const
MSVehicleType
* vtype,
const
SUMOReal
accel,
47
const
SUMOReal
decel,
const
SUMOReal
headwayTime)
48
: myType(vtype), myAccel(accel), myDecel(decel), myHeadwayTime(headwayTime) {
49
}
50
51
52
MSCFModel::~MSCFModel
() {}
53
54
55
SUMOReal
56
MSCFModel::moveHelper
(
MSVehicle
*
const
veh,
SUMOReal
vPos)
const
{
57
const
SUMOReal
oldV = veh->
getSpeed
();
// save old v for optional acceleration computation
58
const
SUMOReal
vSafe =
MIN2
(vPos, veh->
processNextStop
(vPos));
// process stops
59
// we need the acceleration for emission computation;
60
// in this case, we neglect dawdling, nonetheless, using
61
// vSafe does not incorporate speed reduction due to interaction
62
// on lane changing
63
const
SUMOReal
vMin =
getSpeedAfterMaxDecel
(oldV);
64
const
SUMOReal
vMax =
MIN3
(veh->
getLane
()->
getVehicleMaxSpeed
(veh),
maxNextSpeed
(oldV, veh), vSafe);
65
assert(vMin <= vMax);
66
return
veh->
getLaneChangeModel
().
patchSpeed
(vMin, vMax, vMax, *
this
);
67
}
68
69
70
SUMOReal
71
MSCFModel::interactionGap
(
const
MSVehicle
*
const
veh,
SUMOReal
vL)
const
{
72
// Resolve the vsafe equation to gap. Assume predecessor has
73
// speed != 0 and that vsafe will be the current speed plus acceleration,
74
// i.e that with this gap there will be no interaction.
75
const
SUMOReal
vNext =
MIN2
(
maxNextSpeed
(veh->
getSpeed
(), veh), veh->
getLane
()->
getVehicleMaxSpeed
(veh));
76
const
SUMOReal
gap = (vNext - vL) *
77
((veh->
getSpeed
() + vL) / (2.*
myDecel
) +
myHeadwayTime
) +
78
vL *
myHeadwayTime
;
79
80
// Don't allow timeHeadWay < deltaT situations.
81
return
MAX2
(gap,
SPEED2DIST
(vNext));
82
}
83
84
85
SUMOReal
86
MSCFModel::maxNextSpeed
(
SUMOReal
speed,
const
MSVehicle
*
const
/*veh*/
)
const
{
87
return
MIN2
(speed + (
SUMOReal
)
ACCEL2SPEED
(
getMaxAccel
()),
myType
->
getMaxSpeed
());
88
}
89
90
91
SUMOReal
92
MSCFModel::freeSpeed
(
const
MSVehicle
*
const
/* veh */
,
SUMOReal
/* speed */
,
SUMOReal
seen,
SUMOReal
maxSpeed)
const
{
93
// adapt speed to succeeding lane, no reaction time is involved
94
// when breaking for y steps the following distance g is covered
95
// (drive with v in the final step)
96
// g = (y^2 + y) * 0.5 * b + y * v
97
// y = ((((sqrt((b + 2.0*v)*(b + 2.0*v) + 8.0*b*g)) - b)*0.5 - v)/b)
98
const
SUMOReal
b =
ACCEL2SPEED
(
myDecel
);
99
const
SUMOReal
y =
MAX2
(0.0, ((sqrt((b + 2.0 * maxSpeed) * (b + 2.0 * maxSpeed) + 8.0 * b * seen) - b) * 0.5 - maxSpeed) / b);
100
const
SUMOReal
yFull = floor(y);
101
const
SUMOReal
exactGap = (yFull * yFull + yFull) * 0.5 * b + yFull * maxSpeed + (y > yFull ? maxSpeed : 0.0);
102
return
MAX2
((
SUMOReal
)0.0, seen - exactGap) / (yFull + 1) + yFull *
myDecel
+ maxSpeed;
103
}
104
105
/****************************************************************************/
build
buildd
sumo-0.18~dfsg
src
microsim
cfmodels
MSCFModel.cpp
Generated on Wed Oct 23 2013 01:15:09 for SUMO - Simulation of Urban MObility by
1.8.4