IDM Class Reference

A class representing the IDM driver model. More...

#include <IDM.h>

Inheritance diagram for IDM:

Inheritance graph
[legend]
Collaboration diagram for IDM:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 IDM ()
virtual ~IDM ()
double update (double vel, double dist)
 Updates the IDM's acceleration.
double get_T ()
double get_A ()
double get_B ()
double get_S0 ()
double get_S1 ()
double get_V0 ()
double get_Delta ()
double get_Polite ()
double get_Bias ()
double get_DeltaAth ()
void set_T (double val)
void set_A (double val)
void set_B (double val)
void set_S0 (double val)
void set_S1 (double val)
void set_V0 (double val)
void set_Delta (double val)
void set_Polite (double val)
void set_Bias (double val)
void set_DeltaAth (double val)
virtual void ClearRestriction ()
 Clears all restrictions on the IDM.
virtual void ClearGradient ()
 Clears all gradient restrictions on the IDM.
virtual void SetGradient (double gradient)
virtual void ClearSpeedLimit ()
 Clears all speedlimit restrictions on the IDM.
virtual void SetSpeedLimit (double newV0)
 Sets the properties for an IDM entering a speedlimit.
virtual double getDesiredVel ()
 Gets the desired velocity of the IDM.
virtual void setVel (double vel)
 Sets the velocity of the IDM.
double LaneChange (double GapToFront, double GapToBack, double FrontChangeAccel, double CurrentBackAccel, double ProposedBackAccel, bool overtake)
 Finds the advantage that a vehicle would gain from changing lane.

Private Member Functions

double s_star (double vel)
double dvdt (double m_speed, double s)

Private Attributes

double m_T
 Safe time headway.
double m_A
 Maximum acceleration.
double m_B
 Desired deceleration.
double m_S0
double m_S1
double m_V0
double m_Delta
double m_Polite
 MOBIL: Consideration towards other drivers.
double m_Bias
 MOBIL: Desire to keep to slow lane.
double m_DeltaAth
 MOBIL: Dampens overtaking occurances.
double m_V0_BeforeSpeedLimit
double m_T_BeforeGradient
double m_A_BeforeGradient
double m_B_BeforeGradient
double m_V0_BeforeGradient
double m_V0_Initial
double m_speed
double LANECHANGE_MIN_GAP
double SAFE_BRAKING
bool A_FLAG
double A_MIN
bool B_FLAG
double T_SLOPE
double V0_MIN
double V0_SLOPE


Detailed Description

A class representing the IDM driver model.

Definition at line 9 of file IDM.h.


Constructor & Destructor Documentation

IDM::IDM (  ) 

Definition at line 8 of file IDM.cpp.

References CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Param_Modifiers::A_FLAG, A_FLAG, CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Param_Modifiers::A_MIN, A_MIN, CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Param_Modifiers::B_FLAG, B_FLAG, CConfigData::Road_Config::RoadFeatures_Config::Gradient, CConfigData::IDM, CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Modifiers, CConfigData::IDM_Config::LANECHANGE_MIN_GAP, LANECHANGE_MIN_GAP, m_A, m_A_BeforeGradient, m_B, m_B_BeforeGradient, m_Bias, m_Delta, m_DeltaAth, m_Polite, m_S0, m_S1, m_T, m_T_BeforeGradient, m_V0, m_V0_BeforeGradient, m_V0_BeforeSpeedLimit, m_V0_Initial, CConfigData::Road, CConfigData::Road_Config::RoadFeatures, CConfigData::IDM_Config::SAFE_BRAKING, SAFE_BRAKING, CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Param_Modifiers::T_SLOPE, T_SLOPE, CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Param_Modifiers::V0_MIN, V0_MIN, CConfigData::Road_Config::RoadFeatures_Config::Gradient_Config::IDM_Param_Modifiers::V0_SLOPE, and V0_SLOPE.

IDM::~IDM (  )  [virtual]

Definition at line 40 of file IDM.cpp.

00041 {
00042 
00043 }


Member Function Documentation

double IDM::update ( double  vel,
double  dist 
) [virtual]

Updates the IDM's acceleration.

