Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSCFModel_KraussPS.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
22// Krauss car-following model, changing accel and speed by slope
23/****************************************************************************/
24#include <config.h>
25
27#include <microsim/MSVehicle.h>
28#include <microsim/MSLane.h>
29#include "MSCFModel_KraussPS.h"
30
31
32// ===========================================================================
33// method definitions
34// ===========================================================================
38
39
41
42
43double
44MSCFModel_KraussPS::maxNextSpeed(double speed, const MSVehicle* const veh) const {
45 const double aBound = getCurrentAccel(speed);
46 const double aMax = MAX2(0., aBound - GRAVITY * sin(DEG2RAD(veh->getSlope())));
47 // special case for bicycles where getMaxSpeed() is not a a technical but a rather an individual power limit
48 const double typeMax = myType->getMaxSpeed() * (veh->getVClass() == SVC_BICYCLE ? veh->getChosenSpeedFactor() : 1);
49 // assuming drag force is proportional to the square of speed
50 const double vMax = MAX2(
51 sqrt(aMax / getMaxAccel()) * typeMax,
52 // prevent emergency braking when inclination changes suddenly (momentum)
53 speed - ACCEL2SPEED(getMaxDecel()));
54 return MAX2(
55 // prevent stalling at low speed
56 aBound / 2,
57 MIN2(speed + ACCEL2SPEED(aMax), vMax));
58}
59
60
63 return new MSCFModel_KraussPS(vtype);
64}
65
66
67/****************************************************************************/
#define DEG2RAD(x)
Definition GeomHelper.h:35
#define GRAVITY
Definition GeomHelper.h:37
#define ACCEL2SPEED(x)
Definition SUMOTime.h:51
@ SVC_BICYCLE
vehicle is a bicycle
T MIN2(T a, T b)
Definition StdDefs.h:80
T MAX2(T a, T b)
Definition StdDefs.h:86
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
Krauss car-following model, with acceleration decrease and faster start.
Krauss car-following model, changing accel and speed by slope.
MSCFModel_KraussPS(const MSVehicleType *vtype)
Constructor.
~MSCFModel_KraussPS()
Destructor.
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
The car-following model abstraction.
Definition MSCFModel.h:57
virtual double getCurrentAccel(const double speed) const
Get the vehicle type's maximum acceleration [m/s^2].
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
Definition MSCFModel.h:261
const MSVehicleType * myType
The type to which this model definition belongs to.
Definition MSCFModel.h:740
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition MSCFModel.h:269
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
double getSlope() const
Returns the slope of the road at vehicle's position in degrees.
The car-following model and parameter.
double getMaxSpeed() const
Get vehicle's (technical) maximum speed [m/s].