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