Eclipse SUMO - Simulation of Urban MObility
MSCFModel_KraussX.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // Krauss car-following model, changing accel and speed by slope
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
28 #include <microsim/MSVehicle.h>
29 #include <microsim/MSNet.h>
30 #include "MSCFModel_KraussX.h"
31 
32 
33 #define OVERBRAKING_THRESHOLD -3
34 
35 // ===========================================================================
36 // method definitions
37 // ===========================================================================
39  MSCFModel_Krauss(vtype),
40  myTmp1(vtype->getParameter().getCFParam(SUMO_ATTR_TMP1, 0.0)),
41  myTmp2(vtype->getParameter().getCFParam(SUMO_ATTR_TMP2, 0.0)) {
42 }
43 
44 
46 
47 
48 MSCFModel*
50  return new MSCFModel_KraussX(vtype);
51 }
52 
53 
54 double
55 MSCFModel_KraussX::patchSpeedBeforeLC(const MSVehicle* veh, double vMin, double vMax) const {
56  return dawdleX(veh->getSpeed(), vMin, vMax, veh->getRNG());
57 }
58 
59 
60 double
61 MSCFModel_KraussX::dawdleX(double vOld, double vMin, double vMax, std::mt19937* rng) const {
62  double speed = vMax;
64  // in case of the ballistic update, negative speeds indicate
65  // a desired stop before the completion of the next timestep.
66  // We do not allow dawdling to overwrite this indication
67  if (speed < 0) {
68  return speed;
69  }
70  }
71  // extra slow to start
72  if (vOld < myAccel) {
73  speed -= ACCEL2SPEED(myTmp1 * myAccel);
74  }
75  const double random = RandHelper::rand(rng);
76  speed -= ACCEL2SPEED(myDawdle * myAccel * random);
77  // overbraking
78  if (vOld > vMax) {
79  speed -= ACCEL2SPEED(myTmp2 * myAccel * random);
80  //std::cout << " vMin=" << vMin << " vMax=" << vMax << "speed=" << speed << " d1=" << ACCEL2SPEED(myDawdle * myAccel * random) << " d2=" << ACCEL2SPEED(myTmp2 * myAccel * random) << " unexpectedDecel=" << (speed < vMin) << "\n";
82  speed = MAX2(0.0, speed);
83  }
84  }
85  speed = MAX2(vMin, speed);
86  return speed;
87 }
88 
89 
90 
91 /****************************************************************************/
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:65
MSNet.h
MSCFModel_KraussX::myTmp1
double myTmp1
extension parameter nr1
Definition: MSCFModel_KraussX.h:83
SUMO_ATTR_TMP2
Definition: SUMOXMLDefinitions.h:551
ACCEL2SPEED
#define ACCEL2SPEED(x)
Definition: SUMOTime.h:52
SUMO_ATTR_TMP1
Definition: SUMOXMLDefinitions.h:550
MSCFModel_Krauss
Krauss car-following model, with acceleration decrease and faster start.
Definition: MSCFModel_Krauss.h:38
MSCFModel_KraussX::duplicate
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
Definition: MSCFModel_KraussX.cpp:49
MSVehicle.h
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:53
MSCFModel_KraussOrig1::myDawdle
double myDawdle
The vehicle's dawdle-parameter. 0 for no dawdling, 1 for max.
Definition: MSCFModel_KraussOrig1.h:148
MSCFModel_KraussX::dawdleX
double dawdleX(double vOld, double vMin, double vMax, std::mt19937 *rng) const
Applies driver imperfection (dawdling / sigma)
Definition: MSCFModel_KraussX.cpp:61
MSCFModel_KraussX::myTmp2
double myTmp2
Definition: MSCFModel_KraussX.h:84
MSCFModel
The car-following model abstraction.
Definition: MSCFModel.h:56
config.h
MSVehicle::getSpeed
double getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:476
MSCFModel::myAccel
double myAccel
The vehicle's maximum acceleration [m/s^2].
Definition: MSCFModel.h:617
MSGlobals::gSemiImplicitEulerUpdate
static bool gSemiImplicitEulerUpdate
Definition: MSGlobals.h:55
MSCFModel_KraussX::~MSCFModel_KraussX
~MSCFModel_KraussX()
Destructor.
Definition: MSCFModel_KraussX.cpp:45
MSCFModel_KraussX.h
MSCFModel_KraussX::MSCFModel_KraussX
MSCFModel_KraussX(const MSVehicleType *vtype)
Constructor.
Definition: MSCFModel_KraussX.cpp:38
MSCFModel_KraussX::patchSpeedBeforeLC
double patchSpeedBeforeLC(const MSVehicle *veh, double vMin, double vMax) const
apply custom speed adaptations within the given speed bounds
Definition: MSCFModel_KraussX.cpp:55
MSAbstractLaneChangeModel.h
MSBaseVehicle::getRNG
std::mt19937 * getRNG() const
Definition: MSBaseVehicle.cpp:758
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79