SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSCFModel_PWag2009.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Scalable model based on Krauß by Peter Wagner
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2012 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_PWag2009.h"
37 
38 
39 // ===========================================================================
40 // method definitions
41 // ===========================================================================
43  SUMOReal dawdle, SUMOReal headwayTime, SUMOReal tauLast, SUMOReal apProb)
44  : MSCFModel(vtype, accel, decel, headwayTime), myDawdle(dawdle),
45  myTauDecel(decel* headwayTime), myDecelDivTau(decel / headwayTime), myTauLastDecel(decel* tauLast),
46  myActionPointProbability(apProb) {
47 }
48 
49 
51 
52 
55  const SUMOReal vNext = MSCFModel::moveHelper(veh, vPos);
56  const SUMOReal speed = veh->getSpeed();
58  // model should re-use acceleration from previous time-step:
59  SUMOReal apref = vars->aOld;
60  const SUMOReal asafe = SPEED2ACCEL(vNext - speed);
61  if (apref <= asafe && RandHelper::rand() > myActionPointProbability * TS) {
62  std::pair<MSVehicle* const, SUMOReal> l = veh->getLane()->getLeaderOnConsecutive(100., 0., speed, *veh, veh->getBestLanesContinuation(veh->getLane()));
63  if (l.first) {
64  apref = myDecelDivTau * (l.second + (l.first->getSpeed() - speed) * myHeadwayTime - speed * myHeadwayTime) / (speed + myTauDecel);
65  apref += myDawdle * RandHelper::rand((SUMOReal) - 1., (SUMOReal)1.);
66  }
67  }
68  if (apref > asafe) {
69  apref = asafe;
70  }
71  vars->aOld = apref; // save this value for the next time-step
72  return MAX2((SUMOReal)0, speed + ACCEL2SPEED(apref));
73 }
74 
75 
77 MSCFModel_PWag2009::followSpeed(const MSVehicle* const veh, SUMOReal speed, SUMOReal gap, SUMOReal predSpeed, SUMOReal /*predMaxDecel*/) const {
78  return _v(veh, speed, gap, predSpeed);
79 }
80 
81 
83 MSCFModel_PWag2009::stopSpeed(const MSVehicle* const veh, SUMOReal gap) const {
84  return _v(veh, veh->getSpeed(), gap, 0);
85 }
86 
87 
90  return MAX2(SUMOReal(0), speed - ACCEL2SPEED(myDawdle * myAccel * RandHelper::rand()));
91 }
92 
93 // in addition, the parameters myTauLast, probAP, and sigmaAcc are needed; sigmaAcc can use myDawdle
94 // myTauLast might use the current time-step size, but this yields eventually an extreme model, I would be
95 // more careful and set it to something around 0.3 or 0.4, which are among the shortest headways I have
96 // seen so far in data ...
98 MSCFModel_PWag2009::_v(const MSVehicle* const veh, SUMOReal speed, SUMOReal gap, SUMOReal predSpeed) const {
99  if (predSpeed == 0 && gap < 0.01) {
100  return 0;
101  }
102  const SUMOReal vsafe = -myTauLastDecel + sqrt(myTauLastDecel * myTauLastDecel + predSpeed * predSpeed + 2.0 * myDecel * gap);
103  return MAX2((SUMOReal)0, vsafe);
104 }
105 
106 
107 MSCFModel*
110 }