MSCFModel Class Reference

#include <MSCFModel.h>

Inheritance diagram for MSCFModel:

MSCFModel_IDM MSCFModel_Kerner MSCFModel_Krauss MSCFModel_KraussOrig1 MSCFModel_PWag2009

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 55 of file MSCFModel.h.


Public Member Functions

 MSCFModel (const MSVehicleType *vtype, SUMOReal decel) throw ()
 Constructor.
virtual ~MSCFModel () throw ()
 Destructor.
Currently fixed methods
SUMOReal brakeGap (SUMOReal speed) const throw ()
 Returns the distance the vehicle needs to halt including driver's reaction time.
SUMOReal getMaxDecel () const throw ()
 Get the vehicle's maximum deceleration [m/s^2].
SUMOReal getSecureGap (const SUMOReal speed, const SUMOReal leaderSpeedAfterDecel) const throw ()
 Returns the minimum gap to reserve if the leader is braking at maximum.
SUMOReal getSpeedAfterMaxDecel (SUMOReal v) const throw ()
 Returns the velocity after maximum deceleration.
void leftVehicleVsafe (const MSVehicle *const ego, const MSVehicle *const neigh, SUMOReal &vSafe) const throw ()
 Incorporates the influence of the vehicle on the left lane.
SUMOReal maxNextSpeed (SUMOReal speed) const throw ()
 Returns the maximum speed given the current speed.
Methods to override by model implementation
virtual SUMOReal ffeS (const MSVehicle *const veh, SUMOReal gap2pred) const =0 throw ()
 Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling).
virtual SUMOReal ffeV (const MSVehicle *const veh, const MSVehicle *const pred) const =0 throw ()
 Computes the vehicle's safe speed (no dawdling).
virtual SUMOReal ffeV (const MSVehicle *const veh, SUMOReal gap2pred, SUMOReal predSpeed) const =0 throw ()
 Computes the vehicle's safe speed (no dawdling).
virtual SUMOReal ffeV (const MSVehicle *const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed) const =0 throw ()
 Computes the vehicle's safe speed (no dawdling).
virtual SUMOReal getMaxAccel (SUMOReal v) const =0 throw ()
 Get the vehicle's maximum acceleration [m/s^2].
virtual int getModelID () const =0 throw ()
 Returns the model's ID; the XML-Tag number is used.
virtual bool hasSafeGap (SUMOReal speed, SUMOReal gap, SUMOReal predSpeed, SUMOReal laneMaxSpeed) const =0 throw ()
 Returns whether the given gap is safe.
virtual SUMOReal interactionGap (const MSVehicle *const veh, SUMOReal vL) const =0 throw ()
 Returns the maximum gap at which an interaction between both vehicles occurs.
virtual SUMOReal moveHelper (MSVehicle *const veh, const MSLane *const lane, SUMOReal vPos) const =0 throw ()
 Applies interaction with stops and lane changing model influences.
virtual void saveState (std::ostream &os)
 Saves the model's definition into the state.
Virtual methods with default implementation
virtual SUMOReal getTau () const throw ()
 Get the driver's reaction time [s].

Protected Attributes

SUMOReal myDecel
 The vehicle's maximum deceleration [m/s^2].
SUMOReal myInverseTwoDecel
 The precomputed value for 1/(2*d).
const MSVehicleTypemyType
 The type to which this model definition belongs to.

Constructor & Destructor Documentation

MSCFModel::MSCFModel ( const MSVehicleType vtype,
SUMOReal  decel 
) throw ()

Constructor.

Parameters:
[in] rvtype a reference to the corresponding vtype

Definition at line 38 of file MSCFModel.cpp.

References SUMOReal.

00039         : myType(vtype), myDecel(decel) {
00040     myInverseTwoDecel = SUMOReal(1) / (SUMOReal(2) * decel);
00041 }

MSCFModel::~MSCFModel (  )  throw () [virtual]

Destructor.

Definition at line 44 of file MSCFModel.cpp.

00044 {}


Member Function Documentation

SUMOReal MSCFModel::brakeGap ( SUMOReal  speed  )  const throw ()

Returns the distance the vehicle needs to halt including driver's reaction time.

Parameters:
[in] speed The vehicle's current speed
Returns:
The distance needed to halt

Definition at line 66 of file MSCFModel.cpp.

References getTau(), and myInverseTwoDecel.

Referenced by MSVehicle::checkRewindLinkLanes(), MSLane::getLeaderOnConsecutive(), getMaxSpeedRegardingNextLanes(), MSLaneChanger::getRealLeader(), MSLane::isEmissionSuccess(), and MSVehicle::vsafeCriticalCont().

00066                                                 {
00067     return speed * speed * myInverseTwoDecel + speed * getTau();
00068 }

