MSCFModel_Kerner Class Reference

#include <MSCFModel_Kerner.h>

Inheritance diagram for MSCFModel_Kerner:

MSCFModel

Detailed Description

car-following model by B. Kerner

See also:
MSCFModel

Definition at line 42 of file MSCFModel_Kerner.h.


Public Member Functions

 MSCFModel_Kerner (const MSVehicleType *vtype, SUMOReal accel, SUMOReal decel, SUMOReal tau, SUMOReal k, SUMOReal phi) throw ()
 Constructor.
 ~MSCFModel_Kerner () 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.
Implementations of the MSCFModel interface
SUMOReal ffeS (const MSVehicle *const veh, SUMOReal gap2pred) const throw ()
 Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling).
SUMOReal ffeV (const MSVehicle *const veh, const MSVehicle *const pred) const throw ()
 Computes the vehicle's safe speed (no dawdling).
SUMOReal ffeV (const MSVehicle *const veh, SUMOReal gap2pred, SUMOReal predSpeed) const throw ()
 Computes the vehicle's safe speed (no dawdling).
SUMOReal ffeV (const MSVehicle *const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed) const throw ()
 Computes the vehicle's safe speed (no dawdling).
SUMOReal getMaxAccel (SUMOReal v) const throw ()
 Get the vehicle's maximum acceleration [m/s^2].
int getModelID () const throw ()
 Returns the model's name.
SUMOReal getTau () const throw ()
 Get the driver's reaction time [s].
bool hasSafeGap (SUMOReal speed, SUMOReal gap, SUMOReal predSpeed, SUMOReal laneMaxSpeed) const throw ()
 Returns whether the given gap is safe.
SUMOReal interactionGap (const MSVehicle *const veh, SUMOReal vL) const throw ()
 Returns the maximum gap at which an interaction between both vehicles occurs.
SUMOReal moveHelper (MSVehicle *const veh, const MSLane *const lane, SUMOReal vPos) const throw ()
 Applies interaction with stops and lane changing model influences.
Methods to override by model implementation
virtual void saveState (std::ostream &os)
 Saves the model's definition into the state.

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.

Private Member Functions

SUMOReal _v (SUMOReal speed, SUMOReal vfree, SUMOReal gap, SUMOReal predSpeed) const throw ()
 Returns the "safe" velocity.

Private Attributes

model parameter
SUMOReal myAccel
 The vehicle's maximum acceleration [m/s^2].
SUMOReal myK
 The driver's reaction time [s].
SUMOReal myPhi
 The driver's reaction time [s].
SUMOReal myTau
 The driver's reaction time [s].
SUMOReal myTauDecel
 The precomputed value for myDecel*myTau.

Constructor & Destructor Documentation

MSCFModel_Kerner::MSCFModel_Kerner ( const MSVehicleType vtype,
SUMOReal  accel,
SUMOReal  decel,
SUMOReal  tau,
SUMOReal  k,
SUMOReal  phi 
) throw ()

Constructor.

Parameters:
[in] accel The maximum acceleration
[in] decel The maximum deceleration
[in] dawdle The driver imperfection
[in] tau The driver's reaction time

Definition at line 40 of file MSCFModel_Kerner.cpp.

00042         : MSCFModel(vtype, decel), myAccel(accel), myTau(tau), myK(k), myPhi(phi) {
00043 
00044     myTauDecel = decel * myTau;
00045 }

MSCFModel_Kerner::~MSCFModel_Kerner (  )  throw ()

Destructor.

Definition at line 48 of file MSCFModel_Kerner.cpp.

00048 {}


Member Function Documentation

SUMOReal MSCFModel_Kerner::_v ( SUMOReal  speed,
SUMOReal  vfree,
SUMOReal  gap,
SUMOReal  predSpeed 
) const throw () [private]

Returns the "safe" velocity.

Parameters:
[in] gap2pred The (netto) distance to the LEADER
[in] predSpeed The LEADER's speed
Returns:
the safe velocity

Definition at line 125 of file MSCFModel_Kerner.cpp.

References ACCEL2SPEED, MAX2(), MIN2(), MIN3(), MIN4(), myAccel, MSCFModel::myDecel, myK, myPhi, myTauDecel, RandHelper::rand(), SPEED2DIST, and SUMOReal.

Referenced by ffeS(), ffeV(), and hasSafeGap().