Parameters:
vel The vehicle's velocity
dist The distance to the next vehicle
Returns:
The new acceleration
This function updates the acceleration of the IDM based on the current velocity and the distance to the next vehicle

Implements DriverModel.

Definition at line 56 of file IDM.cpp.

References dvdt().

00057 {
00058         double accel = dvdt(vel, dist);
00059         return accel;
00060 }

Here is the call graph for this function:

double IDM::get_T (  ) 

Definition at line 169 of file IDM.cpp.

References m_T.

Referenced by Vehicle::getDataString().

00170 {
00171         // Unit - input: secs
00172         //              - output: secs
00173         return m_T;
00174 }

double IDM::get_A (  ) 

Definition at line 186 of file IDM.cpp.

References m_A.

Referenced by Vehicle::getDataString().

00187 {
00188         // Unit - input: m/s^2
00189         //              - output: m/s^2 
00190         return m_A;
00191 }

double IDM::get_B (  ) 

Definition at line 203 of file IDM.cpp.

References m_B.

Referenced by Vehicle::getDataString().

00204 {
00205         // Unit - input: m/s^2
00206         //              - output: m/s^2 
00207         return m_B;
00208 }

double IDM::get_S0 (  ) 

Definition at line 219 of file IDM.cpp.

References m_S0.

Referenced by Vehicle::getDataString().

00220 {
00221         // Unit - input: m
00222         //              - output: m     
00223         return m_S0;
00224 }

double IDM::get_S1 (  ) 

Definition at line 235 of file IDM.cpp.

References m_S1.

Referenced by Vehicle::getDataString().

00236 {
00237         // Unit - input: m
00238         //              - output: m     
00239         return m_S1;
00240 }

double IDM::get_V0 (  ) 

Definition at line 253 of file IDM.cpp.

References m_V0.

Referenced by Vehicle::getDataString().

00254 {
00255         // Unit - input: m/s
00256         //              - output: m/s //km/h    
00257         return m_V0;// * M_PER_S_TO_KM_PER_H;
00258 }

double IDM::get_Delta (  ) 

Definition at line 269 of file IDM.cpp.

References m_Delta.

Referenced by Vehicle::getDataString().

00270 {
00271         // Unit - input: none
00272         //              - output: none
00273         return m_Delta;
00274 }

double IDM::get_Polite (  ) 

Definition at line 285 of file IDM.cpp.

References m_Polite.

Referenced by Vehicle::getDataString().

00286 {
00287         // Unit - input: none
00288         //              - output: none
00289         return m_Polite;
00290 }

double IDM::get_Bias (  ) 

Definition at line 301 of file IDM.cpp.

References m_Bias.

Referenced by Vehicle::getDataString().

00302 {
00303         // Unit - input: none
00304         //              - output: none
00305         return m_Bias;
00306 }

double IDM::get_DeltaAth (  ) 

Definition at line 317 of file IDM.cpp.

References m_DeltaAth.

Referenced by Vehicle::getDataString().

00318 {
00319         // Unit - input: none
00320         //              - output: none
00321         return m_DeltaAth;
00322 }

void IDM::set_T ( double  val  ) 

Definition at line 162 of file IDM.cpp.

References m_T.

Referenced by CIDMParameterSet::Generate().

00163 {
00164         // Unit - input: secs
00165         //              - output: secs
00166         m_T = val;
00167 }

void IDM::set_A ( double  val  ) 

Definition at line 178 of file IDM.cpp.

References m_A.

Referenced by CIDMParameterSet::Generate().

00179 {
00180         // Unit - input: m/s^2
00181         //              - output: m/s^2
00182         m_A = val;
00183         ASSERT(m_A > 0);
00184 }

void IDM::set_B ( double  val  ) 

Definition at line 195 of file IDM.cpp.

References m_B.

Referenced by CIDMParameterSet::Generate().

00196 {
00197         // Unit - input: m/s^2
00198         //              - output: m/s^2 
00199         m_B = val;
00200         ASSERT(m_B > 0);
00201 }

void IDM::set_S0 ( double  val  ) 

Definition at line 212 of file IDM.cpp.

References m_S0.

Referenced by CIDMParameterSet::Generate().

