#include <MSCFModel_IDM.h>

Definition at line 45 of file MSCFModel_IDM.h.
Public Member Functions | |
| MSCFModel_IDM (const MSVehicleType *vtype, SUMOReal accel, SUMOReal decel, SUMOReal timeHeadWay, SUMOReal mingap, SUMOReal tau) throw () | |
| Constructor. | |
| ~MSCFModel_IDM () 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 , 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 MSVehicleType * | myType |
| The type to which this model definition belongs to. | |
Private Member Functions | |
| SUMOReal | _updateSpeed (SUMOReal gap2pred, SUMOReal mySpeed, SUMOReal predSpeed, SUMOReal desSpeed) const throw () |
| SUMOReal | desiredSpeed (const MSVehicle *const veh) const throw () |
Private Attributes | |
model parameter | |
| SUMOReal | myAccel |
| The vehicle's maximum acceleration [m/s^2]. | |
| SUMOReal | myMinSpace |
| The desired minimum Gap to the leading vehicle (no matter the speed). | |
| SUMOReal | myTau |
| The driver's reaction time [s]. | |
| SUMOReal | myTimeHeadWay |
| The driver's desired time headway [s]. | |
| MSCFModel_IDM::MSCFModel_IDM | ( | const MSVehicleType * | vtype, | |
| SUMOReal | accel, | |||
| SUMOReal | decel, | |||
| SUMOReal | timeHeadWay, | |||
| SUMOReal | mingap, | |||
| SUMOReal | tau | |||
| ) | throw () |
Constructor.
| [in] | accel | The maximum acceleration |
| [in] | decel | The maximum deceleration |
| [in] | timeHeadWay | |
| [in] | mingap |
Definition at line 46 of file MSCFModel_IDM.cpp.
00049 : MSCFModel(vtype, decel), 00050 myAccel(accel), myTimeHeadWay(timeHeadWay), myMinSpace(mingap), myTau(tau) { 00051 00052 }
| MSCFModel_IDM::~MSCFModel_IDM | ( | ) | throw () |
| SUMOReal MSCFModel_IDM::_updateSpeed | ( | SUMOReal | gap2pred, | |
| SUMOReal | mySpeed, | |||
| SUMOReal | predSpeed, | |||
| SUMOReal | desSpeed | |||
| ) | const throw () [private] |
Definition at line 133 of file MSCFModel_IDM.cpp.
References ACCEL2SPEED, DELTA_IDM, MAX2(), myAccel, MSCFModel::myDecel, myMinSpace, myTimeHeadWay, and SUMOReal.
Referenced by ffeS(), ffeV(), and hasSafeGap().
00133 { 00134 SUMOReal delta_v = mySpeed - predSpeed; 00135 SUMOReal s_star_raw = myMinSpace + mySpeed*myTimeHeadWay + (mySpeed*delta_v)/(2*sqrt(myAccel*myDecel)); 00136 SUMOReal s_star = MAX2(s_star_raw, myMinSpace); 00137 SUMOReal acc = myAccel * (1. - pow((double)(mySpeed/desSpeed), (double) DELTA_IDM) - (s_star*s_star)/(gap2pred*gap2pred)); 00138 SUMOReal vNext = mySpeed + ACCEL2SPEED(acc); 00139 return vNext; 00140 }
| SUMOReal MSCFModel::brakeGap | ( | SUMOReal | speed | ) | const throw () [inherited] |
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 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_IDM::desiredSpeed | ( | const MSVehicle *const | veh | ) | const throw () [inline, private] |
Definition at line 177 of file MSCFModel_IDM.h.
References MSVehicle::getLane(), MSLane::getMaxSpeed(), MSVehicleType::getMaxSpeed(), MIN2(), and MSCFModel::myType.
Referenced by ffeS(), ffeV(), and interactionGap().
00177 { 00178 return MIN2(myType->getMaxSpeed(), veh->getLane().getMaxSpeed()); 00179 }
| SUMOReal MSCFModel_IDM::ffeS | ( | const MSVehicle *const | veh, | |
| SUMOReal | gap2pred | |||
| ) | const throw () [virtual] |
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling).
| [in] | veh | The vehicle (EGO) |
| [in] | gap2pred | The (netto) distance to the the obstacle |
Implements MSCFModel.
Definition at line 97 of file MSCFModel_IDM.cpp.
References _updateSpeed(), desiredSpeed(), and SUMOReal.
00097 { 00098 SUMOReal desSpeed = desiredSpeed(veh); 00099 return _updateSpeed(gap2pred, veh->getSpeed(), desSpeed, desSpeed); 00100 }
| SUMOReal MSCFModel_IDM::ffeV | ( | const MSVehicle *const | veh, | |
| const MSVehicle *const | pred | |||
| ) | const throw () [virtual] |
Computes the vehicle's safe speed (no dawdling).
| [in] | veh | The vehicle (EGO) |
| [in] | pred | The LEADER |
Implements MSCFModel.
Definition at line 91 of file MSCFModel_IDM.cpp.
References _updateSpeed(), and desiredSpeed().
00091 { 00092 return _updateSpeed(veh->gap2pred(*pred), veh->getSpeed(), pred->getSpeed(), desiredSpeed(veh)); 00093 }
| SUMOReal MSCFModel_IDM::ffeV | ( | const MSVehicle *const | veh, | |
| SUMOReal | gap2pred, | |||
| SUMOReal | predSpeed | |||
| ) | const throw () [virtual] |
Computes the vehicle's safe speed (no dawdling).
| [in] | veh | The vehicle (EGO) |
| [in] | gap2pred | The (netto) distance to the LEADER |
| [in] | predSpeed | The speed of LEADER |
Implements MSCFModel.
Definition at line 85 of file MSCFModel_IDM.cpp.
References _updateSpeed(), and desiredSpeed().
00085 { 00086 return _updateSpeed(gap2pred, veh->getSpeed(), predSpeed, desiredSpeed(veh)); 00087 }
| SUMOReal MSCFModel_IDM::ffeV | ( | const MSVehicle *const | veh, | |
| SUMOReal | speed, | |||
| SUMOReal | gap2pred, | |||
| SUMOReal | predSpeed | |||
| ) | const throw () [virtual] |
Computes the vehicle's safe speed (no dawdling).
| [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 |
Implements MSCFModel.
Definition at line 79 of file MSCFModel_IDM.cpp.
References _updateSpeed(), and desiredSpeed().
00079 { 00080 return _updateSpeed(gap2pred, speed, predSpeed, desiredSpeed(veh)); 00081 }
| SUMOReal MSCFModel_IDM::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.
| [in] | v | The vehicle's velocity |
Implements MSCFModel.
Definition at line 149 of file MSCFModel_IDM.h.
References myAccel.
00149 { 00150 return myAccel; 00151 }
| SUMOReal MSCFModel::getMaxDecel | ( | ) | const throw () [inline, inherited] |
Get the vehicle's maximum deceleration [m/s^2].
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_IDM::getModelID | ( | ) | const throw () [inline, virtual] |
Returns the model's name.
Implements MSCFModel.
Definition at line 158 of file MSCFModel_IDM.h.
References SUMO_TAG_CF_IDM.
00158 { 00159 return SUMO_TAG_CF_IDM; 00160 }
| 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.
| [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.
| [in] | v | The velocity |
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(), MSCFModel_Kerner::hasSafeGap(), hasSafeGap(), and MSLane::isEmissionSuccess().
00244 { 00245 return MAX2((SUMOReal) 0, v - (SUMOReal) ACCEL2SPEED(myDecel)); 00246 }
| SUMOReal MSCFModel_IDM::getTau | ( | ) | const throw () [inline, virtual] |
Get the driver's reaction time [s].
Reimplemented from MSCFModel.
Definition at line 166 of file MSCFModel_IDM.h.
References myTau.
00166 { 00167 return myTau; 00168 }
| bool MSCFModel_IDM::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.
| [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 |
Implements MSCFModel.
Definition at line 122 of file MSCFModel_IDM.cpp.
References _updateSpeed(), MSCFModel::getSpeedAfterMaxDecel(), MSCFModel::maxNextSpeed(), MIN3(), SPEED2DIST, and SUMOReal.
00122 { 00123 if (gap<0) { 00124 return false; 00125 } 00126 SUMOReal vSafe = _updateSpeed(speed, gap, predSpeed, laneMaxSpeed); 00127 SUMOReal vNext = MIN3(maxNextSpeed(speed), laneMaxSpeed, vSafe); 00128 return (vNext>=getSpeedAfterMaxDecel(speed) && gap >= SPEED2DIST(speed)); 00129 }
| SUMOReal MSCFModel_IDM::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.
| [in] | veh | The EGO vehicle |
| [in] | vL | LEADER's speed |
Implements MSCFModel.
Definition at line 105 of file MSCFModel_IDM.cpp.
References DELTA_IDM, desiredSpeed(), MAX2(), myAccel, MSCFModel::myInverseTwoDecel, SPEED2DIST, and SUMOReal.
00105 { 00106 // Resolve the IDM equation to gap. Assume predecessor has 00107 // speed != 0 and that vsafe will be the current speed plus acceleration, 00108 // i.e that with this gap there will be no interaction. 00109 SUMOReal acc = myAccel * (1. - pow((double)(veh->getSpeed()/desiredSpeed(veh)), (double) DELTA_IDM)); 00110 SUMOReal vNext = veh->getSpeed() + acc; 00111 SUMOReal gap = (vNext - vL) * 00112 ((veh->getSpeed() + vL) * myInverseTwoDecel) + 00113 vL * 1; 00114 00115 // Don't allow timeHeadWay < deltaT situations. 00116 return MAX2(gap, SPEED2DIST(vNext)); 00117 }
| 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
| [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] |
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, MSCFModel::getMaxAccel(), MSVehicleType::getMaxSpeed(), MIN2(), MSCFModel::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(), 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(), moveHelper(), MSVehicle::moveRegardingCritical(), MSLCM_DK2004::patchSpeed(), and MSVehicle::vsafeCriticalCont().
00060 { 00061 return MIN2(speed + (SUMOReal) ACCEL2SPEED(getMaxAccel(speed)), myType->getMaxSpeed()); 00062 }
| SUMOReal MSCFModel_IDM::moveHelper | ( | MSVehicle *const | veh, | |
| const MSLane *const | lane, | |||
| SUMOReal | vPos | |||
| ) | const throw () [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 |
!! reverify
Implements MSCFModel.
Definition at line 59 of file MSCFModel_IDM.cpp.
References ACCEL2SPEED, MAX2(), MSCFModel::maxNextSpeed(), MIN2(), MIN3(), MSCFModel::myDecel, SPEED2ACCEL, and SUMOReal.
00059 { 00060 SUMOReal oldV = veh->getSpeed(); // save old v for optional acceleration computation 00061 vPos = MIN2(vPos, veh->processNextStop(vPos)); // process stops 00062 // we need the acceleration for emission computation; 00063 // in this case, we neglect dawdling, nonetheless, using 00064 // vSafe does not incorporate speed reduction due to interaction 00065 // on lane changing 00066 veh->setPreDawdleAcceleration(SPEED2ACCEL(vPos-oldV)); 00067 // 00068 SUMOReal vNext = vPos; 00069 return 00070 veh->getLaneChangeModel().patchSpeed( 00071 MAX2((SUMOReal) 0, veh->getSpeed()-(SUMOReal)ACCEL2SPEED(myDecel)), 00072 vNext, 00073 MIN3(vNext, lane->getMaxSpeed(), maxNextSpeed(oldV)),//vaccel(myState.mySpeed, myLane->maxSpeed())), 00074 vNext); 00075 }
| void MSCFModel::saveState | ( | std::ostream & | os | ) | [virtual, inherited] |
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_IDM::myAccel [private] |
The vehicle's maximum acceleration [m/s^2].
Definition at line 187 of file MSCFModel_IDM.h.
Referenced by _updateSpeed(), getMaxAccel(), and interactionGap().
SUMOReal MSCFModel::myDecel [protected, inherited] |
The vehicle's maximum deceleration [m/s^2].
Definition at line 255 of file MSCFModel.h.
Referenced by _updateSpeed(), MSCFModel_PWag2009::_v(), MSCFModel_Kerner::_v(), MSCFModel_KraussOrig1::_vsafe(), MSCFModel_Krauss::_vsafe(), MSCFModel::getMaxDecel(), MSCFModel::getSpeedAfterMaxDecel(), MSCFModel_PWag2009::moveHelper(), MSCFModel_KraussOrig1::moveHelper(), MSCFModel_Krauss::moveHelper(), MSCFModel_Kerner::moveHelper(), and moveHelper().
SUMOReal MSCFModel::myInverseTwoDecel [protected, inherited] |
The precomputed value for 1/(2*d).
Definition at line 258 of file MSCFModel.h.
Referenced by MSCFModel::brakeGap(), MSCFModel_PWag2009::interactionGap(), MSCFModel_KraussOrig1::interactionGap(), MSCFModel_Krauss::interactionGap(), MSCFModel_Kerner::interactionGap(), and interactionGap().
SUMOReal MSCFModel_IDM::myMinSpace [private] |
The desired minimum Gap to the leading vehicle (no matter the speed).
Definition at line 193 of file MSCFModel_IDM.h.
Referenced by _updateSpeed().
SUMOReal MSCFModel_IDM::myTau [private] |
The driver's reaction time [s].
Definition at line 196 of file MSCFModel_IDM.h.
Referenced by getTau().
SUMOReal MSCFModel_IDM::myTimeHeadWay [private] |
The driver's desired time headway [s].
Definition at line 190 of file MSCFModel_IDM.h.
Referenced by _updateSpeed().
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 desiredSpeed(), MSCFModel_Krauss::getMaxAccel(), and MSCFModel::maxNextSpeed().
1.5.6