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