|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // The Intelligent Driver Model (IDM) car-following model 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef MSCFMODEL_IDM_H 00020 #define MSCFMODEL_IDM_H 00021 00022 // =========================================================================== 00023 // included modules 00024 // =========================================================================== 00025 #ifdef _MSC_VER 00026 #include <windows_config.h> 00027 #else 00028 #include <config.h> 00029 #endif 00030 00031 #include <microsim/MSCFModel.h> 00032 #include <microsim/MSLane.h> 00033 #include <microsim/MSVehicle.h> 00034 #include <microsim/MSVehicleType.h> 00035 #include <utils/xml/SUMOXMLDefinitions.h> 00036 00037 00038 // =========================================================================== 00039 // class definitions 00040 // =========================================================================== 00045 class MSCFModel_IDM : public MSCFModel { 00046 public: 00054 MSCFModel_IDM(const MSVehicleType* vtype, SUMOReal accel, SUMOReal decel, 00055 SUMOReal headwayTime, SUMOReal delta, SUMOReal internalStepping); 00056 00057 00066 MSCFModel_IDM(const MSVehicleType* vtype, SUMOReal accel, SUMOReal decel, 00067 SUMOReal headwayTime, SUMOReal adaptationFactor, SUMOReal adaptationTime, 00068 SUMOReal internalStepping); 00069 00070 00072 ~MSCFModel_IDM(); 00073 00074 00077 00083 SUMOReal moveHelper(MSVehicle* const veh, SUMOReal vPos) const; 00084 00085 00094 SUMOReal followSpeed(const MSVehicle* const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const; 00095 00096 00104 SUMOReal stopSpeed(const MSVehicle* const veh, SUMOReal gap2pred) const; 00105 00106 00116 SUMOReal interactionGap(const MSVehicle* const , SUMOReal vL) const; 00117 00118 00123 int getModelID() const { 00124 return myExpFactor > 0. ? SUMO_TAG_CF_IDMM : SUMO_TAG_CF_IDM; 00125 } 00127 00128 00129 00134 MSCFModel* duplicate(const MSVehicleType* vtype) const; 00135 00136 00137 VehicleVariables* createVehicleVariables() const { 00138 if (myExpFactor > 0.) { 00139 return new VehicleVariables(); 00140 } 00141 return 0; 00142 } 00143 00144 00145 private: 00146 class VehicleVariables : public MSCFModel::VehicleVariables { 00147 public: 00148 VehicleVariables() : levelOfService(1.) {} 00150 SUMOReal levelOfService; 00151 }; 00152 00153 00154 private: 00155 SUMOReal _v(const MSVehicle* const veh, SUMOReal gap2pred, SUMOReal mySpeed, SUMOReal predSpeed, SUMOReal desSpeed) const; 00156 00157 SUMOReal desiredSpeed(const MSVehicle* const veh) const { 00158 return MIN2(myType->getMaxSpeed(), veh->getLane()->getMaxSpeed()); 00159 } 00160 00161 00162 private: 00164 const SUMOReal myDelta; 00165 00167 const SUMOReal myAdaptationFactor; 00168 00170 const SUMOReal myAdaptationTime; 00171 00173 const SUMOReal myExpFactor; 00174 00176 const int myIterations; 00177 00179 const SUMOReal myTwoSqrtAccelDecel; 00180 }; 00181 00182 #endif /* MSCFMODEL_IDM_H */