MSCFModel_Krauss Class Reference

#include <MSCFModel_Krauss.h>

Inheritance diagram for MSCFModel_Krauss:

MSCFModel

Detailed Description

Krauss car-following model, with acceleration decrease and faster start.

See also:
MSCFModel

Definition at line 42 of file MSCFModel_Krauss.h.


Public Member Functions

 MSCFModel_Krauss (const MSVehicleType *vtype, SUMOReal accel, SUMOReal decel, SUMOReal dawdle, SUMOReal tau) throw ()
 Constructor.
 ~MSCFModel_Krauss () 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 _vsafe (SUMOReal gap, SUMOReal predSpeed) const throw ()
 Returns the "safe" velocity.
SUMOReal dawdle (SUMOReal speed) const throw ()
 Applies driver imperfection (dawdling / sigma).

Private Attributes

model parameter
SUMOReal myAccel
 The vehicle's maximum acceleration [m/s^2].
SUMOReal myDawdle
 The vehicle's dawdle-parameter. 0 for no dawdling, 1 for max.
SUMOReal myTau
 The driver's reaction time [s].
SUMOReal myTauDecel
 The precomputed value for myDecel*myTau.

Constructor & Destructor Documentation

MSCFModel_Krauss::MSCFModel_Krauss ( const MSVehicleType vtype,
SUMOReal  accel,
SUMOReal  decel,
SUMOReal  dawdle,
SUMOReal  tau 
) 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_Krauss.cpp.

00042         : MSCFModel(vtype, decel), myAccel(accel), myDawdle(dawdle), myTau(tau) {
00043 
00044     myTauDecel = decel * myTau;
00045 }

MSCFModel_Krauss::~MSCFModel_Krauss (  )  throw ()

Destructor.

Definition at line 48 of file MSCFModel_Krauss.cpp.

00048 {}


Member Function Documentation

SUMOReal MSCFModel_Krauss::_vsafe ( 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
Returns the SK-vsafe.

Definition at line 140 of file MSCFModel_Krauss.cpp.

References MSCFModel::myDecel, myTauDecel, and SUMOReal.

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

00140                                                                                 {
00141     if (predSpeed==0&&gap<0.01) {
00142         return 0;
00143     }
00144     SUMOReal vsafe = (SUMOReal)(-1. * myTauDecel + sqrt(myTauDecel*myTauDecel + (predSpeed*predSpeed) + (2. * myDecel * gap)));
00145     assert(vsafe >= 0);
00146     return vsafe;
00147 }

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_Krauss::dawdle ( SUMOReal  speed  )  const throw () [private]

Applies driver imperfection (dawdling / sigma).

Parameters:
[in] speed The speed with no dawdling
Returns:
The speed after dawdling

Definition at line 123 of file MSCFModel_Krauss.cpp.

References ACCEL2SPEED, getMaxAccel(), MAX2(), myAccel, myDawdle, RandHelper::rand(), and SUMOReal.

Referenced by moveHelper().

00123                                                      {
00124     // generate random number out of [0,1]
00125     SUMOReal random = RandHelper::rand();
00126     // Dawdle.
00127     if (speed < myAccel) {
00128         // we should not prevent vehicles from driving just due to dawdling
00129         //  if someone is starting, he should definitely start
00130         // (but what about slow-to-start?)!!!
00131         speed -= ACCEL2SPEED(myDawdle * speed * random);
00132     } else {
00133         speed -= ACCEL2SPEED(myDawdle * getMaxAccel(speed) * random);
00134     }
00135     return MAX2(SUMOReal(0), speed);
00136 }

SUMOReal MSCFModel_Krauss::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 91 of file MSCFModel_Krauss.cpp.

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

00091                                                                               {
00092     return MIN2(_vsafe(gap, 0), maxNextSpeed(veh->getSpeed()));
00093 }

SUMOReal MSCFModel_Krauss::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_Krauss.cpp.

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

00085                                                                                        {
00086     return MIN2(_vsafe(veh->gap2pred(*pred), pred->getSpeed()), maxNextSpeed(veh->getSpeed()));
00087 }

SUMOReal MSCFModel_Krauss::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 79 of file MSCFModel_Krauss.cpp.

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

00079                                                                                                   {
00080     return MIN2(_vsafe(gap, predSpeed), maxNextSpeed(veh->getSpeed()));
00081 }

SUMOReal MSCFModel_Krauss::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 73 of file MSCFModel_Krauss.cpp.

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

00073                                                                                                                   {
00074     return MIN2(_vsafe(gap, predSpeed), maxNextSpeed(speed));
00075 }

SUMOReal MSCFModel_Krauss::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_Krauss.h.

References MSVehicleType::getMaxSpeed(), myAccel, MSCFModel::myType, and SUMOReal.

Referenced by dawdle().

00145                                                    {
00146         return (SUMOReal)(myAccel *(1.0 - (v/myType->getMaxSpeed())));
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_Krauss::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_Krauss.h.

References SUMO_TAG_CF_KRAUSS.

00154                                    {
00155         return SUMO_TAG_CF_KRAUSS;
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(), hasSafeGap(), MSCFModel_Kerner::hasSafeGap(), MSCFModel_IDM::hasSafeGap(), and MSLane::isEmissionSuccess().

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

SUMOReal MSCFModel_Krauss::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_Krauss.h.

References myTau.

00162                                     {
00163         return myTau;
00164     }

bool MSCFModel_Krauss::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 112 of file MSCFModel_Krauss.cpp.

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

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

SUMOReal MSCFModel_Krauss::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 97 of file MSCFModel_Krauss.cpp.

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

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

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_Krauss::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_Krauss.cpp.

References ACCEL2SPEED, dawdle(), 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 = dawdle(MIN3(lane->getMaxSpeed(), maxNextSpeed(oldV), vSafe));
00062     vNext =
00063         veh->getLaneChangeModel().patchSpeed(
00064             MAX2((SUMOReal) 0, oldV-(SUMOReal)ACCEL2SPEED(myDecel)), 
00065             vNext,
00066             MIN3(vSafe, veh->getLane().getMaxSpeed(), maxNextSpeed(oldV)),//vaccel(myState.mySpeed, myLane->maxSpeed())),
00067             vSafe);
00068     return MIN4(vNext, vSafe, veh->getLane().getMaxSpeed(), maxNextSpeed(oldV));
00069 }

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

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

Definition at line 188 of file MSCFModel_Krauss.h.

Referenced by dawdle(), and getMaxAccel().

SUMOReal MSCFModel_Krauss::myDawdle [private]

The vehicle's dawdle-parameter. 0 for no dawdling, 1 for max.

Definition at line 191 of file MSCFModel_Krauss.h.

Referenced by dawdle().

SUMOReal MSCFModel::myDecel [protected, inherited]

SUMOReal MSCFModel::myInverseTwoDecel [protected, inherited]

SUMOReal MSCFModel_Krauss::myTau [private]

The driver's reaction time [s].

Definition at line 194 of file MSCFModel_Krauss.h.

Referenced by getTau(), and interactionGap().

SUMOReal MSCFModel_Krauss::myTauDecel [private]

The precomputed value for myDecel*myTau.

Definition at line 197 of file MSCFModel_Krauss.h.

Referenced by _vsafe().

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(), 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