Eclipse SUMO - Simulation of Urban MObility
MSCFModel_KraussPS.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 
28 #include <utils/geom/GeomHelper.h>
29 #include <microsim/MSVehicle.h>
30 #include <microsim/MSLane.h>
31 #include "MSCFModel_KraussPS.h"
32 
33 
34 // ===========================================================================
35 // method definitions
36 // ===========================================================================
38  MSCFModel_Krauss(vtype) {
39 }
40 
41 
43 
44 
45 double
46 MSCFModel_KraussPS::maxNextSpeed(double speed, const MSVehicle* const veh) const {
47  const double gravity = 9.80665;
48  const double aMax = MAX2(0., getMaxAccel() - gravity * sin(DEG2RAD(veh->getSlope())));
49  // assuming drag force is proportional to the square of speed
50  const double vMax = sqrt(aMax / getMaxAccel()) * myType->getMaxSpeed();
51  return MIN2(speed + (double) ACCEL2SPEED(aMax), vMax);
52 }
53 
54 
55 MSCFModel*
57  return new MSCFModel_KraussPS(vtype);
58 }
59 
60 
61 /****************************************************************************/
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:66
MSCFModel_KraussPS::~MSCFModel_KraussPS
~MSCFModel_KraussPS()
Destructor.
Definition: MSCFModel_KraussPS.cpp:42
MSCFModel::getMaxAccel
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
Definition: MSCFModel.h:210
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:74
MSCFModel_KraussPS::maxNextSpeed
double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
Definition: MSCFModel_KraussPS.cpp:46
ACCEL2SPEED
#define ACCEL2SPEED(x)
Definition: SUMOTime.h:53
MSCFModel_Krauss
Krauss car-following model, with acceleration decrease and faster start.
Definition: MSCFModel_Krauss.h:39
MSCFModel_KraussPS::duplicate
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
Definition: MSCFModel_KraussPS.cpp:56
MSVehicle::getSlope
double getSlope() const
Returns the slope of the road at vehicle's position.
Definition: MSVehicle.cpp:1269
MSVehicle.h
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:80
DEG2RAD
#define DEG2RAD(x)
Definition: GeomHelper.h:38
MSCFModel_KraussPS::MSCFModel_KraussPS
MSCFModel_KraussPS(const MSVehicleType *vtype)
Constructor.
Definition: MSCFModel_KraussPS.cpp:37
MSCFModel_KraussPS.h
MSCFModel::myType
const MSVehicleType * myType
The type to which this model definition belongs to.
Definition: MSCFModel.h:613
MSVehicleType::getMaxSpeed
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
Definition: MSVehicleType.h:162
MSCFModel
The car-following model abstraction.
Definition: MSCFModel.h:57
config.h
GeomHelper.h
MSLane.h
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80