SUMO - Simulation of Urban MObility
MSLCM_DK2008.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2005-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
21 // A lane change model developed by D. Krajzewicz between 2004 and 2010
22 /****************************************************************************/
23 #ifndef MSLCM_DK2008_h
24 #define MSLCM_DK2008_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 // class definitions
41 // ===========================================================================
47 public:
48 
49  enum MyLCAEnum {
52  LCA_MRIGHT = 1 << 18,
53  LCA_MLEFT = 1 << 19,
54  // !!! never set LCA_UNBLOCK = 1 << 20,
56  // !!! never used LCA_AMBLOCKINGSECONDFOLLOWER = 1 << 22,
57 
58  // !!! never read LCA_KEEP1 = 1 << 24,
59  // !!! never used LCA_KEEP2 = 1 << 25,
60  LCA_AMBACKBLOCKER = 1 << 26,
62  };
63 
65 
66  virtual ~MSLCM_DK2008();
67 
72  int wantsChange(
73  int laneOffset,
74  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
75  const std::pair<MSVehicle*, double>& leader,
76  const std::pair<MSVehicle*, double>& neighLead,
77  const std::pair<MSVehicle*, double>& neighFollow,
78  const MSLane& neighLane,
79  const std::vector<MSVehicle::LaneQ>& preb,
80  MSVehicle** lastBlocked,
81  MSVehicle** firstBlocked);
82 
83  virtual void* inform(void* info, MSVehicle* sender);
84 
93  virtual double patchSpeed(const double min, const double wanted, const double max,
94  const MSCFModel& cfModel);
95 
96  virtual void changed();
97 
98  virtual void prepareStep();
99 
100 
101 protected:
105  virtual int wantsChangeToRight(
106  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
107  const std::pair<MSVehicle*, double>& leader,
108  const std::pair<MSVehicle*, double>& neighLead,
109  const std::pair<MSVehicle*, double>& neighFollow,
110  const MSLane& neighLane,
111  const std::vector<MSVehicle::LaneQ>& preb,
112  MSVehicle** lastBlocked,
113  MSVehicle** firstBlocked);
114 
118  virtual int wantsChangeToLeft(
119  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
120  const std::pair<MSVehicle*, double>& leader,
121  const std::pair<MSVehicle*, double>& neighLead,
122  const std::pair<MSVehicle*, double>& neighFollow,
123  const MSLane& neighLane,
124  const std::vector<MSVehicle::LaneQ>& preb,
125  MSVehicle** lastBlocked,
126  MSVehicle** firstBlocked);
127 
129  int& blocked, int dir,
130  const std::pair<MSVehicle*, double>& neighLead,
131  const std::pair<MSVehicle*, double>& neighFollow);
132 
133  inline bool amBlockingLeader() {
134  return (myOwnState & LCA_AMBLOCKINGLEADER) != 0;
135  }
136  inline bool amBlockingFollower() {
137  return (myOwnState & LCA_AMBLOCKINGFOLLOWER) != 0;
138  }
139  inline bool amBlockingFollowerNB() {
141  }
142  inline bool amBlockingFollowerPlusNB() {
144  }
145  inline bool currentDistDisallows(double dist, int laneOffset, double lookForwardDist) {
146  return dist / (abs(laneOffset)) < lookForwardDist;
147  }
148  inline bool currentDistAllows(double dist, int laneOffset, double lookForwardDist) {
149  return dist / abs(laneOffset) > lookForwardDist;
150  }
151 
152  typedef std::pair<double, int> Info;
153 
154 
155 
156 protected:
158 
160  double myLeftSpace;
161 
162  std::vector<double> myVSafes;
164 
165 };
166 
167 
168 #endif
169 
170 /****************************************************************************/
171 
double myChangeProbability
Definition: MSLCM_DK2008.h:157
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:83
bool amBlockingFollowerNB()
Definition: MSLCM_DK2008.h:139
bool amBlockingFollower()
Definition: MSLCM_DK2008.h:136
The car-following model abstraction.
Definition: MSCFModel.h:59
virtual void prepareStep()
bool amBlockingLeader()
Definition: MSLCM_DK2008.h:133
bool currentDistDisallows(double dist, int laneOffset, double lookForwardDist)
Definition: MSLCM_DK2008.h:145
virtual 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.
MSLCM_DK2008(MSVehicle &v)
virtual int wantsChangeToRight(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 to right This method gets the information about...
A class responsible for exchanging messages between cars involved in lane-change interaction.
virtual int wantsChangeToLeft(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 to left This method gets the information about ...
bool amBlockingFollowerPlusNB()
Definition: MSLCM_DK2008.h:142
int myOwnState
The current state of the vehicle.
double myLeftSpace
Definition: MSLCM_DK2008.h:160
virtual ~MSLCM_DK2008()
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 method gets th...
bool currentDistAllows(double dist, int laneOffset, double lookForwardDist)
Definition: MSLCM_DK2008.h:148
double myLeadingBlockerLength
Definition: MSLCM_DK2008.h:159
std::vector< double > myVSafes
Definition: MSLCM_DK2008.h:162
A lane change model developed by D. Krajzewicz between 2004 and 2010.
Definition: MSLCM_DK2008.h:46
std::pair< double, int > Info
Definition: MSLCM_DK2008.h:152
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
virtual void * inform(void *info, MSVehicle *sender)
void informBlocker(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int &blocked, int dir, const std::pair< MSVehicle *, double > &neighLead, const std::pair< MSVehicle *, double > &neighFollow)
Interface for lane-change models.
virtual void changed()