virtual SUMOReal MSCFModel::ffeS ( const MSVehicle *const   veh,
SUMOReal  gap2pred 
) const throw () [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] veh The vehicle (EGO)
[in] gap2pred The (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_Kerner, MSCFModel_Krauss, MSCFModel_KraussOrig1, and MSCFModel_PWag2009.

Referenced by MSVehicle::moveRegardingCritical(), MSVehicle::processNextStop(), and MSVehicle::vsafeCriticalCont().

virtual SUMOReal MSCFModel::ffeV ( const MSVehicle *const   veh,
const MSVehicle *const   pred 
) const throw () [pure virtual]

Computes the vehicle's safe 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] veh The vehicle (EGO)
[in] pred The LEADER
Returns:
EGO's safe speed
Todo:
generic Interface, models can call for the values they need

Implemented in MSCFModel_IDM, MSCFModel_Kerner, MSCFModel_Krauss, MSCFModel_KraussOrig1, and MSCFModel_PWag2009.

virtual SUMOReal MSCFModel::ffeV ( const MSVehicle *const   veh,
SUMOReal  gap2pred,
SUMOReal  predSpeed 
) const throw () [pure virtual]

Computes the vehicle's safe 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] veh The vehicle (EGO)
[in] gap2pred The (netto) distance to the LEADER
[in] predSpeed The speed of LEADER
Returns:
EGO's safe speed
Todo:
used by MSLCM_DK2004, allows hypothetic values of gap2pred and predSpeed

Implemented in MSCFModel_IDM, MSCFModel_Kerner, MSCFModel_Krauss, MSCFModel_KraussOrig1, and MSCFModel_PWag2009.

virtual SUMOReal MSCFModel::ffeV ( const MSVehicle *const   veh,
SUMOReal  speed,
SUMOReal  gap2pred,
SUMOReal  predSpeed 
) const throw () [pure virtual]

Computes the vehicle's safe 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] veh The vehicle (EGO)
[in] speed The vehicle's speed
[in] gap2pred The (netto) distance to the LEADER
[in] predSpeed The speed of LEADER
Returns:
EGO's safe speed
Todo:
used by MSLane, can hopefully be removed eventually

Implemented in MSCFModel_IDM, MSCFModel_Kerner, MSCFModel_Krauss, MSCFModel_KraussOrig1, and MSCFModel_PWag2009.

Referenced by getMaxSpeedRegardingNextLanes(), MSLCM_DK2004::informBlocker(), MSLane::isEmissionSuccess(), leftVehicleVsafe(), MSVehicle::moveRegardingCritical(), MSVehicle::vsafeCriticalCont(), MSLCM_DK2004::wantsChangeToLeft(), and MSLCM_DK2004::wantsChangeToRight().

virtual SUMOReal MSCFModel::getMaxAccel ( SUMOReal  v  )  const throw () [pure virtual]

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

As some models describe that a vehicle is accelerating slower the higher its speed is, the velocity is given.

Parameters:
[in] v The vehicle's velocity
Returns:
The maximum acceleration

Implemented in MSCFModel_IDM, MSCFModel_Kerner, MSCFModel_Krauss, MSCFModel_KraussOrig1, and MSCFModel_PWag2009.

Referenced by maxNextSpeed(), and TraCIServerAPI_VehicleType::processGet().

SUMOReal MSCFModel::getMaxDecel (  )  const throw () [inline]

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

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

Definition at line 218 of file MSCFModel.h.

References myDecel.

Referenced by getSecureGap(), MSLCM_DK2004::informBlocker(), TraCIServerAPI_VehicleType::processGet(), MSVehicle::vsafeCriticalCont(), MSLCM_DK2004::wantsChangeToLeft(), and MSLCM_DK2004::wantsChangeToRight().

00218                                          {
00219         return myDecel;
00220     }

virtual int MSCFModel::getModelID (  )  const throw () [pure virtual]

Returns the model's ID; the XML-Tag number is used.

Returns:
The model's ID

Implemented in MSCFModel_IDM, MSCFModel_Kerner, MSCFModel_Krauss, MSCFModel_KraussOrig1, and MSCFModel_PWag2009.

Referenced by MSVehicleType::saveState().

SUMOReal MSCFModel::getSecureGap ( const SUMOReal  speed,
const SUMOReal  leaderSpeedAfterDecel 
) const throw () [inline]

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

Parameters:
[in] speed EGO's speed
[in] leaderSpeedAfterDecel LEADER's speed after he has decelerated with max. deceleration rate

Definition at line 234 of file MSCFModel.h.

References getMaxDecel(), getTau(), and SUMOReal.

Referenced by MSLane::freeEmit(), and MSLane::isEmissionSuccess().

00234                                                                                                     {
00235         const SUMOReal speedDiff = speed - leaderSpeedAfterDecel;
00236         return speedDiff * speedDiff / getMaxDecel() + speed * getTau();
00237     }

SUMOReal MSCFModel::getSpeedAfterMaxDecel ( SUMOReal  v  )  const throw () [inline]

Returns the velocity after maximum deceleration.

Parameters:
[in] v The velocity
Returns:
The velocity after maximum deceleration

Definition at line 244 of file MSCFModel.h.

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

Referenced by MSLane::freeEmit(), MSCFModel_PWag2009::hasSafeGap(), MSCFModel_KraussOrig1::hasSafeGap(), MSCFModel_Krauss::hasSafeGap(), MSCFModel_Kerner::hasSafeGap(), MSCFModel_IDM::hasSafeGap(), and MSLane::isEmissionSuccess().

00244                                                              {
00245         return MAX2((SUMOReal) 0, v - (SUMOReal) ACCEL2SPEED(myDecel));
00246     }

virtual SUMOReal MSCFModel::getTau (  )  const throw () [inline, virtual]

Get the driver's reaction time [s].

Returns:
The reaction time of this class' drivers in s

Reimplemented in MSCFModel_IDM, MSCFModel_Kerner, MSCFModel_Krauss, MSCFModel_KraussOrig1, and MSCFModel_PWag2009.

Definition at line 181 of file MSCFModel.h.

Referenced by brakeGap(), getSecureGap(), and TraCIServerAPI_VehicleType::processGet().

00181                                             {
00182         return 1.;
00183     }

virtual bool MSCFModel::hasSafeGap ( SUMOReal  speed,
SUMOReal  gap,
SUMOReal  predSpeed,
SUMOReal  laneMaxSpeed 
) const throw () [pure virtual]

Returns whether the given gap is safe.

"safe" means that no collision occur when using the gap, given other values.

Parameters:
[in] speed EGO's speed
[in] gap The (netto) gap between LEADER and EGO
[in] predSpeed LEADER's speed
[in] laneMaxSpeed The maximum velocity allowed on the lane
Returns:
Whether the given gap is safe
Todo:
evaluate signature

Implemented in MSCFModel_IDM, MSCFModel_Kerner, MSCFModel_Krauss, MSCFModel_KraussOrig1, and MSCFModel_PWag2009.

Referenced by MSLane::getFollowerOnConsecutive(), MSLCM_DK2004::informBlocker(), and MSLaneChanger::setIsSafeChange().

virtual SUMOReal MSCFModel::interactionGap ( const MSVehicle *const   veh,
SUMOReal  vL 
) const throw () [pure virtual]

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

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

Parameters:
[in] veh The EGO vehicle
[in] vL LEADER's speed
Returns:
The interaction gap
Todo:
evaluate signature

Implemented in MSCFModel_IDM, MSCFModel_Kerner, MSCFModel_Krauss, MSCFModel_KraussOrig1, and MSCFModel_PWag2009.

Referenced by MSAbstractLaneChangeModel::predInteraction().

void MSCFModel::leftVehicleVsafe ( const MSVehicle *const   ego,
const MSVehicle *const   neigh,
SUMOReal &  vSafe 
) const throw ()

Incorporates the influence of the vehicle on the left lane.

In Germany, vehicles on the right lane must not pass a vehicle on the lane left to the if the allowed velocity>60km/h

Parameters:
[in] ego The ego vehicle
[in] neigh The neighbor vehicle on the left lane
[in,out] vSafe Current vSafe; may be adapted due to the left neighbor

Definition at line 48 of file MSCFModel.cpp.

References ffeV(), MAX2(), MIN2(), and SUMOReal.

Referenced by MSVehicle::moveRegardingCritical().

00048                                                                                                                      {
00049     if (neigh!=0&&neigh->getSpeed()>60./3.6) {
00050         SUMOReal mgap = MAX2((SUMOReal) 0, neigh->getPositionOnLane()-neigh->getVehicleType().getLength()-ego->getPositionOnLane());
00051         SUMOReal nVSafe = ffeV(ego, mgap, neigh->getSpeed());
00052         if (mgap-neigh->getSpeed()>=0) {
00053             vSafe = MIN2(vSafe, nVSafe);
00054         }
00055     }
00056 }

SUMOReal MSCFModel::maxNextSpeed ( SUMOReal  speed  )  const throw ()

virtual SUMOReal MSCFModel::moveHelper ( MSVehicle *const   veh,
const MSLane *const   lane,
SUMOReal  vPos 
) const throw () [pure virtual]

Applies interaction with stops and lane changing model influences.

Parameters:
[in] veh The ego vehicle
[in] lane The lane ego is at
[in] vPos The possible velocity
Returns:
The velocity after applying interactions with stops and lane change model influences

Implemented in MSCFModel_IDM, MSCFModel_Kerner, MSCFModel_Krauss, MSCFModel_KraussOrig1, and MSCFModel_PWag2009.

Referenced by MSVehicle::moveFirstChecked().

void MSCFModel::saveState ( std::ostream &  os  )  [virtual]

Saves the model's definition into the state.

Parameters:
[in] os The output to write the definition into

Definition at line 71 of file MSCFModel.cpp.

00071 {}


Field Documentation

SUMOReal MSCFModel::myDecel [protected]

SUMOReal MSCFModel::myInverseTwoDecel [protected]

const MSVehicleType* MSCFModel::myType [protected]

The type to which this model definition belongs to.

Definition at line 252 of file MSCFModel.h.

Referenced by MSCFModel_IDM::desiredSpeed(), MSCFModel_Krauss::getMaxAccel(), and maxNextSpeed().


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

Generated on Wed May 5 00:06:47 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6