00213 {
00214         // Unit - input: m
00215         //              - output: m     
00216         m_S0 = val;
00217 }

void IDM::set_S1 ( double  val  ) 

Definition at line 228 of file IDM.cpp.

References m_S1.

Referenced by CIDMParameterSet::Generate().

00229 {
00230         // Unit - input: m
00231         //              - output: m     
00232         m_S1 = val;
00233 }

void IDM::set_V0 ( double  val  ) 

Definition at line 244 of file IDM.cpp.

References KM_PER_H_TO_M_PER_S, m_V0, and m_V0_Initial.

Referenced by CIDMParameterSet::Generate().

00245 {
00246         // Unit - input: km/h
00247         //              - output: m/s   
00248         m_V0 = val * KM_PER_H_TO_M_PER_S;
00249         m_V0_Initial = m_V0;
00250         ASSERT(m_V0 > 0);
00251 }

void IDM::set_Delta ( double  val  ) 

Definition at line 262 of file IDM.cpp.

References m_Delta.

Referenced by CIDMParameterSet::Generate().

00263 {
00264         // Unit - input: none
00265         //              - output: none
00266         m_Delta = val;
00267 }

void IDM::set_Polite ( double  val  ) 

Definition at line 278 of file IDM.cpp.

References m_Polite.

Referenced by CIDMParameterSet::Generate().

00279 {
00280         // Unit - input: none
00281         //              - output: none
00282         m_Polite = val;
00283 }

void IDM::set_Bias ( double  val  ) 

Definition at line 294 of file IDM.cpp.

References m_Bias.

Referenced by CIDMParameterSet::Generate().

00295 {
00296         // Unit - input: none
00297         //              - output: none
00298         m_Bias = val;
00299 }

void IDM::set_DeltaAth ( double  val  ) 

Definition at line 310 of file IDM.cpp.

References m_DeltaAth.

Referenced by CIDMParameterSet::Generate().

00311 {
00312         // Unit - input: none
00313         //              - output: none
00314         m_DeltaAth = val;
00315 }

void IDM::ClearRestriction (  )  [virtual]

Clears all restrictions on the IDM.

This function removes all of the speed/gradient restrictions on an IDM, and is only called once the IDM's vehicle has left all previous road segments and has not entered another one. The desired velocity of the IDM is set back to its original desired velocity

Reimplemented from DriverModel.

Definition at line 439 of file IDM.cpp.

References m_V0, and m_V0_Initial.

00440 {
00441         // This is only called if we are entering a clear road and
00442         // have already been removed from all segments.
00443         m_V0 = m_V0_Initial;
00444 }

void IDM::ClearGradient (  )  [virtual]

Clears all gradient restrictions on the IDM.

This function removes all of the restrictions imposed upon an IDM when the IDM's vehicle enters a gradient road segment. The variables affected are all set back to the value they were previous to the vehicle entering the gradient segment.

Reimplemented from DriverModel.

Definition at line 417 of file IDM.cpp.

References m_A, m_A_BeforeGradient, m_B, m_B_BeforeGradient, DriverModel::m_bInGradient, m_T, m_T_BeforeGradient, m_V0, and m_V0_BeforeGradient.

00418 {
00419         if(!m_bInGradient)
00420                 TRACE("***Grad: Removed but not in\n");
00421         ASSERT(m_V0_BeforeGradient > 0);        // if this happens it means vehicle wasn't added to segment but was removed from it
00422 
00423         m_bInGradient = false;
00424         m_T = m_T_BeforeGradient;
00425         m_A = m_A_BeforeGradient;
00426         m_B = m_B_BeforeGradient;
00427         m_V0 = m_V0_BeforeGradient;
00428 }

void IDM::SetGradient ( double  gradient  )  [virtual]

Reimplemented from DriverModel.

Definition at line 348 of file IDM.cpp.

References A_FLAG, A_MIN, B_FLAG, KM_PER_H_TO_M_PER_S, m_A, m_A_BeforeGradient, m_B, m_B_BeforeGradient, DriverModel::m_bInGradient, DriverModel::m_bInSpeedLimit, m_T, m_T_BeforeGradient, m_V0, m_V0_BeforeGradient, m_V0_Initial, T_SLOPE, V0_MIN, and V0_SLOPE.