00125                                                                                                    {
00126     if (predSpeed==0&&gap<0.01) {
00127         return 0;
00128     }
00129     // !!! in the following, the prior step is not considered!!!
00130     SUMOReal G = MAX2((SUMOReal) 0, (SUMOReal)(SPEED2DIST(myK*speed)+myPhi/myAccel*speed*(speed-predSpeed)));
00131     SUMOReal vcond = gap>G ? speed+ACCEL2SPEED(myAccel) : speed+MAX2(ACCEL2SPEED(-myDecel), MIN2(ACCEL2SPEED(myAccel), predSpeed-speed));
00132     SUMOReal vsafe = (SUMOReal)(-1. * myTauDecel + sqrt(myTauDecel*myTauDecel + (predSpeed*predSpeed) + (2. * myDecel * gap)));
00133     SUMOReal va = MAX2((SUMOReal) 0, MIN3(vfree, vsafe, vcond)) + RandHelper::rand();
00134     SUMOReal v = MAX2((SUMOReal) 0, MIN4(vfree, va, speed+ACCEL2SPEED(myAccel), vsafe));
00135     return v;
00136 }

SUMOReal MSCFModel::brakeGap ( SUMOReal  speed  )  const throw () [inherited]

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 MSCFModel::getTau(), and MSCFModel::myInverseTwoDecel.

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

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

SUMOReal MSCFModel_Kerner::ffeS ( const MSVehicle *const   veh,
SUMOReal  gap2pred 
) const throw () [virtual]

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

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
See also:
MSCFModel::ffeS
Todo:
generic Interface, models can call for the values they need

Implements MSCFModel.

Definition at line 92 of file MSCFModel_Kerner.cpp.

References _v(), MSCFModel::maxNextSpeed(), MIN2(), and SUMOReal.

00092                                                                               {
00093     SUMOReal speed = veh->getSpeed();
00094     return MIN2(_v(speed, maxNextSpeed(speed), gap, 0), maxNextSpeed(speed));
00095 }

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

Computes the vehicle's safe speed (no dawdling).

Parameters:
[in] veh The vehicle (EGO)
[in] pred The LEADER
Returns:
EGO's safe speed
See also:
MSCFModel::ffeV
Todo:
generic Interface, models can call for the values they need

Implements MSCFModel.

Definition at line 85 of file MSCFModel_Kerner.cpp.

References _v(), MSCFModel::maxNextSpeed(), MIN2(), and SUMOReal.

00085                                                                                        {
00086     SUMOReal speed = veh->getSpeed();
00087     return MIN2(_v(speed, maxNextSpeed(speed), veh->gap2pred(*pred), pred->getSpeed()), maxNextSpeed(speed));
00088 }

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

Computes the vehicle's safe speed (no dawdling).

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
See also:
MSCFModel::ffeV
Todo:
used by MSLCM_DK2004, allows hypothetic values of gap2pred and predSpeed

Implements MSCFModel.

Definition at line 78 of file MSCFModel_Kerner.cpp.

References _v(), MSCFModel::maxNextSpeed(), MIN2(), and SUMOReal.

00078                                                                                                   {
00079     SUMOReal speed = veh->getSpeed();
00080     return MIN2(_v(speed, maxNextSpeed(speed), gap, predSpeed), maxNextSpeed(speed));
00081 }

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

Computes the vehicle's safe speed (no dawdling).

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
See also:
MSCFModel::ffeV

Implements MSCFModel.

Definition at line 72 of file MSCFModel_Kerner.cpp.

References _v(), MSCFModel::maxNextSpeed(), and MIN2().

00072                                                                                                                   {
00073     return MIN2(_v(speed, maxNextSpeed(speed), gap, predSpeed), maxNextSpeed(speed));
00074 }

SUMOReal MSCFModel_Kerner::getMaxAccel ( SUMOReal  v  )  const throw () [inline, 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

Implements MSCFModel.

Definition at line 145 of file MSCFModel_Kerner.h.

References myAccel.

00145                                                    {
00146         return myAccel;
00147     }

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

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 MSCFModel::myDecel.

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

00218                                          {
00219         return myDecel;
00220     }

int MSCFModel_Kerner::getModelID (  )  const throw () [inline, virtual]

Returns the model's name.

Returns:
The model's name
See also:
MSCFModel::getModelName

Implements MSCFModel.

Definition at line 154 of file MSCFModel_Kerner.h.

References SUMO_TAG_CF_BKERNER.

00154                                    {
00155         return SUMO_TAG_CF_BKERNER;
00156     }

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

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 MSCFModel::getMaxDecel(), MSCFModel::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, inherited]

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(), MSCFModel::myDecel, and SUMOReal.

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

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

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

Get the driver's reaction time [s].

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

Reimplemented from MSCFModel.

Definition at line 162 of file MSCFModel_Kerner.h.

References myTau.

00162                                     {
00163         return myTau;
00164     }

