36#define INTERACTION_GAP 150
41#define DEBUG_FOLLOW_SPEED
43#define DEBUG_COND (veh->isSelected())
77 double& sdxc,
double& sdxo,
double& sdxv)
const {
79 const double dv = predSpeed - speed;
82 const double v_slower = (dv >= 0 || leaderAccel < 1) ? speed : predSpeed + dv * rndVal;
93 const double dv = predSpeed - speed;
97 const double leaderAccel = pred !=
nullptr ? pred->
getAcceleration() : 0;
101 double sdxc, sdxo, sdxv;
104 const double sdv =
myCC6 * dx * dx / 10000;
105 const double sdvc = speed > 0 ?
myCC4 - sdv : 0;
106 const double sdvo = predSpeed >
myCC5 ? sdv +
myCC5 : sdv;
111 if (dv < sdvo && dx <= sdxc) {
123 accel =
MIN2(leaderAccel + dv * dv / (cc0 - dx), 0.0);
126 accel =
MIN2(leaderAccel + 0.5 * (dv - sdvo), 0.0);
130 if (accel > -
myCC7) {
134 accel =
MAX2(accel, -10 + 0.5 * sqrt(speed));
139 }
else if (dv < sdvc && dx < sdxv) {
141 accel = 0.5 * dv * dv / (sdxc - dx - 0.1);
144 }
else if (dv < sdvo && dx < sdxo) {
163 accel =
MIN2(dv * dv / (sdxo - dx), accelMax);
174#ifdef DEBUG_FOLLOW_SPEED
177 <<
" v=" << speed <<
" pV=" << predSpeed <<
" g=" << gap2pred
178 <<
" dv=" << dv <<
" dx=" << dx
179 <<
" sdxc=" << sdxc <<
" sdxo=" << sdxo <<
" sdxv=" << sdxv <<
" sdv=" << sdv <<
" sdvo=" << sdvo <<
" sdvc=" << sdvc
181 <<
" a=" << accel <<
" V=" << vNew <<
"\n";
187 vNew =
MAX2(0.0, vNew);
218 }
else if (key ==
"cc1") {
220 }
else if (key ==
"cc2") {
222 }
else if (key ==
"cc3") {
224 }
else if (key ==
"cc4") {
226 }
else if (key ==
"cc5") {
228 }
else if (key ==
"cc6") {
230 }
else if (key ==
"cc7") {
232 }
else if (key ==
"cc8") {
234 }
else if (key ==
"cc9") {
237 throw InvalidArgument(
"Parameter '" + key +
"' is not supported by carFollowModel");
248 throw InvalidArgument(
"Invalid value '" + value +
"' for parameter '" + key +
"' for vehicle '" + veh->
getID() +
"'");
250 if (key !=
"cc0" && key !=
"cc1" && key !=
"cc2" && key !=
"cc3" && key !=
"cc4"
251 && key !=
"cc5" && key !=
"cc6" && key !=
"cc7" && key !=
"cc8" && key !=
"cc9") {
252 throw InvalidArgument(
"Setting parameter '" + key +
"' is not supported by carFollowModel");
259 }
else if (key ==
"cc1") {
263 }
else if (key ==
"cc2") {
266 }
else if (key ==
"cc3") {
269 }
else if (key ==
"cc4") {
272 }
else if (key ==
"cc5") {
275 }
else if (key ==
"cc6") {
278 }
else if (key ==
"cc7") {
281 }
else if (key ==
"cc8") {
285 }
else if (key ==
"cc9") {
@ SUMO_ATTR_COLLISION_MINGAP_FACTOR
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
The W99 Model car-following model.
MSCFModel_W99(const MSVehicleType *vtype)
Constructor.
std::string getParameter(const MSVehicle *veh, const std::string &key) const
try to get the given parameter for this carFollowingModel
double interactionGap(const MSVehicle *const, double vL) const
Returns the maximum gap at which an interaction between both vehicles occurs.
void setParameter(MSVehicle *veh, const std::string &key, const std::string &value) const
try to set the given parameter for this carFollowingModel
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)
void computeThresholds(double speed, double predSpeed, double leaderAccel, double rndVal, double &sdxc, double &sdxo, double &sdxv) const
~MSCFModel_W99()
Destructor.
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)
MSCFModel * duplicate(const MSVehicleType *vtype) const
Duplicates the car-following model.
The car-following model abstraction.
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
CalcReason
What the return value of stop/follow/free-Speed is used for.
double myCollisionMinGapFactor
The factor of minGap that must be maintained to avoid a collision event.
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
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.
double getAcceleration() const
Returns the vehicle's acceleration in m/s (this is computed as the last step's mean acceleration in c...
The car-following model and parameter.
double getMinGap() const
Get the free space in front of vehicles of this class.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
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.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Structure representing possible vehicle parameter.
std::map< SumoXMLAttr, std::string > SubParams
sub-model parameters
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.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
#define UNUSED_PARAMETER(x)