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-2014 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 
151  inline bool amBlockingLeader() {
152  return (myOwnState & LCA_AMBLOCKINGLEADER) != 0;
153  }
154  inline bool amBlockingFollower() {
155  return (myOwnState & LCA_AMBLOCKINGFOLLOWER) != 0;
156  }
157  inline bool amBlockingFollowerNB() {
159  }
160  inline bool amBlockingFollowerPlusNB() {
162  }
163  inline bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
164  return dist / (abs(laneOffset)) < lookForwardDist;
165  }
166  inline bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
167  return dist / abs(laneOffset) > lookForwardDist;
168  }
169 
171  typedef std::pair<SUMOReal, int> Info;
172 
173 
174 
175 protected:
178  /* @brief a value for tracking the probability of following the/"Rechtsfahrgebot"
179  * A larger negative value indicates higher probability for moving to the
180  * right (as in mySpeedGainProbability) */
182 
185 
186  /*@brief the speed to use when computing the look-ahead distance for
187  * determining urgency of strategic lane changes */
189 
190  std::vector<SUMOReal> myVSafes;
192 
193 };
194 
195 
196 #endif
197 
198 /****************************************************************************/
199