SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSLCM_LC2013.h
Go to the documentation of this file.
1 /****************************************************************************/
11 // A lane change model developed by D. Krajzewicz, J. Erdmann et al. between 2004 and 2013
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
14 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 #ifndef MSLCM_LC2013_h
25 #define MSLCM_LC2013_h
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
38 #include <vector>
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
50 public:
51 
52  enum MyLCAEnum {
55  LCA_MRIGHT = 1 << 18,
56  LCA_MLEFT = 1 << 19,
57  // !!! never set LCA_UNBLOCK = 1 << 20,
59  // !!! never used LCA_AMBLOCKINGSECONDFOLLOWER = 1 << 22,
60  LCA_CHANGE_TO_HELP = 1 << 23,
61  // !!! never read LCA_KEEP1 = 1 << 24,
62  // !!! never used LCA_KEEP2 = 1 << 25,
63  LCA_AMBACKBLOCKER = 1 << 26,
65  };
66 
67 
69 
70  virtual ~MSLCM_LC2013();
71 
76  int wantsChange(
77  int laneOffset,
78  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
79  const std::pair<MSVehicle*, SUMOReal>& leader,
80  const std::pair<MSVehicle*, SUMOReal>& neighLead,
81  const std::pair<MSVehicle*, SUMOReal>& neighFollow,
82  const MSLane& neighLane,
83  const std::vector<MSVehicle::LaneQ>& preb,
84  MSVehicle** lastBlocked,
85  MSVehicle** firstBlocked);
86 
87  void* inform(void* info, MSVehicle* sender);
88 
97  SUMOReal patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal max,
98  const MSCFModel& cfModel);
100  SUMOReal _patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal max,
101  const MSCFModel& cfModel);
102 
103  void changed();
104 
105  void prepareStep();
106 
107 
108 protected:
109 
111  int _wantsChange(
112  int laneOffset,
113  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
114  const std::pair<MSVehicle*, SUMOReal>& leader,
115  const std::pair<MSVehicle*, SUMOReal>& neighLead,
116  const std::pair<MSVehicle*, SUMOReal>& neighFollow,
117  const MSLane& neighLane,
118  const std::vector<MSVehicle::LaneQ>& preb,
119  MSVehicle** lastBlocked,
120  MSVehicle** firstBlocked);
121 
122 
123  /* @brief decide whether we will overtake or follow a blocking leader
124  * and inform it accordingly
125  * If we decide to follow, myVSafes will be extended
126  * returns the planned speed if following or -1 if overtaking */
128  int blocked, int dir,
129  const std::pair<MSVehicle*, SUMOReal>& neighLead,
130  SUMOReal remainingSeconds);
131 
134  int blocked, int dir,
135  const std::pair<MSVehicle*, SUMOReal>& neighFollow,
136  SUMOReal remainingSeconds,
137  SUMOReal plannedSpeed);
138 
139 
141  int slowDownForBlocked(MSVehicle** blocked, int state);
142 
144  void saveBlockerLength(MSVehicle* blocker, int lcaCounter);
145 
147  inline void saveBlockerLength(SUMOReal length) {
149  };
150 
152  void keepRight(MSVehicle* neigh);
153 
154  inline bool amBlockingLeader() {
155  return (myOwnState & LCA_AMBLOCKINGLEADER) != 0;
156  }
157  inline bool amBlockingFollower() {
158  return (myOwnState & LCA_AMBLOCKINGFOLLOWER) != 0;
159  }
160  inline bool amBlockingFollowerNB() {
162  }
163  inline bool amBlockingFollowerPlusNB() {
165  }
166  inline bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
167  return dist / (abs(laneOffset)) < lookForwardDist;
168  }
169  inline bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
170  return dist / abs(laneOffset) > lookForwardDist;
171  }
172 
174  typedef std::pair<SUMOReal, int> Info;
175 
176 
177 
178 protected:
183 
186 
187  /*@brief the speed to use when computing the look-ahead distance for
188  * determining urgency of strategic lane changes */
190 
191  std::vector<SUMOReal> myVSafes;
193 
194 };
195 
196 
197 #endif
198 
199 /****************************************************************************/
200