00349 {
00350         m_bInGradient = true;   
00351         m_A_BeforeGradient = m_A;       m_T_BeforeGradient = m_T;
00352         m_B_BeforeGradient = m_B;       m_V0_BeforeGradient = m_V0;
00353         
00354         // increase T - regardless of uphill or downhill
00355         double ABSgradient = gradient < 0 ? -gradient : gradient;
00356         m_T += ABSgradient/T_SLOPE;     
00357         
00358         // Reduce A - for uphill
00359         // MAGIC NUMBER 10 accounts for component of gravity acceleration
00360         // parallel to road surface - sin of small angle
00361         if(A_FLAG)
00362         {
00363                 m_A -= gradient/10;
00364                 m_A = m_A < A_MIN ? A_MIN : m_A;        // set to min at least
00365         }
00366         
00367         // Increase B for uphill only - MAGIC NUMBER 10 as for A
00368         if(B_FLAG && gradient > 0)
00369                 m_B += gradient/10;     
00370         
00371         // Reduce V0 for uphill only
00372         if(gradient > 0)
00373         {
00374                 // reduce V0 from the 'free' desired velocity
00375                 // so if not in speed limit zone, we're free to reduce to gradient, else
00376                 if(!m_bInSpeedLimit)
00377                         m_V0 -= (gradient/V0_SLOPE)*KM_PER_H_TO_M_PER_S;        
00378                 else    // we're in a speed limit so see if speed limit or gradient governs V0
00379                 {
00380                         double FreeV0 = m_V0_Initial;   // Do NOT change value of m_V0_BeforeSpeedLimit here!
00381                         double SpeedLimitV0 = m_V0;
00382                         double GradientV0 = FreeV0 - (gradient/V0_SLOPE)*KM_PER_H_TO_M_PER_S;
00383                         m_V0 = SpeedLimitV0 < GradientV0 ? SpeedLimitV0 : GradientV0;
00384                 }
00385                 if(m_V0 < V0_MIN)
00386                 {
00387                         //TRACE("*** V0 of: %f\t set to: %f\n",m_V0, V0_MIN);
00388                         m_V0 = V0_MIN;  // set to min at least
00389                 }
00390         }       // end if gradient uphill
00391 }

void IDM::ClearSpeedLimit (  )  [virtual]

Clears all speedlimit restrictions on the IDM.

This function removes the speed restriction imposed upon an IDM when the IDM's vehicle enters a speedlimit road segment. The desired velocity of the vehicle is set back to the value it was previous to the vehicle entering the speedlimit segment

Reimplemented from DriverModel.

Definition at line 400 of file IDM.cpp.

References DriverModel::m_bInSpeedLimit, m_V0, and m_V0_BeforeSpeedLimit.

00401 {
00402         if(!m_bInSpeedLimit)
00403                 TRACE("***SL: Removed but not in\n");
00404         ASSERT(m_V0_BeforeSpeedLimit > 0);      // if this happens it means vehicle wasn't added to segment but was removed from it
00405         m_bInSpeedLimit = false;
00406         m_V0 = m_V0_BeforeSpeedLimit;
00407 }

void IDM::SetSpeedLimit ( double  newV0  )  [virtual]

Sets the properties for an IDM entering a speedlimit.

Parameters:
newV0 The new desired velocity of the IDM
This function deals with setting the properties for when an IDM enters a speedlimit segment. It takes note that it is currently in a speedlimit, and takes note of the desired velocity before the segment was entered. The desired velocity of the IDM is set to the given desired velocity

Reimplemented from DriverModel.

Definition at line 335 of file IDM.cpp.

References DriverModel::m_bInSpeedLimit, m_V0, and m_V0_BeforeSpeedLimit.

00336 {
00337         m_bInSpeedLimit = true;
00338         m_V0_BeforeSpeedLimit = m_V0;
00339 
00340         m_V0 = newV0;
00341         ASSERT(m_V0 > 0);
00342         ASSERT(m_V0_BeforeSpeedLimit > 0);
00343 }

