SUMO - Simulation of Urban MObility

MSCFModel.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // The car-following model abstraction
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_h
00020 #define MSCFModel_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 <cassert>
00032 #include <string>
00033 #include <utils/common/StdDefs.h>
00034 #include <utils/common/FileHelpers.h>
00035 
00036 
00037 // ===========================================================================
00038 // class declarations
00039 // ===========================================================================
00040 class MSVehicleType;
00041 class MSVehicle;
00042 class MSLane;
00043 
00044 
00045 // ===========================================================================
00046 // class definitions
00047 // ===========================================================================
00055 class MSCFModel {
00056 public:
00057 
00058     class VehicleVariables {
00059     };
00060 
00064     MSCFModel(const MSVehicleType* vtype, SUMOReal accel, SUMOReal decel, SUMOReal headwayTime);
00065 
00066 
00068     virtual ~MSCFModel();
00069 
00070 
00073 
00079     virtual SUMOReal moveHelper(MSVehicle* const veh, SUMOReal vPos) const;
00080 
00081 
00091     virtual SUMOReal freeSpeed(const MSVehicle* const veh, SUMOReal speed, SUMOReal seen, SUMOReal maxSpeed) const {
00092         return followSpeed(veh, speed, seen, maxSpeed, 0);
00093     }
00094 
00095 
00105     virtual SUMOReal followSpeed(const MSVehicle* const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const = 0;
00106 
00107 
00116     virtual SUMOReal stopSpeed(const MSVehicle* const veh, SUMOReal gap2pred) const = 0;
00117 
00118 
00127     virtual SUMOReal interactionGap(const MSVehicle* const veh, SUMOReal vL) const;
00128 
00129 
00133     virtual void saveState(std::ostream& os);
00134 
00135 
00139     virtual int getModelID() const = 0;
00140 
00141 
00146     virtual MSCFModel* duplicate(const MSVehicleType* vtype) const = 0;
00147 
00148 
00152     virtual VehicleVariables* createVehicleVariables() const {
00153         return 0;
00154     }
00156 
00157 
00160 
00164     virtual SUMOReal getMaxAccel() const {
00165         return myAccel;
00166     }
00167 
00168 
00172     virtual SUMOReal getMaxDecel() const {
00173         return myDecel;
00174     }
00175 
00176 
00180     virtual SUMOReal getImperfection() const {
00181         return -1;
00182     }
00183 
00184 
00188     virtual SUMOReal getHeadwayTime() const {
00189         return myHeadwayTime;
00190     }
00192 
00193 
00194 
00197 
00205     void leftVehicleVsafe(const MSVehicle* const ego, const MSVehicle* const neigh, SUMOReal& vSafe) const;
00206 
00207 
00219     SUMOReal maxNextSpeed(SUMOReal speed) const;
00220 
00221 
00226     SUMOReal brakeGap(SUMOReal speed) const;
00227 
00228 
00234     SUMOReal getSecureGap(const SUMOReal speed, const SUMOReal leaderSpeed, const SUMOReal leaderMaxDecel) const {
00235         const int leaderSteps = int(leaderSpeed / ACCEL2SPEED(leaderMaxDecel));
00236         const SUMOReal leaderBreak = SPEED2DIST(leaderSteps * leaderSpeed - ACCEL2SPEED(leaderMaxDecel) * leaderSteps * (leaderSteps+1) / 2);
00237         return MAX2((SUMOReal) 0, brakeGap(speed) - leaderBreak);
00238     }
00239 
00240 
00245     SUMOReal getSpeedAfterMaxDecel(SUMOReal v) const {
00246         return MAX2((SUMOReal) 0, v - (SUMOReal) ACCEL2SPEED(myDecel));
00247     }
00249 
00250 
00253 
00257     virtual void setMaxAccel(SUMOReal accel) {
00258         myAccel = accel;
00259     }
00260 
00261 
00265     virtual void setMaxDecel(SUMOReal decel) {
00266         myDecel = decel;
00267     }
00268 
00269 
00273     virtual void setImperfection(SUMOReal imperfection) {
00274         UNUSED_PARAMETER(imperfection);
00275     }
00276 
00277 
00281     virtual void setHeadwayTime(SUMOReal headwayTime) {
00282         myHeadwayTime = headwayTime;
00283     }
00285 
00286 
00287 protected:
00289     const MSVehicleType* myType;
00290 
00292     SUMOReal myAccel;
00293 
00295     SUMOReal myDecel;
00296 
00298     SUMOReal myHeadwayTime;
00299 };
00300 
00301 
00302 #endif  /* MSCFModel_h */
00303 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines