SUMO - Simulation of Urban MObility
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.dlr.de/
14 // Copyright (C) 2001-2016 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 
72  bool debugVehicle() const;
73 
78  int wantsChange(
79  int laneOffset,
80  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
81  const std::pair<MSVehicle*, SUMOReal>& leader,
82  const std::pair<MSVehicle*, SUMOReal>& neighLead,
83  const std::pair<MSVehicle*, SUMOReal>& neighFollow,
84  const MSLane& neighLane,
85  const std::vector<MSVehicle::LaneQ>& preb,
86  MSVehicle** lastBlocked,
87  MSVehicle** firstBlocked);
88 
89  void* inform(void* info, MSVehicle* sender);
90 
99  SUMOReal patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal max,
100  const MSCFModel& cfModel);
102  SUMOReal _patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal max,
103  const MSCFModel& cfModel);
104 
105  void changed();
106 
107  void prepareStep();
108 
109 
110 protected:
111 
113  int _wantsChange(
114  int laneOffset,
115  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
116  const std::pair<MSVehicle*, SUMOReal>& leader,
117  const std::pair<MSVehicle*, SUMOReal>& neighLead,
118  const std::pair<MSVehicle*, SUMOReal>& neighFollow,
119  const MSLane& neighLane,
120  const std::vector<MSVehicle::LaneQ>& preb,
121  MSVehicle** lastBlocked,
122  MSVehicle** firstBlocked);
123 
124 
125  /* @brief decide whether we will overtake or follow a blocking leader
126  * and inform it accordingly
127  * If we decide to follow, myVSafes will be extended
128  * returns the planned speed if following or -1 if overtaking */
130  int blocked, int dir,
131  const std::pair<MSVehicle*, SUMOReal>& neighLead,
132  SUMOReal remainingSeconds);
133 
136  int blocked, int dir,
137  const std::pair<MSVehicle*, SUMOReal>& neighFollow,
138  SUMOReal remainingSeconds,
139  SUMOReal plannedSpeed);
140 
141 
143  int slowDownForBlocked(MSVehicle** blocked, int state);
144 
146  void saveBlockerLength(MSVehicle* blocker, int lcaCounter);
147 
149  inline void saveBlockerLength(SUMOReal length) {
151  };
152 
153  inline bool amBlockingLeader() {
154  return (myOwnState & LCA_AMBLOCKINGLEADER) != 0;
155  }
156  inline bool amBlockingFollower() {
157  return (myOwnState & LCA_AMBLOCKINGFOLLOWER) != 0;
158  }
159  inline bool amBlockingFollowerNB() {
161  }
162  inline bool amBlockingFollowerPlusNB() {
164  }
165  inline bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
166  return dist / (abs(laneOffset)) < lookForwardDist;
167  }
168  inline bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
169  return dist / abs(laneOffset) > lookForwardDist;
170  }
171 
173  typedef std::pair<SUMOReal, int> Info;
174 
175 
176 
177 protected:
180  /* @brief a value for tracking the probability of following the/"Rechtsfahrgebot"
181  * A larger negative value indicates higher probability for moving to the
182  * right (as in mySpeedGainProbability) */
184 
187 
188  /*@brief the speed to use when computing the look-ahead distance for
189  * determining urgency of strategic lane changes */
191 
192  std::vector<SUMOReal> myVSafes;
194 
196 
202 
204 
205  // @brief willingness to encroach on other vehicles laterally (pushing them around)
209 };
210 
211 
212 #endif
213 
214 /****************************************************************************/
215 
bool debugVehicle() const
whether the current vehicles shall be debugged
void saveBlockerLength(MSVehicle *blocker, int lcaCounter)
save space for vehicles which need to counter-lane-change
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:81
MSLCM_LC2013(MSVehicle &v)
int wantsChange(int laneOffset, MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, const std::pair< MSVehicle *, SUMOReal > &leader, const std::pair< MSVehicle *, SUMOReal > &neighLead, const std::pair< MSVehicle *, SUMOReal > &neighFollow, const MSLane &neighLane, const std::vector< MSVehicle::LaneQ > &preb, MSVehicle **lastBlocked, MSVehicle **firstBlocked)
Called to examine whether the vehicle wants to change using the given laneOffset. This method gets th...
void prepareStep()
#define min(a, b)
Definition: polyfonts.c:66
bool amBlockingFollower()
Definition: MSLCM_LC2013.h:156
bool amBlockingFollowerNB()
Definition: MSLCM_LC2013.h:159
SUMOReal patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal max, const MSCFModel &cfModel)
Called to adapt the speed in order to allow a lane change.
const SUMOReal myChangeProbThresholdRight
Definition: MSLCM_LC2013.h:206
The car-following model abstraction.
Definition: MSCFModel.h:59
SUMOReal myKeepRightProbability
Definition: MSLCM_LC2013.h:183
T MAX2(T a, T b)
Definition: StdDefs.h:75
const SUMOReal myKeepRightParam
Definition: MSLCM_LC2013.h:200
const SUMOReal myChangeProbThresholdLeft
Definition: MSLCM_LC2013.h:207
std::vector< SUMOReal > myVSafes
Definition: MSLCM_LC2013.h:192
const SUMOReal myCooperativeParam
Definition: MSLCM_LC2013.h:198
#define abs(a)
Definition: polyfonts.c:67
void informFollower(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, int dir, const std::pair< MSVehicle *, SUMOReal > &neighFollow, SUMOReal remainingSeconds, SUMOReal plannedSpeed)
decide whether we will try cut in before the follower or allow to be overtaken
void saveBlockerLength(SUMOReal length)
reserve space at the end of the lane to avoid dead locks
Definition: MSLCM_LC2013.h:149
const SUMOReal myStrategicParam
Definition: MSLCM_LC2013.h:197
A class responsible for exchanging messages between cars involved in lane-change interaction.
bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
Definition: MSLCM_LC2013.h:165
A lane change model developed by D. Krajzewicz, J. Erdmann et al. between 2004 and 2013...
Definition: MSLCM_LC2013.h:49
bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
Definition: MSLCM_LC2013.h:168
#define max(a, b)
Definition: polyfonts.c:65
SUMOReal myLeadingBlockerLength
Definition: MSLCM_LC2013.h:185
SUMOReal myLookAheadSpeed
Definition: MSLCM_LC2013.h:190
int slowDownForBlocked(MSVehicle **blocked, int state)
compute useful slowdowns for blocked vehicles
int myOwnState
The current state of the vehicle.
SUMOReal informLeader(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, int dir, const std::pair< MSVehicle *, SUMOReal > &neighLead, SUMOReal remainingSeconds)
std::pair< SUMOReal, int > Info
information regarding save velocity (unused) and state flags of the ego vehicle
Definition: MSLCM_LC2013.h:173
int _wantsChange(int laneOffset, MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, const std::pair< MSVehicle *, SUMOReal > &leader, const std::pair< MSVehicle *, SUMOReal > &neighLead, const std::pair< MSVehicle *, SUMOReal > &neighFollow, const MSLane &neighLane, const std::vector< MSVehicle::LaneQ > &preb, MSVehicle **lastBlocked, MSVehicle **firstBlocked)
helper function for doing the actual work
virtual ~MSLCM_LC2013()
SUMOReal mySpeedGainProbability
a value for tracking the probability that a change to the offset with the same sign is beneficial ...
Definition: MSLCM_LC2013.h:179
SUMOReal myLeftSpace
Definition: MSLCM_LC2013.h:186
#define SUMOReal
Definition: config.h:213
bool amBlockingFollowerPlusNB()
Definition: MSLCM_LC2013.h:162
SUMOReal _patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal max, const MSCFModel &cfModel)
void * inform(void *info, MSVehicle *sender)
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
const SUMOReal mySpeedGainParam
Definition: MSLCM_LC2013.h:199
Interface for lane-change models.
bool amBlockingLeader()
Definition: MSLCM_LC2013.h:153