double IDM::getDesiredVel (  )  [virtual]

Gets the desired velocity of the IDM.

Returns:
The IDM's desired velocity

Implements DriverModel.

Definition at line 105 of file IDM.cpp.

References m_V0.

00106 {
00107         return m_V0;
00108 }

void IDM::setVel ( double  vel  )  [virtual]

Sets the velocity of the IDM.

Parameters:
vel The velocity to set

Implements DriverModel.

Definition at line 96 of file IDM.cpp.

References m_speed.

00097 {
00098         m_speed = vel;
00099 }

double IDM::LaneChange ( double  GapToFront,
double  GapToBack,
double  FrontChangeAccel,
double  CurrentBackAccel,
double  ProposedBackAccel,
bool  overtake 
) [virtual]

Finds the advantage that a vehicle would gain from changing lane.

Parameters:
GapToFront The gap to the vehicle in front in the new lane
GapToBack The gap to the vehicle behind in the new lane
FrontChangeAccel The change in acceleration the vehicle will experience with a new front vehicle
CurrentBackAccel The current acceleration of the vehicle behind in the new lane
ProposedBackAccel The new acceleration the vehicle behind will experience with a new front vehicle
overtake Whether or not the vehicle is overtaking
Returns:
The net advantage of the change
This function finds the net advantage (the vehicle's own advantage minus the disadvantage of others) that occurs due to a vehicle changing lane. The advantage is seen as the extra acceleration gained from changing lane, while the disadvantage is considered to be the deceleration that other vehicles have to undertake in order to allow the change to take place.

Implements DriverModel.

Definition at line 129 of file IDM.cpp.

References LANECHANGE_MIN_GAP, m_Bias, m_DeltaAth, m_Polite, and SAFE_BRAKING.

00131 {
00132         double advantage = 0.0;
00133         double othersDisadv = 0.0;
00134         double netAdvantage = 0.0;
00135 
00136         if(GapToFront >= LANECHANGE_MIN_GAP && GapToBack >= LANECHANGE_MIN_GAP && ProposedBackAccel >= SAFE_BRAKING)
00137         {
00138                 advantage = FrontChangeAccel + (overtake ? -1 : 1) * m_Bias;
00139                 othersDisadv = CurrentBackAccel - ProposedBackAccel;
00140         }
00141 
00142         if(othersDisadv < 0.0)
00143                 othersDisadv = 0.0;
00144 
00145         netAdvantage = advantage - othersDisadv * m_Polite;
00146 
00147         if(netAdvantage <= m_DeltaAth)  // if it's under the threshold
00148                 netAdvantage = 0.0;
00149 
00150         return netAdvantage;
00151 }

double IDM::s_star ( double  vel  )  [private]

Definition at line 78 of file IDM.cpp.

References m_A, m_B, m_S0, m_S1, m_speed, m_T, and m_V0.

Referenced by dvdt().

00079 {
00080         // Desired gap
00081         ASSERT(m_V0 > 0);       // it has to be because of the division & sqrt below
00082         ASSERT(m_A > 0);
00083         ASSERT(m_B > 0);
00084         double s_str = m_S0 + m_S1 * sqrt(m_speed/m_V0) 
00085                 + m_T*m_speed + (m_speed*dv)/(2*sqrt(m_A*m_B));
00086 
00087         return s_str;
00088 }

double IDM::dvdt ( double  m_speed,
double  s 
) [private]

Definition at line 62 of file IDM.cpp.

References m_A, m_Delta, m_speed, m_V0, s_star(), and SAFE_BRAKING.

Referenced by update().

00063 {
00064         double s_str = s_star(dv);
00065         double intel_acc = m_A*(1-pow(m_speed/m_V0,m_Delta));
00066         double intel_dec = -m_A*pow(s_str/s,2);
00067 
00068         double net_acc = intel_acc + intel_dec;
00069 
00070         // THIS NEEDS TO BE CAPPED OR BREAKDOWN OCCURS (net_acc ~ -30000)
00071         // Test value of -100 given
00072         if(net_acc < SAFE_BRAKING)
00073                 net_acc = SAFE_BRAKING;
00074 
00075         return net_acc;
00076 }

Here is the call graph for this function:


Member Data Documentation

double IDM::m_T [private]

Safe time headway.

Definition at line 44 of file IDM.h.

Referenced by ClearGradient(), get_T(), IDM(), s_star(), set_T(), and SetGradient().

double IDM::m_A [private]

Maximum acceleration.

Definition at line 46 of file IDM.h.

Referenced by ClearGradient(), dvdt(), get_A(), IDM(), s_star(), set_A(), and SetGradient().

double IDM::m_B [private]

Desired deceleration.

Definition at line 48 of file IDM.h.

Referenced by ClearGradient(), get_B(), IDM(), s_star(), set_B(), and SetGradient().

double IDM::m_S0 [private]

Definition at line 50 of file IDM.h.

Referenced by get_S0(), IDM(), s_star(), and set_S0().

double IDM::m_S1 [private]

Definition at line 52 of file IDM.h.

Referenced by get_S1(), IDM(), s_star(), and set_S1().

double IDM::m_V0 [private]

double IDM::m_Delta [private]

Definition at line 56 of file IDM.h.

Referenced by dvdt(), get_Delta(), IDM(), and set_Delta().

double IDM::m_Polite [private]

MOBIL: Consideration towards other drivers.

Definition at line 59 of file IDM.h.

Referenced by get_Polite(), IDM(), LaneChange(), and set_Polite().

double IDM::m_Bias [private]

MOBIL: Desire to keep to slow lane.

Definition at line 61 of file IDM.h.

Referenced by get_Bias(), IDM(), LaneChange(), and set_Bias().

double IDM::m_DeltaAth [private]

MOBIL: Dampens overtaking occurances.

Definition at line 63 of file IDM.h.

Referenced by get_DeltaAth(), IDM(), LaneChange(), and set_DeltaAth().

double IDM::m_V0_BeforeSpeedLimit [private]

Definition at line 65 of file IDM.h.

Referenced by ClearSpeedLimit(), IDM(), and SetSpeedLimit().

double IDM::m_T_BeforeGradient [private]

Definition at line 66 of file IDM.h.

Referenced by ClearGradient(), IDM(), and SetGradient().

double IDM::m_A_BeforeGradient [private]

Definition at line 67 of file IDM.h.

Referenced by ClearGradient(), IDM(), and SetGradient().

double IDM::m_B_BeforeGradient [private]

Definition at line 68 of file IDM.h.

Referenced by ClearGradient(), IDM(), and SetGradient().

double IDM::m_V0_BeforeGradient [private]

Definition at line 69 of file IDM.h.

Referenced by ClearGradient(), IDM(), and SetGradient().

double IDM::m_V0_Initial [private]

Definition at line 70 of file IDM.h.

Referenced by ClearRestriction(), IDM(), set_V0(), and SetGradient().

double IDM::m_speed [private]

Definition at line 93 of file IDM.h.

Referenced by dvdt(), s_star(), and setVel().

double IDM::LANECHANGE_MIN_GAP [private]

Definition at line 97 of file IDM.h.

Referenced by IDM(), and LaneChange().

double IDM::SAFE_BRAKING [private]

Definition at line 98 of file IDM.h.

Referenced by dvdt(), IDM(), and LaneChange().

bool IDM::A_FLAG [private]

Definition at line 99 of file IDM.h.

Referenced by IDM(), and SetGradient().

double IDM::A_MIN [private]

Definition at line 100 of file IDM.h.

Referenced by IDM(), and SetGradient().

bool IDM::B_FLAG [private]

Definition at line 101 of file IDM.h.

Referenced by IDM(), and SetGradient().

double IDM::T_SLOPE [private]

Definition at line 102 of file IDM.h.

Referenced by IDM(), and SetGradient().

double IDM::V0_MIN [private]

Definition at line 103 of file IDM.h.

Referenced by IDM(), and SetGradient().

double IDM::V0_SLOPE [private]

Definition at line 104 of file IDM.h.

Referenced by IDM(), and SetGradient().


The documentation for this class was generated from the following files:

Generated on Wed Aug 20 00:48:47 2008 for EvolveTraffic by  doxygen 1.5.6