MSLCM_DK2004.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 //  »missingDescription«
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 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 MSLCM_DK2004_h
00020 #define MSLCM_DK2004_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
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 // enumeration definition
00038 // ===========================================================================
00039 enum MyLCAEnum {
00040     LCA_AMBLOCKINGLEADER = 256, // 0
00041     LCA_AMBLOCKINGFOLLOWER = 512,// 1
00042     LCA_MRIGHT = 1024, // 2
00043     LCA_MLEFT = 2048,// 3
00044     LCA_UNBLOCK = 4096,// 4
00045     LCA_AMBLOCKINGFOLLOWER_DONTBRAKE = 8192,// 5
00046     LCA_AMBLOCKINGSECONDFOLLOWER = 16384, // 6
00047     LCA_KEEP1 = 65536,// 8
00048     LCA_KEEP2 = 131072,// 9
00049     LCA_AMBACKBLOCKER = 262144,// 10
00050     LCA_AMBACKBLOCKER_STANDING = 524288// 11
00051 
00052 };
00053 
00054 // ===========================================================================
00055 // class definitions
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         int bestLaneOffset, SUMOReal bestDist, SUMOReal neighDist,
00078         SUMOReal currentDist,
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         //        bool congested, bool predInteraction,
00094         int bestLaneOffset, SUMOReal bestDist, SUMOReal neighDist,
00095         SUMOReal currentDist,
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     void unblockLeader();
00117     void unblockFollower();
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 

Generated on Wed May 5 00:06:32 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6