SUMO - Simulation of Urban MObility
MSCFModel_IDM.h
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // The Intelligent Driver Model (IDM) car-following model
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 #ifndef MSCFMODEL_IDM_H
00023 #define MSCFMODEL_IDM_H
00024 
00025 // ===========================================================================
00026 // included modules
00027 // ===========================================================================
00028 #ifdef _MSC_VER
00029 #include <windows_config.h>
00030 #else
00031 #include <config.h>
00032 #endif
00033 
00034 #include <microsim/MSCFModel.h>
00035 #include <microsim/MSLane.h>
00036 #include <microsim/MSVehicle.h>
00037 #include <microsim/MSVehicleType.h>
00038 #include <utils/xml/SUMOXMLDefinitions.h>
00039 
00040 
00041 // ===========================================================================
00042 // class definitions
00043 // ===========================================================================
00048 class MSCFModel_IDM : public MSCFModel {
00049 public:
00057     MSCFModel_IDM(const MSVehicleType* vtype, SUMOReal accel, SUMOReal decel,
00058                   SUMOReal headwayTime, SUMOReal delta, SUMOReal internalStepping);
00059 
00060 
00069     MSCFModel_IDM(const MSVehicleType* vtype, SUMOReal accel, SUMOReal decel,
00070                   SUMOReal headwayTime, SUMOReal adaptationFactor, SUMOReal adaptationTime,
00071                   SUMOReal internalStepping);
00072 
00073 
00075     ~MSCFModel_IDM();
00076 
00077 
00080 
00086     SUMOReal moveHelper(MSVehicle* const veh, SUMOReal vPos) const;
00087 
00088 
00097     SUMOReal followSpeed(const MSVehicle* const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const;
00098 
00099 
00107     SUMOReal stopSpeed(const MSVehicle* const veh, SUMOReal gap2pred) const;
00108 
00109 
00119     SUMOReal interactionGap(const MSVehicle* const , SUMOReal vL) const;
00120 
00121 
00126     int getModelID() const {
00127         return myExpFactor > 0. ? SUMO_TAG_CF_IDMM : SUMO_TAG_CF_IDM;
00128     }
00130 
00131 
00132 
00137     MSCFModel* duplicate(const MSVehicleType* vtype) const;
00138 
00139 
00140     VehicleVariables* createVehicleVariables() const {
00141         if (myExpFactor > 0.) {
00142             return new VehicleVariables();
00143         }
00144         return 0;
00145     }
00146 
00147 
00148 private:
00149     class VehicleVariables : public MSCFModel::VehicleVariables {
00150     public:
00151         VehicleVariables() : levelOfService(1.) {}
00153         SUMOReal levelOfService;
00154     };
00155 
00156 
00157 private:
00158     SUMOReal _v(const MSVehicle* const veh, SUMOReal gap2pred, SUMOReal mySpeed, SUMOReal predSpeed, SUMOReal desSpeed) const;
00159 
00160     SUMOReal desiredSpeed(const MSVehicle* const veh) const {
00161         return MIN2(myType->getMaxSpeed(), veh->getLane()->getMaxSpeed());
00162     }
00163 
00164 
00165 private:
00167     const SUMOReal myDelta;
00168 
00170     const SUMOReal myAdaptationFactor;
00171 
00173     const SUMOReal myAdaptationTime;
00174 
00176     const SUMOReal myExpFactor;
00177 
00179     const int myIterations;
00180 
00182     const SUMOReal myTwoSqrtAccelDecel;
00183 };
00184 
00185 #endif  /* MSCFMODEL_IDM_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines