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 /****************************************************************************/
19 // Krauss car-following model, changing accel and speed by slope
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
29 #include <microsim/MSVehicle.h>
30 #include <microsim/MSNet.h>
31 #include "MSCFModel_KraussX.h"
32 
33 
34 #define OVERBRAKING_THRESHOLD -3
35 
36 // ===========================================================================
37 // method definitions
38 // ===========================================================================
40  MSCFModel_Krauss(vtype),
41  myTmp1(vtype->getParameter().getCFParam(SUMO_ATTR_TMP1, 0.0)),
42  myTmp2(vtype->getParameter().getCFParam(SUMO_ATTR_TMP2, 0.0)) {
43 }
44 
45 
47 
48 
49 MSCFModel*
51  return new MSCFModel_KraussX(vtype);
52 }
53 
54 
55 double
56 MSCFModel_KraussX::patchSpeedBeforeLC(const MSVehicle* veh, double vMin, double vMax) const {
57  return dawdleX(veh->getSpeed(), vMin, vMax, veh->getRNG());
58 }
59 
60 
61 double
62 MSCFModel_KraussX::dawdleX(double vOld, double vMin, double vMax, std::mt19937* rng) const {
63  double speed = vMax;
65  // in case of the ballistic update, negative speeds indicate
66  // a desired stop before the completion of the next timestep.
67  // We do not allow dawdling to overwrite this indication
68  if (speed < 0) {
69  return speed;
70  }
71  }
72  // extra slow to start
73  if (vOld < myAccel) {
74  speed -= ACCEL2SPEED(myTmp1 * myAccel);
75  }
76  const double random = RandHelper::rand(rng);
77  speed -= ACCEL2SPEED(myDawdle * myAccel * random);
78  // overbraking
79  if (vOld > vMax) {
80  speed -= ACCEL2SPEED(myTmp2 * myAccel * random);
81  //std::cout << " vMin=" << vMin << " vMax=" << vMax << "speed=" << speed << " d1=" << ACCEL2SPEED(myDawdle * myAccel * random) << " d2=" << ACCEL2SPEED(myTmp2 * myAccel * random) << " unexpectedDecel=" << (speed < vMin) << "\n";
83  speed = MAX2(0.0, speed);
84  }
85  }
86  speed = MAX2(vMin, speed);
87  return speed;
88 }
89 
90 
91 
92 /****************************************************************************/
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:66
MSNet.h
MSCFModel_KraussX::myTmp1
double myTmp1
extension parameter nr1
Definition: MSCFModel_KraussX.h:84
SUMO_ATTR_TMP2
Definition: SUMOXMLDefinitions.h:551
ACCEL2SPEED
#define ACCEL2SPEED(x)
Definition: SUMOTime.h:53
SUMO_ATTR_TMP1
Definition: SUMOXMLDefinitions.h:550
MSCFModel_Krauss
Krauss car-following model, with acceleration decrease and faster start.
Definition: MSCFModel_Krauss.h:39
MSCFModel_KraussX::duplicate
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
Definition: MSCFModel_KraussX.cpp:50
MSVehicle.h
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:80
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:60
MSCFModel_KraussOrig1::myDawdle
double myDawdle
The vehicle's dawdle-parameter. 0 for no dawdling, 1 for max.
Definition: MSCFModel_KraussOrig1.h:149
MSCFModel_KraussX::dawdleX
double dawdleX(double vOld, double vMin, double vMax, std::mt19937 *rng) const
Applies driver imperfection (dawdling / sigma)
Definition: MSCFModel_KraussX.cpp:62
MSCFModel_KraussX::myTmp2
double myTmp2
Definition: MSCFModel_KraussX.h:85
MSCFModel
The car-following model abstraction.
Definition: MSCFModel.h:57
config.h
MSVehicle::getSpeed
double getSpeed() const
Returns the vehicle's current speed.
Definition: MSVehicle.h:477
MSCFModel::myAccel
double myAccel
The vehicle's maximum acceleration [m/s^2].
Definition: MSCFModel.h:616
MSGlobals::gSemiImplicitEulerUpdate
static bool gSemiImplicitEulerUpdate
Definition: MSGlobals.h:56
MSCFModel_KraussX::~MSCFModel_KraussX
~MSCFModel_KraussX()
Destructor.
Definition: MSCFModel_KraussX.cpp:46
MSCFModel_KraussX.h
MSCFModel_KraussX::MSCFModel_KraussX
MSCFModel_KraussX(const MSVehicleType *vtype)
Constructor.
Definition: MSCFModel_KraussX.cpp:39
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:56
MSAbstractLaneChangeModel.h
MSBaseVehicle::getRNG
std::mt19937 * getRNG() const
Definition: MSBaseVehicle.cpp:712
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80