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-2014 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 
147  inline bool amBlockingLeader() {
148  return (myOwnState & LCA_AMBLOCKINGLEADER) != 0;
149  }
150  inline bool amBlockingFollower() {
151  return (myOwnState & LCA_AMBLOCKINGFOLLOWER) != 0;
152  }
153  inline bool amBlockingFollowerNB() {
155  }
156  inline bool amBlockingFollowerPlusNB() {
158  }
159  inline bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
160  return dist / (abs(laneOffset)) < lookForwardDist;
161  }
162  inline bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
163  return dist / abs(laneOffset) > lookForwardDist;
164  }
165 
167  typedef std::pair<SUMOReal, int> Info;
168 
169 
170 
171 protected:
174  /* @brief a value for tracking the probability of following the/"Rechtsfahrgebot"
175  * A larger negative value indicates higher probability for moving to the
176  * right (as in mySpeedGainProbability) */
178 
181 
182  /*@brief the speed to use when computing the look-ahead distance for
183  * determining urgency of strategic lane changes */
185 
186  std::vector<SUMOReal> myVSafes;
188 
189 };
190 
191 
192 #endif
193 
194 /****************************************************************************/
195 
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:77
int slowDownForBlocked(MSVehicle **blocked, int state)
compute useful slowdowns for blocked vehicles
#define min(a, b)
Definition: polyfonts.c:62
bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
Definition: MSLCM_JE2013.h:162
bool amBlockingFollowerNB()
Definition: MSLCM_JE2013.h:153
SUMOReal myLeadingBlockerLength
Definition: MSLCM_JE2013.h:179
The car-following model abstraction.
Definition: MSCFModel.h:58
bool amBlockingFollower()
Definition: MSLCM_JE2013.h:150
virtual ~MSLCM_JE2013()
SUMOReal myLeftSpace
Definition: MSLCM_JE2013.h:180
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:71
MSLCM_JE2013(MSVehicle &v)
std::vector< SUMOReal > myVSafes
Definition: MSLCM_JE2013.h:186
#define abs(a)
Definition: polyfonts.c:63
A lane change model developed by J. Erdmann.
Definition: MSLCM_JE2013.h:45
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:167
A class responsible for exchanging messages between cars involved in lane-change interaction.
#define max(a, b)
Definition: polyfonts.c:61
SUMOReal mySpeedGainProbability
a value for tracking the probability that a change to the offset with the same sign is beneficial ...
Definition: MSLCM_JE2013.h:173
void prepareStep()
bool amBlockingFollowerPlusNB()
Definition: MSLCM_JE2013.h:156
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:147
int myOwnState
The current state of the vehicle.
SUMOReal myKeepRightProbability
Definition: MSLCM_JE2013.h:177
SUMOReal myLookAheadSpeed
Definition: MSLCM_JE2013.h:184
#define SUMOReal
Definition: config.h:215
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
Definition: MSLCM_JE2013.h:159
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:143
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.