SUMO - Simulation of Urban MObility
MSLCM_SL2015.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // A lane change model for heterogeneous traffic (based on sub-lanes)
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2013-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef MSLCM_SL2015_h
21 #define MSLCM_SL2015_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
34 #include <vector>
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
45 public:
46 
47  enum MyLCAEnum {
48  LCA_MNone = 0,
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_SL2015();
67 
72  int wantsChangeSublane(int laneOffset,
73  const MSLeaderDistanceInfo& leaders,
74  const MSLeaderDistanceInfo& followers,
75  const MSLeaderDistanceInfo& blockers,
76  const MSLeaderDistanceInfo& neighLeaders,
77  const MSLeaderDistanceInfo& neighFollowers,
78  const MSLeaderDistanceInfo& neighBlockers,
79  const MSLane& neighLane,
80  const std::vector<MSVehicle::LaneQ>& preb,
81  MSVehicle** lastBlocked,
82  MSVehicle** firstBlocked,
83  double& latDist, int& blocked);
84 
89  int wantsChange(
90  int laneOffset,
91  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
92  const std::pair<MSVehicle*, double>& leader,
93  const std::pair<MSVehicle*, double>& neighLead,
94  const std::pair<MSVehicle*, double>& neighFollow,
95  const MSLane& neighLane,
96  const std::vector<MSVehicle::LaneQ>& preb,
97  MSVehicle** lastBlocked,
98  MSVehicle** firstBlocked);
99 
100  void* inform(void* info, MSVehicle* sender);
101 
110  double patchSpeed(const double min, const double wanted, const double max,
111  const MSCFModel& cfModel);
113  double _patchSpeed(const double min, const double wanted, const double max,
114  const MSCFModel& cfModel);
115 
116  void changed();
117 
118  void prepareStep();
119 
121  bool debugVehicle() const;
122 
123  void setOwnState(const int state);
124 
126  std::string getParameter(const std::string& key) const;
127 
129  void setParameter(const std::string& key, const std::string& value);
130 
131 protected:
132 
135  int laneOffset,
136  const MSLeaderDistanceInfo& leaders,
137  const MSLeaderDistanceInfo& followers,
138  const MSLeaderDistanceInfo& blockers,
139  const MSLeaderDistanceInfo& neighLeaders,
140  const MSLeaderDistanceInfo& neighFollowers,
141  const MSLeaderDistanceInfo& neighBlockers,
142  const MSLane& neighLane,
143  const std::vector<MSVehicle::LaneQ>& preb,
144  MSVehicle** lastBlocked,
145  MSVehicle** firstBlocked,
146  double& latDist, int& blocked);
147 
148 
149  /* @brief decide whether we will overtake or follow blocking leaders
150  * and inform them accordingly (see informLeader)
151  * If we decide to follow, myVSafes will be extended
152  * returns the planned speed if following or -1 if overtaking */
153  double informLeaders(int blocked, int dir,
154  const std::vector<CLeaderDist>& blockers,
155  double remainingSeconds);
156 
158  void informFollowers(int blocked, int dir,
159  const std::vector<CLeaderDist>& blockers,
160  double remainingSeconds,
161  double plannedSpeed);
162 
163  /* @brief decide whether we will overtake or follow a blocking leader
164  * and inform it accordingly
165  * If we decide to follow, myVSafes will be extended
166  * returns the planned speed if following or -1 if overtaking */
167  double informLeader(int blocked, int dir,
168  const CLeaderDist& neighLead,
169  double remainingSeconds);
170 
172  void informFollower(int blocked, int dir,
173  const CLeaderDist& neighFollow,
174  double remainingSeconds,
175  double plannedSpeed);
176 
177 
179  int slowDownForBlocked(MSVehicle** blocked, int state);
180 
182  void saveBlockerLength(const MSVehicle* blocker, int lcaCounter);
183 
185  inline void saveBlockerLength(double length) {
187  };
188 
189  inline bool amBlockingLeader() {
190  return (myOwnState & LCA_AMBLOCKINGLEADER) != 0;
191  }
192  inline bool amBlockingFollower() {
193  return (myOwnState & LCA_AMBLOCKINGFOLLOWER) != 0;
194  }
195  inline bool amBlockingFollowerNB() {
197  }
198  inline bool amBlockingFollowerPlusNB() {
200  }
201  inline bool currentDistDisallows(double dist, int laneOffset, double lookForwardDist) {
202  return dist / (abs(laneOffset)) < lookForwardDist;
203  }
204  inline bool currentDistAllows(double dist, int laneOffset, double lookForwardDist) {
205  return dist / abs(laneOffset) > lookForwardDist;
206  }
207 
209  typedef std::pair<double, int> Info;
210 
211 
213  void updateExpectedSublaneSpeeds(const MSLeaderInfo& ahead, int sublaneOffset, int laneIndex);
214 
217 
218 protected:
219 
221  void msg(const CLeaderDist& cld, double speed, int state);
222 
224  int computeSublaneShift(const MSEdge* prevEdge, const MSEdge* curEdge);
225 
227  static CLeaderDist getLongest(const MSLeaderDistanceInfo& ldi);
228 
230  static CLeaderDist getSlowest(const MSLeaderDistanceInfo& ldi);
231 
233  int checkBlocking(const MSLane& neighLane, double& latDist, int laneOffset,
234  const MSLeaderDistanceInfo& leaders,
235  const MSLeaderDistanceInfo& followers,
236  const MSLeaderDistanceInfo& blockers,
237  const MSLeaderDistanceInfo& neighLeaders,
238  const MSLeaderDistanceInfo& neighFollowers,
239  const MSLeaderDistanceInfo& neighBlockers,
240  std::vector<CLeaderDist>* collectLeadBlockers = 0,
241  std::vector<CLeaderDist>* collectFollowBlockers = 0,
242  bool keepLatGapManeuver = false);
243 
245  int checkBlockingVehicles(const MSVehicle* ego, const MSLeaderDistanceInfo& vehicles,
246  double latDist, double foeOffset, bool leaders, LaneChangeAction blockType,
247  std::vector<CLeaderDist>* collectBlockers = 0) const;
248 
250  static bool overlap(double right, double left, double right2, double left2);
251 
253  static LaneChangeAction getLCA(int state, double latDist);
254 
256  int checkStrategicChange(int ret,
257  int laneOffset,
258  const std::vector<MSVehicle::LaneQ>& preb,
259  const MSLeaderDistanceInfo& leaders,
260  const MSLeaderDistanceInfo& neighLeaders,
261  int currIdx,
262  int bestLaneOffset,
263  bool changeToBest,
264  int lcaCounter,
265  double currentDist,
266  double neighDist,
267  double laDist,
268  int roundaboutEdgesAhead,
269  double latLaneDist,
270  double& latDist
271  );
272 
274  int keepLatGap(int state,
275  const MSLeaderDistanceInfo& leaders,
276  const MSLeaderDistanceInfo& followers,
277  const MSLeaderDistanceInfo& blockers,
278  const MSLeaderDistanceInfo& neighLeaders,
279  const MSLeaderDistanceInfo& neighFollowers,
280  const MSLeaderDistanceInfo& neighBlockers,
281  const MSLane& neighLane,
282  int laneOffset,
283  double& latDist,
284  int& blocked);
285 
286 
288  void updateGaps(const MSLeaderDistanceInfo& others, double foeOffset, double oldCenter, double gapFactor,
289  double& surplusGapRight, double& surplusGapLeft, bool saveMinGap = false, double netOverlap = 0);
290 
291 protected:
296 
297  /* @brief a value for tracking the probability of following the/"Rechtsfahrgebot"
298  * A larger negative value indicates higher probability for moving to the
299  * right (as in mySpeedGainProbability) */
301 
303  double myLeftSpace;
304 
305  /*@brief the speed to use when computing the look-ahead distance for
306  * determining urgency of strategic lane changes */
308 
310  std::vector<double> myVSafes;
311 
313  std::vector<double> myExpectedSublaneSpeeds;
314 
317 
320 
323 
326 
329 
331 
337  // @brief willingness to encroach on other vehicles laterally (pushing them around)
338  double myPushy;
339  double myAssertive;
341 
343 
344  // @brief willingness to encroach on other vehicles laterally (pushing them around)
349 
350 };
351 
352 
353 #endif
354 
355 /****************************************************************************/
356 
void * inform(void *info, MSVehicle *sender)
const double mySpeedLossProbThreshold
Definition: MSLCM_SL2015.h:347
A lane change model developed by J. Erdmann.
Definition: MSLCM_SL2015.h:44
double myLeftSpace
Definition: MSLCM_SL2015.h:303
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:136
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
void msg(const CLeaderDist &cld, double speed, int state)
send a speed recommendation to the given vehicle
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this laneChangeModel. Throw exception for unsupported key ...
double mySpeedGainProbabilityLeft
a value for tracking the probability that a change to the left is beneficial
Definition: MSLCM_SL2015.h:295
#define min(a, b)
Definition: polyfonts.c:66
double mySpeedGainParam
Definition: MSLCM_SL2015.h:334
double informLeaders(int blocked, int dir, const std::vector< CLeaderDist > &blockers, double remainingSeconds)
bool myCanChangeFully
whether the current lane changing meneuver can be finished in a single step
Definition: MSLCM_SL2015.h:322
double myKeepRightParam
Definition: MSLCM_SL2015.h:335
void saveBlockerLength(double length)
reserve space at the end of the lane to avoid dead locks
Definition: MSLCM_SL2015.h:185
const double myChangeProbThresholdLeft
Definition: MSLCM_SL2015.h:346
int checkStrategicChange(int ret, int laneOffset, const std::vector< MSVehicle::LaneQ > &preb, const MSLeaderDistanceInfo &leaders, const MSLeaderDistanceInfo &neighLeaders, int currIdx, int bestLaneOffset, bool changeToBest, int lcaCounter, double currentDist, double neighDist, double laDist, int roundaboutEdgesAhead, double latLaneDist, double &latDist)
compute strategic lane change actions
The car-following model abstraction.
Definition: MSCFModel.h:60
double myStrategicParam
Definition: MSLCM_SL2015.h:332
void setOwnState(const int state)
static CLeaderDist getSlowest(const MSLeaderDistanceInfo &ldi)
get the slowest vehicle in the given info
void updateExpectedSublaneSpeeds(const MSLeaderInfo &ahead, int sublaneOffset, int laneIndex)
update expected speeds for each sublane of the current edge
std::vector< double > myExpectedSublaneSpeeds
expected travel speeds on all sublanes on the current edge(!)
Definition: MSLCM_SL2015.h:313
T MAX2(T a, T b)
Definition: StdDefs.h:70
int keepLatGap(int state, const MSLeaderDistanceInfo &leaders, const MSLeaderDistanceInfo &followers, const MSLeaderDistanceInfo &blockers, const MSLeaderDistanceInfo &neighLeaders, const MSLeaderDistanceInfo &neighFollowers, const MSLeaderDistanceInfo &neighBlockers, const MSLane &neighLane, int laneOffset, double &latDist, int &blocked)
check whether lateral gap requirements are met override the current maneuver if necessary ...
bool debugVehicle() const
whether the current vehicles shall be debugged
bool amBlockingFollower()
Definition: MSLCM_SL2015.h:192
MSLCM_SL2015(MSVehicle &v)
#define abs(a)
Definition: polyfonts.c:67
std::vector< double > myVSafes
speed adaptation requests by ego and surrounding vehicles
Definition: MSLCM_SL2015.h:310
void saveBlockerLength(const MSVehicle *blocker, int lcaCounter)
save space for vehicles which need to counter-lane-change
static bool overlap(double right, double left, double right2, double left2)
return whether the given intervals overlap
A class responsible for exchanging messages between cars involved in lane-change interaction.
StateAndDist decideDirection(StateAndDist sd1, StateAndDist sd2) const
decide in which direction to move in case both directions are desirable
A road/street connecting two junctions.
Definition: MSEdge.h:80
double myLeadingBlockerLength
Definition: MSLCM_SL2015.h:302
void prepareStep()
#define max(a, b)
Definition: polyfonts.c:65
const MSEdge * myLastEdge
expected travel speeds on all sublanes on the current edge(!)
Definition: MSLCM_SL2015.h:316
double myPushy
Definition: MSLCM_SL2015.h:338
double informLeader(int blocked, int dir, const CLeaderDist &neighLead, double remainingSeconds)
static LaneChangeAction getLCA(int state, double latDist)
compute lane change action from desired lateral distance
void informFollowers(int blocked, int dir, const std::vector< CLeaderDist > &blockers, double remainingSeconds, double plannedSpeed)
call informFollower for multiple followers
bool amBlockingFollowerNB()
Definition: MSLCM_SL2015.h:195
int checkBlockingVehicles(const MSVehicle *ego, const MSLeaderDistanceInfo &vehicles, double latDist, double foeOffset, bool leaders, LaneChangeAction blockType, std::vector< CLeaderDist > *collectBlockers=0) const
check whether any of the vehicles overlaps with ego
void updateGaps(const MSLeaderDistanceInfo &others, double foeOffset, double oldCenter, double gapFactor, double &surplusGapRight, double &surplusGapLeft, bool saveMinGap=false, double netOverlap=0)
check remaining lateral gaps for the given foe vehicles and optionally update minimum lateral gaps ...
double _patchSpeed(const double min, const double wanted, const double max, const MSCFModel &cfModel)
int myOwnState
The current state of the vehicle.
static CLeaderDist getLongest(const MSLeaderDistanceInfo &ldi)
get the longest vehicle in the given info
double myCooperativeParam
Definition: MSLCM_SL2015.h:333
std::pair< double, int > Info
information regarding save velocity (unused) and state flags of the ego vehicle
Definition: MSLCM_SL2015.h:209
int wantsChangeSublane(int laneOffset, const MSLeaderDistanceInfo &leaders, const MSLeaderDistanceInfo &followers, const MSLeaderDistanceInfo &blockers, const MSLeaderDistanceInfo &neighLeaders, const MSLeaderDistanceInfo &neighFollowers, const MSLeaderDistanceInfo &neighBlockers, const MSLane &neighLane, const std::vector< MSVehicle::LaneQ > &preb, MSVehicle **lastBlocked, MSVehicle **firstBlocked, double &latDist, int &blocked)
Called to examine whether the vehicle wants to change with the given laneOffset (using the sublane mo...
virtual ~MSLCM_SL2015()
std::pair< const MSVehicle *, double > CLeaderDist
Definition: MSLeaderInfo.h:42
LaneChangeAction
The state of a vehicle&#39;s lane-change behavior.
double patchSpeed(const double min, const double wanted, const double max, const MSCFModel &cfModel)
Called to adapt the speed in order to allow a lane change.
double myKeepRightProbability
Definition: MSLCM_SL2015.h:300
double myOrigLatDist
the complete lateral distance the vehicle wants to travel to finish its maneuver
Definition: MSLCM_SL2015.h:328
int slowDownForBlocked(MSVehicle **blocked, int state)
compute useful slowdowns for blocked vehicles
void informFollower(int blocked, int dir, const CLeaderDist &neighFollow, double remainingSeconds, double plannedSpeed)
decide whether we will try cut in before the follower or allow to be overtaken
bool currentDistDisallows(double dist, int laneOffset, double lookForwardDist)
Definition: MSLCM_SL2015.h:201
const double myChangeProbThresholdRight
Definition: MSLCM_SL2015.h:345
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key ...
double mySpeedGainProbabilityRight
a value for tracking the probability that a change to the right is beneficial
Definition: MSLCM_SL2015.h:293
double myLookAheadSpeed
Definition: MSLCM_SL2015.h:307
bool currentDistAllows(double dist, int laneOffset, double lookForwardDist)
Definition: MSLCM_SL2015.h:204
int _wantsChangeSublane(int laneOffset, const MSLeaderDistanceInfo &leaders, const MSLeaderDistanceInfo &followers, const MSLeaderDistanceInfo &blockers, const MSLeaderDistanceInfo &neighLeaders, const MSLeaderDistanceInfo &neighFollowers, const MSLeaderDistanceInfo &neighBlockers, const MSLane &neighLane, const std::vector< MSVehicle::LaneQ > &preb, MSVehicle **lastBlocked, MSVehicle **firstBlocked, double &latDist, int &blocked)
helper function for doing the actual work
bool amBlockingLeader()
Definition: MSLCM_SL2015.h:189
bool myDontBrake
flag to prevent speed adaptation by slowing down
Definition: MSLCM_SL2015.h:319
int checkBlocking(const MSLane &neighLane, double &latDist, int laneOffset, const MSLeaderDistanceInfo &leaders, const MSLeaderDistanceInfo &followers, const MSLeaderDistanceInfo &blockers, const MSLeaderDistanceInfo &neighLeaders, const MSLeaderDistanceInfo &neighFollowers, const MSLeaderDistanceInfo &neighBlockers, std::vector< CLeaderDist > *collectLeadBlockers=0, std::vector< CLeaderDist > *collectFollowBlockers=0, bool keepLatGapManeuver=false)
restrict latDist to permissible speed and determine blocking state depending on that distance ...
int wantsChange(int laneOffset, MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, const std::pair< MSVehicle *, double > &leader, const std::pair< MSVehicle *, double > &neighLead, const std::pair< MSVehicle *, double > &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 is a wrapper a...
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
int myPreviousState
lane changing state from the previous simulation step
Definition: MSLCM_SL2015.h:325
int computeSublaneShift(const MSEdge *prevEdge, const MSEdge *curEdge)
compute shift so that prevSublane + shift = newSublane
Interface for lane-change models.
double mySublaneParam
Definition: MSLCM_SL2015.h:336
bool amBlockingFollowerPlusNB()
Definition: MSLCM_SL2015.h:198
double myAssertive
Definition: MSLCM_SL2015.h:339