30#define DEBUG_COND (veh->isSelected())
44 myTwoSqrtAccelDecel(double(2 * sqrt(myAccel * myDecel))) {
85 if (speed <= maxSpeed) {
96 vSafe =
MIN2(vSafe, maxSpeed);
129#ifdef DEBUG_INSERTION_SPEED
130 std::cout <<
SIMTIME <<
" veh=" << v->
getID() <<
" speed=" << speed <<
" gap2pred=" << gap2pred <<
" predSpeed=" << predSpeed <<
" predMaxDecel=" << predMaxDecel <<
" pred=" <<
Named::getIDSecure(pred) <<
" s=" << s <<
" speed2=" << speed2 <<
" speed3=" << speed3 <<
"\n";
145 if (gap > 0 && speed < NUMERICAL_EPS && result < NUMERICAL_EPS) {
169 const double vNext = veh->
getSpeed() + acc;
170 const double gap = (vNext - vL) * (veh->
getSpeed() + vL) / (2 *
myDecel) + vL;
178 const double delta_v = speed - leaderSpeed;
185 const double predSpeed,
const double desSpeed,
const bool respectMinGap)
const {
194 double newSpeed = egoSpeed;
195 double gap = gap2pred;
202 std::cout <<
SIMTIME <<
" veh=" << veh->
getID() <<
" gap2pred=" << gap2pred <<
" egoSpeed=" << egoSpeed <<
" predSpeed=" << predSpeed <<
" desSpeed=" << desSpeed <<
" rMG=" << respectMinGap <<
" hw=" << headwayTime <<
"\n";
206 const double delta_v = newSpeed - predSpeed;
211 gap =
MAX2(NUMERICAL_EPS, gap);
212 const double acc =
myAccel * (1. - pow(newSpeed /
MAX2(NUMERICAL_EPS, desSpeed),
myDelta) - (s * s) / (gap * gap));
215 std::cout <<
" i=" << i <<
" gap=" << gap <<
" t=" <<
myHeadwayTime <<
" t2=" << headwayTime <<
" s=" << s <<
" pow=" << pow(newSpeed / desSpeed,
myDelta) <<
" gapDecel=" << (s * s) / (gap * gap) <<
" a=" << acc;
227 return MAX2(0., newSpeed);
@ SUMO_ATTR_CF_IDMM_ADAPT_TIME
@ SUMO_ATTR_CF_IDM_STEPPING
@ SUMO_ATTR_CF_IDMM_ADAPT_FACTOR
@ SUMO_ATTR_COLLISION_MINGAP_FACTOR
double levelOfService
state variable for remembering speed deviation history (lambda)
The Intelligent Driver Model (IDM) car-following model.
const int myIterations
The number of iterations in speed calculations.
double stopSpeed(const MSVehicle *const veh, const double speed, double gap, double decel, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
double minNextSpeed(double speed, const MSVehicle *const veh=0) const
Returns the minimum speed given the current speed (depends on the numerical update scheme and its ste...
double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences.
double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed (no dawdling)
virtual double freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion=false, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed without a leader.
~MSCFModel_IDM()
Destructor.
const bool myIDMM
whether the model is IDMM or IDM
double getSecureGap(const MSVehicle *const veh, const MSVehicle *const pred, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
MSCFModel_IDM(const MSVehicleType *vtype, bool idmm)
Constructor.
double insertionFollowSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const
Computes the vehicle's safe speed (no dawdling) This method is used during the insertion stage....
const double myAdaptationTime
The IDMM adaptation time tau.
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
const double myTwoSqrtAccelDecel
A computational shortcut.
const double myAdaptationFactor
The IDMM adaptation factor beta.
const double myDelta
The IDM delta exponent.
double _v(const MSVehicle *const veh, const double gap2pred, const double mySpeed, const double predSpeed, const double desSpeed, const bool respectMinGap=true) const
double interactionGap(const MSVehicle *const, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
The car-following model abstraction.
void applyHeadwayPerceptionError(const MSVehicle *const veh, double speed, double &gap) const
Overwrites gap by the perceived value obtained from the vehicle's driver state.
virtual double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences. Called at most once per simulation...
double myEmergencyDecel
The vehicle's maximum emergency deceleration [m/s^2].
void applyHeadwayAndSpeedDifferencePerceptionErrors(const MSVehicle *const veh, double speed, double &gap, double &predSpeed, double predMaxDecel, const MSVehicle *const pred) const
Overwrites gap2pred and predSpeed by the perceived values obtained from the vehicle's driver state,...
CalcReason
What the return value of stop/follow/free-Speed is used for.
@ FUTURE
the return value is used for calculating future speeds
double myCollisionMinGapFactor
The factor of minGap that must be maintained to avoid a collision event.
double myDecel
The vehicle's maximum deceleration [m/s^2].
double maximumSafeStopSpeed(double gap, double decel, double currentSpeed, bool onInsertion=false, double headway=-1, bool relaxEmergency=true) const
Returns the maximum next velocity for stopping within gap.
double myAccel
The vehicle's maximum acceleration [m/s^2].
const MSVehicleType * myType
The type to which this model definition belongs to.
double myHeadwayTime
The driver's desired time headway (aka reaction time tau) [s].
static bool gSemiImplicitEulerUpdate
static bool gComputeLC
whether the simulationLoop is in the lane changing phase
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Representation of a vehicle in the micro simulation.
double getActionStepLengthSecs() const
Returns the vehicle's action step length in secs, i.e. the interval between two action points.
const MSLane * getLane() const
Returns the lane the vehicle is on.
double getSpeed() const
Returns the vehicle's current speed.
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle's car following model variables.
The car-following model and parameter.
double getMinGap() const
Get the free space in front of vehicles of this class.
const SUMOVTypeParameter & getParameter() const
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const std::string & getID() const
Returns the id.
double getCFParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.