#include <MSCFModel.h>

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 MSVehicleType * | myType |
| The type to which this model definition belongs to. | |
| MSCFModel::MSCFModel | ( | const MSVehicleType * | vtype, | |
| SUMOReal | decel | |||
| ) | throw () |
Constructor.
| [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] |
| SUMOReal MSCFModel::brakeGap | ( | SUMOReal | speed | ) | const throw () |
Returns the distance the vehicle needs to halt including driver's reaction time.
| [in] | speed | The vehicle's current speed |
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.
| [in] | veh | The vehicle (EGO) |
| [in] | gap2pred | The (netto) distance to the the obstacle |
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.
| [in] | veh | The vehicle (EGO) |
| [in] | pred | The LEADER |
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.
| [in] | veh | The vehicle (EGO) |
| [in] | gap2pred | The (netto) distance to the LEADER |
| [in] | predSpeed | The speed of LEADER |
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.
| [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 |
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.
| [in] | v | The vehicle's velocity |
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].
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.
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.
| [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.
| [in] | v | The velocity |
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].
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().
| 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.
| [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 |
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.
| [in] | veh | The EGO vehicle |
| [in] | vL | LEADER's speed |
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
| [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 () |
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).
| [in] | speed | The vehicle's current speed |
Definition at line 60 of file MSCFModel.cpp.
References ACCEL2SPEED, getMaxAccel(), MSVehicleType::getMaxSpeed(), MIN2(), myType, and SUMOReal.
Referenced by MSCFModel_PWag2009::ffeS(), MSCFModel_KraussOrig1::ffeS(), MSCFModel_Krauss::ffeS(), MSCFModel_Kerner::ffeS(), MSCFModel_PWag2009::ffeV(), MSCFModel_KraussOrig1::ffeV(), MSCFModel_Krauss::ffeV(), MSCFModel_Kerner::ffeV(), MSLane::getFollowerOnConsecutive(), MSCFModel_PWag2009::hasSafeGap(), MSCFModel_KraussOrig1::hasSafeGap(), MSCFModel_Krauss::hasSafeGap(), MSCFModel_Kerner::hasSafeGap(), MSCFModel_IDM::hasSafeGap(), MSCFModel_PWag2009::interactionGap(), MSCFModel_KraussOrig1::interactionGap(), MSCFModel_Krauss::interactionGap(), MSCFModel_Kerner::interactionGap(), MSCFModel_PWag2009::moveHelper(), MSCFModel_KraussOrig1::moveHelper(), MSCFModel_Krauss::moveHelper(), MSCFModel_Kerner::moveHelper(), MSCFModel_IDM::moveHelper(), MSVehicle::moveRegardingCritical(), MSLCM_DK2004::patchSpeed(), and MSVehicle::vsafeCriticalCont().
00060 { 00061 return MIN2(speed + (SUMOReal) ACCEL2SPEED(getMaxAccel(speed)), myType->getMaxSpeed()); 00062 }
| 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.
| [in] | veh | The ego vehicle |
| [in] | lane | The lane ego is at |
| [in] | vPos | The possible velocity |
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.
| [in] | os | The output to write the definition into |
Definition at line 71 of file MSCFModel.cpp.
SUMOReal MSCFModel::myDecel [protected] |
The vehicle's maximum deceleration [m/s^2].
Definition at line 255 of file MSCFModel.h.
Referenced by MSCFModel_IDM::_updateSpeed(), MSCFModel_PWag2009::_v(), MSCFModel_Kerner::_v(), MSCFModel_KraussOrig1::_vsafe(), MSCFModel_Krauss::_vsafe(), getMaxDecel(), getSpeedAfterMaxDecel(), MSCFModel_PWag2009::moveHelper(), MSCFModel_KraussOrig1::moveHelper(), MSCFModel_Krauss::moveHelper(), MSCFModel_Kerner::moveHelper(), and MSCFModel_IDM::moveHelper().
SUMOReal MSCFModel::myInverseTwoDecel [protected] |
The precomputed value for 1/(2*d).
Definition at line 258 of file MSCFModel.h.
Referenced by brakeGap(), MSCFModel_PWag2009::interactionGap(), MSCFModel_KraussOrig1::interactionGap(), MSCFModel_Krauss::interactionGap(), MSCFModel_Kerner::interactionGap(), and MSCFModel_IDM::interactionGap().
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().
1.5.6