SUMO - Simulation of Urban MObility
MSCFModel Class Referenceabstract

The car-following model abstraction. More...

#include <MSCFModel.h>

Inheritance diagram for MSCFModel:
Inheritance graph
Collaboration diagram for MSCFModel:
Collaboration graph

Data Structures

class  VehicleVariables
 

Public Member Functions

SUMOReal getMaxAccel () const
 Get the vehicle type's maximum acceleration [m/s^2]. More...
 
SUMOReal getMaxDecel () const
 Get the vehicle type's maximum deceleration [m/s^2]. More...
 
 MSCFModel (const MSVehicleType *vtype, SUMOReal accel, SUMOReal decel, SUMOReal headwayTime)
 Constructor. More...
 
virtual ~MSCFModel ()
 Destructor. More...
 
Methods to override by model implementation
virtual SUMOReal moveHelper (MSVehicle *const veh, SUMOReal vPos) const
 Applies interaction with stops and lane changing model influences. More...
 
virtual SUMOReal freeSpeed (const MSVehicle *const veh, SUMOReal speed, SUMOReal seen, SUMOReal maxSpeed, const bool onInsertion=false) const
 Computes the vehicle's safe speed without a leader. More...
 
virtual SUMOReal followSpeed (const MSVehicle *const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const =0
 Computes the vehicle's follow speed (no dawdling) More...
 
virtual SUMOReal insertionFollowSpeed (const MSVehicle *const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const
 Computes the vehicle's safe speed (no dawdling) This method is used during the insertion stage. Whereas the method followSpeed returns the desired speed which may be lower than the safe speed, this method only considers safety constraints. More...
 
virtual SUMOReal stopSpeed (const MSVehicle *const veh, const SUMOReal speed, SUMOReal gap2pred) const =0
 Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling) More...
 
virtual SUMOReal interactionGap (const MSVehicle *const veh, SUMOReal vL) const
 Returns the maximum gap at which an interaction between both vehicles occurs. More...
 
virtual int getModelID () const =0
 Returns the model's ID; the XML-Tag number is used. More...
 
virtual MSCFModelduplicate (const MSVehicleType *vtype) const =0
 Duplicates the car-following model. More...
 
virtual VehicleVariablescreateVehicleVariables () const
 Returns model specific values which are stored inside a vehicle and must be used with casting. More...
 
Virtual methods with default implementation
virtual SUMOReal getImperfection () const
 Get the driver's imperfection. More...
 
virtual SUMOReal getHeadwayTime () const
 Get the driver's reaction time [s]. More...
 
Setter methods
virtual void setMaxAccel (SUMOReal accel)
 Sets a new value for maximum acceleration [m/s^2]. More...
 
virtual void setMaxDecel (SUMOReal decel)
 Sets a new value for maximum deceleration [m/s^2]. More...
 
virtual void setImperfection (SUMOReal imperfection)
 Sets a new value for driver imperfection. More...
 
virtual void setHeadwayTime (SUMOReal headwayTime)
 Sets a new value for driver reaction time [s]. More...
 

Protected Member Functions

SUMOReal maximumSafeFollowSpeed (SUMOReal gap, SUMOReal predSpeed, SUMOReal predMaxDecel) const
 Returns the maximum safe velocity for following the given leader. More...
 
SUMOReal maximumSafeStopSpeed (SUMOReal gap) const
 Returns the maximum velocity for stopping within gap This depends stronlgy on the position update model. More...
 

Protected Attributes

SUMOReal myAccel
 The vehicle's maximum acceleration [m/s^2]. More...
 
SUMOReal myDecel
 The vehicle's maximum deceleration [m/s^2]. More...
 
SUMOReal myHeadwayTime
 The driver's desired time headway (aka reaction time tau) [s]. More...
 
const MSVehicleTypemyType
 The type to which this model definition belongs to. More...
 

Currently fixed methods

virtual SUMOReal maxNextSpeed (SUMOReal speed, const MSVehicle *const veh) const
 Returns the maximum speed given the current speed. More...
 
SUMOReal brakeGap (const SUMOReal speed) const
 Returns the distance the vehicle needs to halt including driver's reaction time. More...
 
SUMOReal getSecureGap (const SUMOReal speed, const SUMOReal leaderSpeed, const SUMOReal leaderMaxDecel) const
 Returns the minimum gap to reserve if the leader is braking at maximum. More...
 
SUMOReal getSpeedAfterMaxDecel (SUMOReal v) const
 Returns the velocity after maximum deceleration. More...
 
static SUMOReal brakeGap (const SUMOReal speed, const SUMOReal decel, const SUMOReal headwayTime)
 
static SUMOReal freeSpeed (const SUMOReal decel, const SUMOReal seen, const SUMOReal maxSpeed, const bool onInsertion)
 

Detailed Description

The car-following model abstraction.

MSCFModel is an interface for different car following Models to implement. It provides methods to compute a vehicles velocity for a simulation step.

Definition at line 59 of file MSCFModel.h.

Constructor & Destructor Documentation

MSCFModel::MSCFModel ( const MSVehicleType vtype,
SUMOReal  accel,
SUMOReal  decel,
SUMOReal  headwayTime 
)

Constructor.

Parameters
[in]rvtypea reference to the corresponding vtype

Definition at line 46 of file MSCFModel.cpp.

MSCFModel::~MSCFModel ( )
virtual

Destructor.

Definition at line 52 of file MSCFModel.cpp.

References SUMOReal.

Member Function Documentation

static SUMOReal MSCFModel::brakeGap ( const SUMOReal  speed,
const SUMOReal  decel,
const SUMOReal  headwayTime 
)
inlinestatic

Definition at line 237 of file MSCFModel.h.

References ACCEL2SPEED, SPEED2DIST, and SUMOReal.

virtual VehicleVariables* MSCFModel::createVehicleVariables ( ) const
inlinevirtual

Returns model specific values which are stored inside a vehicle and must be used with casting.

Reimplemented in MSCFModel_SmartSK, MSCFModel_IDM, MSCFModel_Wiedemann, MSCFModel_PWag2009, and MSCFModel_Kerner.

Definition at line 167 of file MSCFModel.h.

Referenced by MSVehicle::MSVehicle().

virtual MSCFModel* MSCFModel::duplicate ( const MSVehicleType vtype) const
pure virtual

Duplicates the car-following model.

Parameters
[in]vtypeThe vehicle type this model belongs to (1:1)
Returns
A duplicate of this car-following model

Implemented in MSCFModel_KraussOrig1, MSCFModel_SmartSK, MSCFModel_Daniel1, MSCFModel_IDM, MSCFModel_Wiedemann, MSCFModel_PWag2009, MSCFModel_Kerner, MSCFModel_Krauss, MSCFModel_KraussPS, and MSCFModel_KraussAccelBound.

Referenced by MSVehicleType::build().

virtual SUMOReal MSCFModel::followSpeed ( const MSVehicle *const  veh,
SUMOReal  speed,
SUMOReal  gap2pred,
SUMOReal  predSpeed,
SUMOReal  predMaxDecel 
) const
pure virtual

Computes the vehicle's follow speed (no dawdling)

Returns the velocity of the vehicle in dependence to the vehicle's and its leader's values and the distance between them.

Parameters
[in]vehThe vehicle (EGO)
[in]speedThe vehicle's speed
[in]gap2predThe (netto) distance to the LEADER
[in]predSpeedThe speed of LEADER
Returns
EGO's safe speed

Implemented in MSCFModel_IDM, MSCFModel_Wiedemann, MSCFModel_Krauss, MSCFModel_KraussOrig1, MSCFModel_PWag2009, MSCFModel_SmartSK, MSCFModel_Daniel1, and MSCFModel_Kerner.

Referenced by MSLCM_JE2013::_wantsChange(), MSLCM_LC2013::_wantsChange(), MSVehicle::getSafeFollowSpeed(), MSLink::getZipperSpeed(), MSLCM_DK2008::informBlocker(), MSLCM_JE2013::informFollower(), MSLCM_LC2013::informFollower(), MSLCM_JE2013::informLeader(), MSLCM_LC2013::informLeader(), MSLCM_JE2013::slowDownForBlocked(), MSLCM_LC2013::slowDownForBlocked(), MSLCM_DK2008::wantsChangeToLeft(), and MSLCM_DK2008::wantsChangeToRight().

SUMOReal MSCFModel::freeSpeed ( const MSVehicle *const  veh,
SUMOReal  speed,
SUMOReal  seen,
SUMOReal  maxSpeed,
const bool  onInsertion = false 
) const
virtual

Computes the vehicle's safe speed without a leader.

Returns the velocity of the vehicle in dependence to the length of the free street and the target velocity at the end of the free range. If onInsertion is true, the vehicle may still brake before the next movement.

Parameters
[in]vehThe vehicle (EGO)
[in]speedThe vehicle's speed
[in]seenThe look ahead distance
[in]maxSpeedThe maximum allowed speed
[in]onInsertionwhether speed at insertion is asked for
Returns
EGO's safe speed

Definition at line 92 of file MSCFModel.cpp.

References myDecel, and SUMOReal.

Referenced by MSLane::isInsertionSuccess(), and MSVehicle::planMoveInternal().

static SUMOReal MSCFModel::freeSpeed ( const SUMOReal  decel,
const SUMOReal  seen,
const SUMOReal  maxSpeed,
const bool  onInsertion 
)
inlinestatic

Definition at line 246 of file MSCFModel.h.

References ACCEL2DIST, ACCEL2SPEED, DIST2SPEED, MAX2(), SPEED2DIST, and SUMOReal.

virtual SUMOReal MSCFModel::getHeadwayTime ( ) const
inlinevirtual
virtual SUMOReal MSCFModel::getImperfection ( ) const
inlinevirtual

Get the driver's imperfection.

Returns
The imperfection of drivers of this class

Reimplemented in MSCFModel_KraussOrig1, MSCFModel_PWag2009, MSCFModel_SmartSK, and MSCFModel_Daniel1.

Definition at line 195 of file MSCFModel.h.

Referenced by TraCIServerAPI_VehicleType::getVariable().

SUMOReal MSCFModel::getMaxAccel ( ) const
inline

Get the vehicle type's maximum acceleration [m/s^2].

Returns
The maximum acceleration (in m/s^2) of vehicles of this class

Definition at line 176 of file MSCFModel.h.

References myAccel.

Referenced by MSVehicle::estimateLeaveSpeed(), TraCIServerAPI_VehicleType::getVariable(), MSCFModel_KraussPS::maxNextSpeed(), maxNextSpeed(), MSVehicle::planMoveInternal(), and MSMeanData_Emissions::MSLaneMeanDataValues::write().

virtual int MSCFModel::getModelID ( ) const
pure virtual
SUMOReal MSCFModel::getSecureGap ( const SUMOReal  speed,
const SUMOReal  leaderSpeed,
const SUMOReal  leaderMaxDecel 
) const
inline

Returns the minimum gap to reserve if the leader is braking at maximum.

Parameters
[in]speedEGO's speed
[in]leaderSpeedLEADER's speed
[in]leaderMaxDecelLEADER's max. deceleration rate

Definition at line 270 of file MSCFModel.h.

References brakeGap(), MAX2(), MIN2(), myDecel, myHeadwayTime, and SUMOReal.

Referenced by MSLCM_JE2013::_wantsChange(), MSLCM_LC2013::_wantsChange(), MSLaneChanger::checkChange(), MSLane::freeInsertion(), MSLane::getMissingRearGap(), MSLCM_DK2008::informBlocker(), MSLCM_JE2013::informFollower(), MSLCM_LC2013::informFollower(), MSLCM_JE2013::informLeader(), MSLCM_LC2013::informLeader(), and MSLane::isInsertionSuccess().

SUMOReal MSCFModel::getSpeedAfterMaxDecel ( SUMOReal  v) const
inline

Returns the velocity after maximum deceleration.

Parameters
[in]vThe velocity
Returns
The velocity after maximum deceleration

Definition at line 283 of file MSCFModel.h.

References ACCEL2SPEED, MAX2(), myDecel, and SUMOReal.

Referenced by MSCFModel_SmartSK::followSpeed(), MSCFModel_Daniel1::moveHelper(), MSCFModel_SmartSK::moveHelper(), MSCFModel_KraussOrig1::moveHelper(), moveHelper(), MSVehicle::planMoveInternal(), MSCFModel_SmartSK::stopSpeed(), and MSCFModel_Wiedemann::stopSpeed().

SUMOReal MSCFModel::insertionFollowSpeed ( const MSVehicle *const  veh,
SUMOReal  speed,
SUMOReal  gap2pred,
SUMOReal  predSpeed,
SUMOReal  predMaxDecel 
) const
virtual

Computes the vehicle's safe speed (no dawdling) This method is used during the insertion stage. Whereas the method followSpeed returns the desired speed which may be lower than the safe speed, this method only considers safety constraints.

Returns the velocity of the vehicle in dependence to the vehicle's and its leader's values and the distance between them.

Parameters
[in]vehThe vehicle (EGO)
[in]speedThe vehicle's speed
[in]gap2predThe (netto) distance to the LEADER
[in]predSpeedThe speed of LEADER
Returns
EGO's safe speed

Reimplemented in MSCFModel_KraussOrig1.

Definition at line 98 of file MSCFModel.cpp.

References maximumSafeFollowSpeed(), and SUMOReal.

Referenced by MSLane::freeInsertion(), MSLane::getCriticalLeader(), MSLane::isInsertionSuccess(), and MSLane::pWagGenericInsertion().

SUMOReal MSCFModel::interactionGap ( const MSVehicle *const  veh,
SUMOReal  vL 
) const
virtual

Returns the maximum gap at which an interaction between both vehicles occurs.

"interaction" means that the LEADER influences EGO's speed.

Parameters
[in]vehThe EGO vehicle
[in]vLLEADER's speed
Returns
The interaction gap
Todo:
evaluate signature

Reimplemented in MSCFModel_IDM, and MSCFModel_Wiedemann.

Definition at line 71 of file MSCFModel.cpp.

References MSVehicle::getLane(), MSVehicle::getSpeed(), MSLane::getVehicleMaxSpeed(), MAX2(), maxNextSpeed(), MIN2(), myDecel, myHeadwayTime, SPEED2DIST, and SUMOReal.

Referenced by MSAbstractLaneChangeModel::predInteraction().

SUMOReal MSCFModel::maximumSafeFollowSpeed ( SUMOReal  gap,
SUMOReal  predSpeed,
SUMOReal  predMaxDecel 
) const
protected

Returns the maximum safe velocity for following the given leader.

Parameters
[in]gap2predThe (netto) distance to the LEADER
[in]predSpeedThe LEADER's speed
[in]predMaxDecelThe LEADER's maximum deceleration
Returns
the safe velocity

Returns the SK-vsafe.

Definition at line 134 of file MSCFModel.cpp.

References brakeGap(), ISNAN(), MAX2(), maximumSafeStopSpeed(), myDecel, and SUMOReal.

Referenced by MSCFModel_Krauss::followSpeed(), insertionFollowSpeed(), and setHeadwayTime().

SUMOReal MSCFModel::maximumSafeStopSpeed ( SUMOReal  gap) const
protected

Returns the maximum velocity for stopping within gap This depends stronlgy on the position update model.

Parameters
[in]gapThe (netto) distance to the LEADER

Definition at line 105 of file MSCFModel.cpp.

References ACCEL2SPEED, myDecel, myHeadwayTime, NUMERICAL_EPS, SUMOReal, and TS.

Referenced by maximumSafeFollowSpeed(), setHeadwayTime(), and MSCFModel_Krauss::stopSpeed().

SUMOReal MSCFModel::maxNextSpeed ( SUMOReal  speed,
const MSVehicle *const  veh 
) const
virtual

Returns the maximum speed given the current speed.

The implementation of this method must take into account the time step duration.

Justification: Due to air brake or other influences, the vehicle's next maximum speed may depend on the vehicle's current speed (given).

Parameters
[in]speedThe vehicle's current speed
[in]speedThe vehicle itself, for obtaining other values
Returns
The maximum possible speed for the next step

Reimplemented in MSCFModel_KraussPS, and MSCFModel_KraussAccelBound.

Definition at line 86 of file MSCFModel.cpp.

References ACCEL2SPEED, getMaxAccel(), MSVehicleType::getMaxSpeed(), MIN2(), myType, and SUMOReal.

Referenced by MSVehicle::executeMove(), MSCFModel_Kerner::followSpeed(), MSCFModel_Daniel1::followSpeed(), MSCFModel_KraussOrig1::followSpeed(), MSCFModel_SmartSK::followSpeed(), MSCFModel_Krauss::followSpeed(), getHeadwayTime(), interactionGap(), MSCFModel_Daniel1::moveHelper(), MSCFModel_KraussOrig1::moveHelper(), MSCFModel_SmartSK::moveHelper(), moveHelper(), MSLCM_DK2008::patchSpeed(), MSVehicle::planMoveInternal(), MSCFModel_Krauss::stopSpeed(), MSCFModel_Kerner::stopSpeed(), MSCFModel_Daniel1::stopSpeed(), MSCFModel_KraussOrig1::stopSpeed(), MSCFModel_SmartSK::stopSpeed(), and MSCFModel_Wiedemann::stopSpeed().

SUMOReal MSCFModel::moveHelper ( MSVehicle *const  veh,
SUMOReal  vPos 
) const
virtual

Applies interaction with stops and lane changing model influences.

Parameters
[in]vehThe ego vehicle
[in]vPosThe possible velocity
Returns
The velocity after applying interactions with stops and lane change model influences

Reimplemented in MSCFModel_IDM, MSCFModel_Wiedemann, MSCFModel_KraussOrig1, MSCFModel_PWag2009, MSCFModel_SmartSK, MSCFModel_Daniel1, and MSCFModel_Kerner.

Definition at line 56 of file MSCFModel.cpp.

References MSVehicle::getLane(), MSVehicle::getLaneChangeModel(), MSVehicle::getSpeed(), getSpeedAfterMaxDecel(), MSLane::getVehicleMaxSpeed(), maxNextSpeed(), MIN2(), MIN3(), MSAbstractLaneChangeModel::patchSpeed(), MSVehicle::processNextStop(), and SUMOReal.

Referenced by MSCFModel_Kerner::moveHelper(), MSCFModel_PWag2009::moveHelper(), MSCFModel_Wiedemann::moveHelper(), and MSCFModel_IDM::moveHelper().

virtual void MSCFModel::setHeadwayTime ( SUMOReal  headwayTime)
inlinevirtual

Sets a new value for driver reaction time [s].

Parameters
[in]headwayTimeThe new driver reaction time (in s)

Reimplemented in MSCFModel_KraussOrig1, MSCFModel_SmartSK, and MSCFModel_Daniel1.

Definition at line 319 of file MSCFModel.h.

References maximumSafeFollowSpeed(), maximumSafeStopSpeed(), myHeadwayTime, and SUMOReal.

Referenced by TraCIServerAPI_VehicleType::setVariable().

virtual void MSCFModel::setImperfection ( SUMOReal  imperfection)
inlinevirtual

Sets a new value for driver imperfection.

Parameters
[in]accelThe new driver imperfection

Reimplemented in MSCFModel_KraussOrig1, MSCFModel_SmartSK, and MSCFModel_Daniel1.

Definition at line 311 of file MSCFModel.h.

References UNUSED_PARAMETER.

Referenced by TraCIServerAPI_VehicleType::setVariable().

virtual void MSCFModel::setMaxAccel ( SUMOReal  accel)
inlinevirtual

Sets a new value for maximum acceleration [m/s^2].

Parameters
[in]accelThe new acceleration in m/s^2

Definition at line 295 of file MSCFModel.h.

References myAccel.

Referenced by TraCIServerAPI_VehicleType::setVariable().

virtual void MSCFModel::setMaxDecel ( SUMOReal  decel)
inlinevirtual

Sets a new value for maximum deceleration [m/s^2].

Parameters
[in]accelThe new deceleration in m/s^2

Reimplemented in MSCFModel_KraussOrig1, MSCFModel_SmartSK, and MSCFModel_Daniel1.

Definition at line 303 of file MSCFModel.h.

References myDecel.

Referenced by TraCIServerAPI_VehicleType::setVariable().

virtual SUMOReal MSCFModel::stopSpeed ( const MSVehicle *const  veh,
const SUMOReal  speed,
SUMOReal  gap2pred 
) const
pure virtual

Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)

Returns the velocity of the vehicle when approaching a static object (such as the end of a lane) assuming no reaction time is needed.

Parameters
[in]vehThe vehicle (EGO)
[in]gap2predThe (netto) distance to the the obstacle
Returns
EGO's safe speed for approaching a non-moving obstacle
Todo:
generic Interface, models can call for the values they need

Implemented in MSCFModel_IDM, MSCFModel_Wiedemann, MSCFModel_KraussOrig1, MSCFModel_PWag2009, MSCFModel_SmartSK, MSCFModel_Daniel1, MSCFModel_Kerner, and MSCFModel_Krauss.

Referenced by MSLCM_JE2013::_patchSpeed(), MSLCM_LC2013::_patchSpeed(), MSVehicle::getSafeFollowSpeed(), MSLCM_JE2013::informLeader(), MSLCM_LC2013::informLeader(), MSLane::isInsertionSuccess(), MSLCM_DK2008::patchSpeed(), MSVehicle::planMoveInternal(), and MSVehicle::processNextStop().

Field Documentation

const MSVehicleType* MSCFModel::myType
protected

The type to which this model definition belongs to.

Definition at line 342 of file MSCFModel.h.

Referenced by MSCFModel_Wiedemann::_v(), MSCFModel_IDM::_v(), MSCFModel_KraussPS::maxNextSpeed(), and maxNextSpeed().


The documentation for this class was generated from the following files: