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-2013 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 
152  void keepRight(MSVehicle* neigh);
153 
154  inline bool amBlockingLeader() {
155  return (myOwnState & LCA_AMBLOCKINGLEADER) != 0;
156  }
157  inline bool amBlockingFollower() {
158  return (myOwnState & LCA_AMBLOCKINGFOLLOWER) != 0;
159  }
160  inline bool amBlockingFollowerNB() {
162  }
163  inline bool amBlockingFollowerPlusNB() {
165  }
166  inline bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
167  return dist / (abs(laneOffset)) < lookForwardDist;
168  }
169  inline bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
170  return dist / abs(laneOffset) > lookForwardDist;
171  }
172 
174  typedef std::pair<SUMOReal, int> Info;
175 
176 
177 
178 protected:
183 
186 
187  /*@brief the speed to use when computing the look-ahead distance for
188  * determining urgency of strategic lane changes */
190 
191  std::vector<SUMOReal> myVSafes;
193 
194 };
195 
196 
197 #endif
198 
199 /****************************************************************************/
200 
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:77
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:62
bool amBlockingFollower()
Definition: MSLCM_LC2013.h:157
bool amBlockingFollowerNB()
Definition: MSLCM_LC2013.h:160
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.
The car-following model abstraction.
Definition: MSCFModel.h:58
SUMOReal myKeepRightProbability
a value for tracking the probability of following the/&quot;Rechtsfahrgebot&quot; (never a positive value) ...
Definition: MSLCM_LC2013.h:182
T MAX2(T a, T b)
Definition: StdDefs.h:63
std::vector< SUMOReal > myVSafes
Definition: MSLCM_LC2013.h:191
#define abs(a)
Definition: polyfonts.c:63
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:147
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:166
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:169
#define max(a, b)
Definition: polyfonts.c:61
void keepRight(MSVehicle *neigh)
updated myKeepRightProbability and mySpeedGainProbability if the right neighbours are faster ...
SUMOReal myLeadingBlockerLength
Definition: MSLCM_LC2013.h:184
SUMOReal myLookAheadSpeed
Definition: MSLCM_LC2013.h:189
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:174
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:180
SUMOReal myLeftSpace
Definition: MSLCM_LC2013.h:185
#define SUMOReal
Definition: config.h:215
bool amBlockingFollowerPlusNB()
Definition: MSLCM_LC2013.h:163
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:77
Interface for lane-change models.
bool amBlockingLeader()
Definition: MSLCM_LC2013.h:154