#include <MSCFModel_Krauss.h>

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 MSVehicleType * | myType |
| 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. | |
| MSCFModel_Krauss::MSCFModel_Krauss | ( | const MSVehicleType * | vtype, | |
| SUMOReal | accel, | |||
| SUMOReal | decel, | |||
| SUMOReal | dawdle, | |||
| SUMOReal | tau | |||
| ) | throw () |
Constructor.
| [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 () |
| SUMOReal MSCFModel_Krauss::_vsafe | ( | SUMOReal | gap, | |
| SUMOReal | predSpeed | |||
| ) | const throw () [private] |
Returns the "safe" velocity.
| [in] | gap2pred | The (netto) distance to the LEADER |
| [in] | predSpeed | The LEADER's speed |
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.
| [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_Krauss::dawdle | ( | SUMOReal | speed | ) | const throw () [private] |
Applies driver imperfection (dawdling / sigma).
| [in] | speed | The speed with no 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).
| [in] | veh | The vehicle (EGO) |
| [in] | gap2pred | The (netto) distance to the the obstacle |
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).
| [in] | veh | The vehicle (EGO) |
| [in] | pred | The LEADER |
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).
| [in] | veh | The vehicle (EGO) |
| [in] | gap2pred | The (netto) distance to the LEADER |
| [in] | predSpeed | The speed of LEADER |
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).
| [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 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.
| [in] | v | The vehicle's velocity |
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].
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.
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.
| [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(), 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].
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.
| [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 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.
| [in] | veh | The EGO vehicle |
| [in] | vL | LEADER's speed |
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
| [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(), ffeS(), MSCFModel_Kerner::ffeS(), MSCFModel_PWag2009::ffeV(), MSCFModel_KraussOrig1::ffeV(), ffeV(), MSCFModel_Kerner::ffeV(), MSLane::getFollowerOnConsecutive(), MSCFModel_PWag2009::hasSafeGap(), MSCFModel_KraussOrig1::hasSafeGap(), hasSafeGap(), MSCFModel_Kerner::hasSafeGap(), MSCFModel_IDM::hasSafeGap(), MSCFModel_PWag2009::interactionGap(), MSCFModel_KraussOrig1::interactionGap(), interactionGap(), MSCFModel_Kerner::interactionGap(), MSCFModel_PWag2009::moveHelper(), MSCFModel_KraussOrig1::moveHelper(), 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 }
| 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.
| [in] | veh | The ego vehicle |
| [in] | lane | The lane ego is at |
| [in] | vPos | The possible velocity |
!! 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.
| [in] | os | The output to write the definition into |
Definition at line 71 of file MSCFModel.cpp.
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] |
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(), _vsafe(), MSCFModel::getMaxDecel(), MSCFModel::getSpeedAfterMaxDecel(), MSCFModel_PWag2009::moveHelper(), MSCFModel_KraussOrig1::moveHelper(), moveHelper(), MSCFModel_Kerner::moveHelper(), and MSCFModel_IDM::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(), interactionGap(), MSCFModel_Kerner::interactionGap(), and MSCFModel_IDM::interactionGap().
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().
1.5.6