bool MSCFModel_Kerner::hasSafeGap ( SUMOReal  speed,
SUMOReal  gap,
SUMOReal  predSpeed,
SUMOReal  laneMaxSpeed 
) const throw () [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
See also:
MSCFModel::hasSafeGap
Todo:
evaluate signature

Implements MSCFModel.

Definition at line 114 of file MSCFModel_Kerner.cpp.

References _v(), MSCFModel::getSpeedAfterMaxDecel(), MSCFModel::maxNextSpeed(), MIN2(), MIN3(), SPEED2DIST, and SUMOReal.

00114                                                                                                                   {
00115     if (gap<0) {
00116         return false;
00117     }
00118     SUMOReal vSafe = MIN2(_v(speed, maxNextSpeed(speed), gap, predSpeed), maxNextSpeed(speed));
00119     SUMOReal vNext = MIN3(maxNextSpeed(speed), laneMaxSpeed, vSafe);
00120     return (vNext>=getSpeedAfterMaxDecel(speed) && gap>= SPEED2DIST(speed));
00121 }

SUMOReal MSCFModel_Kerner::interactionGap ( const MSVehicle *const   veh,
SUMOReal  vL 
) const throw () [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
See also:
MSCFModel::interactionGap
Todo:
evaluate signature

Implements MSCFModel.

Definition at line 99 of file MSCFModel_Kerner.cpp.

References MAX2(), MSCFModel::maxNextSpeed(), MIN2(), MSCFModel::myInverseTwoDecel, myTau, SPEED2DIST, and SUMOReal.

00099                                                                                        {
00100     // Resolve the vsafe equation to gap. Assume predecessor has
00101     // speed != 0 and that vsafe will be the current speed plus acceleration,
00102     // i.e that with this gap there will be no interaction.
00103     SUMOReal vNext = MIN2(maxNextSpeed(veh->getSpeed()), veh->getLane().getMaxSpeed());
00104     SUMOReal gap = (vNext - vL) *
00105                    ((veh->getSpeed() + vL) * myInverseTwoDecel + myTau) +
00106                    vL * myTau;
00107 
00108     // Don't allow timeHeadWay < deltaT situations.
00109     return MAX2(gap, SPEED2DIST(vNext));
00110 }

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

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 MSCFModel::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 () [inherited]

SUMOReal MSCFModel_Kerner::moveHelper ( MSVehicle *const   veh,
const MSLane *const   lane,
SUMOReal  vPos 
) const throw () [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

!! reverify

Implements MSCFModel.

Definition at line 52 of file MSCFModel_Kerner.cpp.

References ACCEL2SPEED, MAX2(), MSCFModel::maxNextSpeed(), MIN2(), MIN3(), MIN4(), MSCFModel::myDecel, SPEED2ACCEL, and SUMOReal.

00052                                                                                                           {
00053     SUMOReal oldV = veh->getSpeed(); // save old v for optional acceleration computation
00054     SUMOReal vSafe = MIN2(vPos, veh->processNextStop(vPos)); // process stops
00055     // we need the acceleration for emission computation;
00056     //  in this case, we neglect dawdling, nonetheless, using
00057     //  vSafe does not incorporate speed reduction due to interaction
00058     //  on lane changing
00059     veh->setPreDawdleAcceleration(SPEED2ACCEL(vSafe-oldV));
00060     //
00061     SUMOReal vNext =
00062         veh->getLaneChangeModel().patchSpeed(
00063             MAX2((SUMOReal) 0, oldV-(SUMOReal)ACCEL2SPEED(myDecel)), 
00064             vSafe,
00065             MIN3(vSafe, veh->getLane().getMaxSpeed(), maxNextSpeed(oldV)),//vaccel(myState.mySpeed, myLane->maxSpeed())),
00066             vSafe);
00067     return MIN4(vNext, vSafe, veh->getLane().getMaxSpeed(), maxNextSpeed(oldV));
00068 }

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

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_Kerner::myAccel [private]

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

Definition at line 183 of file MSCFModel_Kerner.h.

Referenced by _v(), and getMaxAccel().

SUMOReal MSCFModel::myDecel [protected, inherited]

SUMOReal MSCFModel::myInverseTwoDecel [protected, inherited]

SUMOReal MSCFModel_Kerner::myK [private]

The driver's reaction time [s].

Definition at line 189 of file MSCFModel_Kerner.h.

Referenced by _v().

SUMOReal MSCFModel_Kerner::myPhi [private]

The driver's reaction time [s].

Definition at line 192 of file MSCFModel_Kerner.h.

Referenced by _v().

SUMOReal MSCFModel_Kerner::myTau [private]

The driver's reaction time [s].

Definition at line 186 of file MSCFModel_Kerner.h.

Referenced by getTau(), and interactionGap().

SUMOReal MSCFModel_Kerner::myTauDecel [private]

The precomputed value for myDecel*myTau.

Definition at line 195 of file MSCFModel_Kerner.h.

Referenced by _v().

const MSVehicleType* MSCFModel::myType [protected, inherited]

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 MSCFModel::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