SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00010 // A lane change model developed by D. Krajzewicz between 2004 and 2010 00011 /****************************************************************************/ 00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00014 /****************************************************************************/ 00015 // 00016 // This file is part of SUMO. 00017 // SUMO is free software: you can redistribute it and/or modify 00018 // it under the terms of the GNU General Public License as published by 00019 // the Free Software Foundation, either version 3 of the License, or 00020 // (at your option) any later version. 00021 // 00022 /****************************************************************************/ 00023 #ifndef MSLCM_DK2004_h 00024 #define MSLCM_DK2004_h 00025 00026 00027 // =========================================================================== 00028 // included modules 00029 // =========================================================================== 00030 #ifdef _MSC_VER 00031 #include <windows_config.h> 00032 #else 00033 #include <config.h> 00034 #endif 00035 00036 #include <microsim/MSAbstractLaneChangeModel.h> 00037 #include <vector> 00038 00039 // =========================================================================== 00040 // enumeration definition 00041 // =========================================================================== 00042 enum MyLCAEnum { 00043 LCA_AMBLOCKINGLEADER = 256, // 0 00044 LCA_AMBLOCKINGFOLLOWER = 512,// 1 00045 LCA_MRIGHT = 1024, // 2 00046 LCA_MLEFT = 2048,// 3 00047 // !!! never set LCA_UNBLOCK = 4096,// 4 00048 LCA_AMBLOCKINGFOLLOWER_DONTBRAKE = 8192,// 5 00049 // !!! never used LCA_AMBLOCKINGSECONDFOLLOWER = 16384, // 6 00050 // !!! never read LCA_KEEP1 = 65536,// 8 00051 // !!! never used LCA_KEEP2 = 131072,// 9 00052 LCA_AMBACKBLOCKER = 262144,// 10 00053 LCA_AMBACKBLOCKER_STANDING = 524288// 11 00054 00055 }; 00056 00057 // =========================================================================== 00058 // class definitions 00059 // =========================================================================== 00064 class MSLCM_DK2004 : public MSAbstractLaneChangeModel { 00065 public: 00066 MSLCM_DK2004(MSVehicle& v); 00067 00068 virtual ~MSLCM_DK2004(); 00069 00073 virtual int wantsChangeToRight( 00074 MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked, 00075 const std::pair<MSVehicle*, SUMOReal> &leader, 00076 const std::pair<MSVehicle*, SUMOReal> &neighLead, 00077 const std::pair<MSVehicle*, SUMOReal> &neighFollow, 00078 const MSLane& neighLane, 00079 const std::vector<MSVehicle::LaneQ> &preb, 00080 MSVehicle** lastBlocked); 00081 00085 virtual int wantsChangeToLeft( 00086 MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked, 00087 const std::pair<MSVehicle*, SUMOReal> &leader, 00088 const std::pair<MSVehicle*, SUMOReal> &neighLead, 00089 const std::pair<MSVehicle*, SUMOReal> &neighFollow, 00090 const MSLane& neighLane, 00091 const std::vector<MSVehicle::LaneQ> &preb, 00092 MSVehicle** lastBlocked); 00093 00094 virtual void* inform(void* info, MSVehicle* sender); 00095 00104 virtual SUMOReal patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal max, 00105 const MSCFModel& cfModel); 00106 00107 virtual void changed(); 00108 00109 SUMOReal getProb() const; 00110 virtual void prepareStep(); 00111 00112 SUMOReal getChangeProbability() const { 00113 return myChangeProbability; 00114 } 00115 00116 00117 protected: 00118 void informBlocker(MSAbstractLaneChangeModel::MSLCMessager& msgPass, 00119 int& blocked, int dir, 00120 const std::pair<MSVehicle*, SUMOReal> &neighLead, 00121 const std::pair<MSVehicle*, SUMOReal> &neighFollow); 00122 00123 inline bool amBlockingLeader() { 00124 return (myOwnState & LCA_AMBLOCKINGLEADER) != 0; 00125 } 00126 inline bool amBlockingFollower() { 00127 return (myOwnState & LCA_AMBLOCKINGFOLLOWER) != 0; 00128 } 00129 inline bool amBlockingFollowerNB() { 00130 return (myOwnState & LCA_AMBLOCKINGFOLLOWER_DONTBRAKE) != 0; 00131 } 00132 inline bool amBlockingFollowerPlusNB() { 00133 return (myOwnState & (LCA_AMBLOCKINGFOLLOWER | LCA_AMBLOCKINGFOLLOWER_DONTBRAKE)) != 0; 00134 } 00135 inline bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) { 00136 return dist / (abs(laneOffset)) < lookForwardDist; 00137 } 00138 inline bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) { 00139 return dist / abs(laneOffset) > lookForwardDist; 00140 } 00141 00142 typedef std::pair<SUMOReal, int> Info; 00143 00144 00145 00146 protected: 00147 SUMOReal myChangeProbability; 00148 00149 SUMOReal myLeadingBlockerLength; 00150 SUMOReal myLeftSpace; 00151 00152 std::vector<SUMOReal> myVSafes; 00153 bool myDontBrake; 00154 00155 }; 00156 00157 00158 #endif 00159 00160 /****************************************************************************/ 00161