SUMO - Simulation of Urban MObility
MSLCM_JE2013.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A lane change model developed by J. Erdmann
10 // based on the model of D. Krajzewicz developed between 2004 and 2011 (MSLCM_DK2004)
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2013-2016 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSLCM_JE2013_h
24 #define MSLCM_JE2013_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
37 #include <vector>
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
48 public:
49 
50  enum MyLCAEnum {
53  LCA_MRIGHT = 1 << 18,
54  LCA_MLEFT = 1 << 19,
55  // !!! never set LCA_UNBLOCK = 1 << 20,
57  // !!! never used LCA_AMBLOCKINGSECONDFOLLOWER = 1 << 22,
58  LCA_CHANGE_TO_HELP = 1 << 23,
59  // !!! never read LCA_KEEP1 = 1 << 24,
60  // !!! never used LCA_KEEP2 = 1 << 25,
61  LCA_AMBACKBLOCKER = 1 << 26,
63  };
64 
65 
67 
68  virtual ~MSLCM_JE2013();
69 
74  int wantsChange(
75  int laneOffset,
76  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
77  const std::pair<MSVehicle*, SUMOReal>& leader,
78  const std::pair<MSVehicle*, SUMOReal>& neighLead,
79  const std::pair<MSVehicle*, SUMOReal>& neighFollow,
80  const MSLane& neighLane,
81  const std::vector<MSVehicle::LaneQ>& preb,
82  MSVehicle** lastBlocked,
83  MSVehicle** firstBlocked);
84 
85  void* inform(void* info, MSVehicle* sender);
86 
95  SUMOReal patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal max,
96  const MSCFModel& cfModel);
98  SUMOReal _patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal max,
99  const MSCFModel& cfModel);
100 
101  void changed(int dir);
102 
103  void prepareStep();
104 
105 
106 protected:
107 
109  int _wantsChange(
110  int laneOffset,
111  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
112  const std::pair<MSVehicle*, SUMOReal>& leader,
113  const std::pair<MSVehicle*, SUMOReal>& neighLead,
114  const std::pair<MSVehicle*, SUMOReal>& neighFollow,
115  const MSLane& neighLane,
116  const std::vector<MSVehicle::LaneQ>& preb,
117  MSVehicle** lastBlocked,
118  MSVehicle** firstBlocked);
119 
120 
121  /* @brief decide whether we will overtake or follow a blocking leader
122  * and inform it accordingly
123  * If we decide to follow, myVSafes will be extended
124  * returns the planned speed if following or -1 if overtaking */
126  int blocked, int dir,
127  const std::pair<MSVehicle*, SUMOReal>& neighLead,
128  SUMOReal remainingSeconds);
129 
132  int blocked, int dir,
133  const std::pair<MSVehicle*, SUMOReal>& neighFollow,
134  SUMOReal remainingSeconds,
135  SUMOReal plannedSpeed);
136 
137 
139  int slowDownForBlocked(MSVehicle** blocked, int state);
140 
142  void saveBlockerLength(MSVehicle* blocker, int lcaCounter);
143 
145  inline void saveBlockerLength(SUMOReal length) {
147  };
148 
149  inline bool amBlockingLeader() {
150  return (myOwnState & LCA_AMBLOCKINGLEADER) != 0;
151  }
152  inline bool amBlockingFollower() {
153  return (myOwnState & LCA_AMBLOCKINGFOLLOWER) != 0;
154  }
155  inline bool amBlockingFollowerNB() {
157  }
158  inline bool amBlockingFollowerPlusNB() {
160  }
161  inline bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
162  return dist / (abs(laneOffset)) < lookForwardDist;
163  }
164  inline bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
165  return dist / abs(laneOffset) > lookForwardDist;
166  }
167 
169  typedef std::pair<SUMOReal, int> Info;
170 
171 
172 
173 protected:
176  /* @brief a value for tracking the probability of following the/"Rechtsfahrgebot"
177  * A larger negative value indicates higher probability for moving to the
178  * right (as in mySpeedGainProbability) */
180 
183 
184  /*@brief the speed to use when computing the look-ahead distance for
185  * determining urgency of strategic lane changes */
187 
188  std::vector<SUMOReal> myVSafes;
190 
191 };
192 
193 
194 #endif
195 
196 /****************************************************************************/
197 
void * inform(void *info, MSVehicle *sender)
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
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
int slowDownForBlocked(MSVehicle **blocked, int state)
compute useful slowdowns for blocked vehicles
#define min(a, b)
Definition: polyfonts.c:66
bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
Definition: MSLCM_JE2013.h:164
bool amBlockingFollowerNB()
Definition: MSLCM_JE2013.h:155
SUMOReal myLeadingBlockerLength
Definition: MSLCM_JE2013.h:181
The car-following model abstraction.
Definition: MSCFModel.h:59
bool amBlockingFollower()
Definition: MSLCM_JE2013.h:152
virtual ~MSLCM_JE2013()
SUMOReal myLeftSpace
Definition: MSLCM_JE2013.h:182
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...
T MAX2(T a, T b)
Definition: StdDefs.h:75
MSLCM_JE2013(MSVehicle &v)
std::vector< SUMOReal > myVSafes
Definition: MSLCM_JE2013.h:188
#define abs(a)
Definition: polyfonts.c:67
A lane change model developed by J. Erdmann.
Definition: MSLCM_JE2013.h:47
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
std::pair< SUMOReal, int > Info
information regarding save velocity (unused) and state flags of the ego vehicle
Definition: MSLCM_JE2013.h:169
A class responsible for exchanging messages between cars involved in lane-change interaction.
#define max(a, b)
Definition: polyfonts.c:65
SUMOReal mySpeedGainProbability
a value for tracking the probability that a change to the offset with the same sign is beneficial ...
Definition: MSLCM_JE2013.h:175
void prepareStep()
bool amBlockingFollowerPlusNB()
Definition: MSLCM_JE2013.h:158
SUMOReal informLeader(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, int dir, const std::pair< MSVehicle *, SUMOReal > &neighLead, SUMOReal remainingSeconds)
SUMOReal _patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal max, const MSCFModel &cfModel)
void saveBlockerLength(MSVehicle *blocker, int lcaCounter)
save space for vehicles which need to counter-lane-change
bool amBlockingLeader()
Definition: MSLCM_JE2013.h:149
int myOwnState
The current state of the vehicle.
void changed(int dir)
SUMOReal myKeepRightProbability
Definition: MSLCM_JE2013.h:179
SUMOReal myLookAheadSpeed
Definition: MSLCM_JE2013.h:186
#define SUMOReal
Definition: config.h:213
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
Definition: MSLCM_JE2013.h:161
Interface for lane-change models.
void saveBlockerLength(SUMOReal length)
reserve space at the end of the lane to avoid dead locks
Definition: MSLCM_JE2013.h:145
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.