40 myTwoSqrtAccelDecel(double(2 * sqrt(myAccel * myDecel))) {
67 if (speed <= maxSpeed) {
78 vSafe =
MIN2(vSafe, maxSpeed);
109 const double speed2 =
followSpeed(v, speed, gap2pred, predSpeed, predMaxDecel);
110 const double speed3 =
followSpeed(v, speed2, gap2pred, predSpeed, predMaxDecel);
111 if (speed2 - speed3 < 1) {
114 #ifdef DEBUG_INSERTION_SPEED
115 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";
130 if (gap > 0 && speed < NUMERICAL_EPS && result < NUMERICAL_EPS) {
149 const double vNext = veh->
getSpeed() + acc;
150 const double gap = (vNext - vL) * (veh->
getSpeed() + vL) / (2 *
myDecel) + vL;
158 const double delta_v = speed - leaderSpeed;
165 const double predSpeed,
const double desSpeed,
const bool respectMinGap)
const {
174 double newSpeed = egoSpeed;
175 double gap = gap2pred;
181 const double delta_v = newSpeed - predSpeed;
186 gap =
MAX2(NUMERICAL_EPS, gap);
187 const double acc =
myAccel * (1. - pow(newSpeed / desSpeed,
myDelta) - (s * s) / (gap * gap));
190 std::cout <<
" gap=" << gap <<
" t=" <<
myHeadwayTime <<
" t2=" << headwayTime <<
" s=" << s <<
" pow=" << pow(newSpeed / desSpeed,
myDelta) <<
" gapDecel=" << (s * s) / (gap * gap) <<
" a=" << acc;
196 std::cout <<
" v2=" << newSpeed <<
"\n";
202 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
bool gDebugFlag1
global utility flags for debugging
virtual bool isSelected() const
whether this vehicle is selected in the GUI
double levelOfService
state variable for remembering speed deviation history (lambda)
const int myIterations
The number of iterations in speed calculations.
double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences.
~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....
virtual double freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion=false) const
Computes the vehicle's safe speed without a leader.
const double myAdaptationTime
The IDMM adaptation time tau.
double followSpeed(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)
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.
double stopSpeed(const MSVehicle *const veh, const double speed, double gap, double decel) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
The car-following model abstraction.
double maximumSafeStopSpeed(double gap, double decel, double currentSpeed, bool onInsertion=false, double headway=-1) const
Returns the maximum next velocity for stopping within gap.
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...
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,...
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 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].
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.
MSCFModel::VehicleVariables * getCarFollowVariables() const
Returns the vehicle's car following model variables.
double getSpeed() const
Returns the vehicle's current speed.
const MSLane * getLane() const
Returns the lane the vehicle is on.
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.