00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MSLCM_DK2004_h
00020 #define MSLCM_DK2004_h
00021
00022
00023
00024
00025
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031
00032 #include <microsim/MSAbstractLaneChangeModel.h>
00033 #include <microsim/MSVehicleQuitReminded.h>
00034 #include <vector>
00035
00036
00037
00038
00039 enum MyLCAEnum {
00040 LCA_AMBLOCKINGLEADER = 256,
00041 LCA_AMBLOCKINGFOLLOWER = 512,
00042 LCA_MRIGHT = 1024,
00043 LCA_MLEFT = 2048,
00044 LCA_UNBLOCK = 4096,
00045 LCA_AMBLOCKINGFOLLOWER_DONTBRAKE = 8192,
00046 LCA_AMBLOCKINGSECONDFOLLOWER = 16384,
00047 LCA_KEEP1 = 65536,
00048 LCA_KEEP2 = 131072,
00049 LCA_AMBACKBLOCKER = 262144,
00050 LCA_AMBACKBLOCKER_STANDING = 524288
00051
00052 };
00053
00054
00055
00056
00060 class MSLCM_DK2004 : public MSAbstractLaneChangeModel {
00061 public:
00062 MSLCM_DK2004(MSVehicle &v);
00063
00064 virtual ~MSLCM_DK2004();
00065
00069 virtual int wantsChangeToRight(
00070 MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked,
00071 const std::pair<MSVehicle*, SUMOReal> &leader,
00072 const std::pair<MSVehicle*, SUMOReal> &neighLead,
00073 const std::pair<MSVehicle*, SUMOReal> &neighFollow,
00074 const MSLane &neighLane,
00075 const std::vector<MSVehicle::LaneQ> &preb,
00076
00077
00078
00079
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
00093
00094
00095
00096
00097 MSVehicle **lastBlocked);
00098
00099 virtual void *inform(void *info, MSVehicle *sender);
00100
00101 virtual SUMOReal patchSpeed(SUMOReal min, SUMOReal wanted, SUMOReal max,
00102 SUMOReal vsafe);
00103
00104 virtual void changed();
00105
00106 SUMOReal getProb() const;
00107 virtual void prepareStep();
00108
00109 SUMOReal getChangeProbability() const {
00110 return myChangeProbability;
00111 }
00112
00113
00114 protected:
00115
00116
00117
00118
00119 void informBlocker(MSAbstractLaneChangeModel::MSLCMessager &msgPass,
00120 int &blocked, int dir,
00121 const std::pair<MSVehicle*, SUMOReal> &neighLead,
00122 const std::pair<MSVehicle*, SUMOReal> &neighFollow);
00123
00124 inline bool amBlockingLeader() {
00125 return (myState&LCA_AMBLOCKINGLEADER)!=0;
00126 }
00127 inline bool amBlockingFollower() {
00128 return (myState&LCA_AMBLOCKINGFOLLOWER)!=0;
00129 }
00130 inline bool amBlockingFollowerNB() {
00131 return (myState&LCA_AMBLOCKINGFOLLOWER_DONTBRAKE)!=0;
00132 }
00133 inline bool amBlockingFollowerPlusNB() {
00134 return (myState&(LCA_AMBLOCKINGFOLLOWER|LCA_AMBLOCKINGFOLLOWER_DONTBRAKE))!=0;
00135 }
00136 inline bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
00137 return dist/(abs(laneOffset))<lookForwardDist;
00138 }
00139 inline bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
00140 return dist/abs(laneOffset)>lookForwardDist;
00141 }
00142
00143 typedef std::pair<SUMOReal, int> Info;
00144
00145
00146
00147 protected:
00148 SUMOReal myChangeProbability;
00149 SUMOReal myVSafe;
00150 MSVehicle *myBlockingLeader;
00151 MSVehicle *myBlockingFollower;
00152 SUMOReal myUrgency;
00153 };
00154
00155
00156 #endif
00157
00158
00159