SUMO - Simulation of Urban MObility
MSLCM_DK2008.h
Go to the documentation of this file.
1 /****************************************************************************/
11 // A lane change model developed by D. Krajzewicz between 2004 and 2010
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
14 // Copyright (C) 2005-2016 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_DK2008_h
25 #define MSLCM_DK2008_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 // 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 
59  // !!! never read LCA_KEEP1 = 1 << 24,
60  // !!! never used LCA_KEEP2 = 1 << 25,
61  LCA_AMBACKBLOCKER = 1 << 26,
63  };
64 
66 
67  virtual ~MSLCM_DK2008();
68 
73  int wantsChange(
74  int laneOffset,
75  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
76  const std::pair<MSVehicle*, SUMOReal>& leader,
77  const std::pair<MSVehicle*, SUMOReal>& neighLead,
78  const std::pair<MSVehicle*, SUMOReal>& neighFollow,
79  const MSLane& neighLane,
80  const std::vector<MSVehicle::LaneQ>& preb,
81  MSVehicle** lastBlocked,
82  MSVehicle** firstBlocked);
83 
84  virtual void* inform(void* info, MSVehicle* sender);
85 
94  virtual SUMOReal patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal max,
95  const MSCFModel& cfModel);
96 
97  virtual void changed();
98 
99  virtual void prepareStep();
100 
101 
102 protected:
106  virtual int wantsChangeToRight(
107  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
108  const std::pair<MSVehicle*, SUMOReal>& leader,
109  const std::pair<MSVehicle*, SUMOReal>& neighLead,
110  const std::pair<MSVehicle*, SUMOReal>& neighFollow,
111  const MSLane& neighLane,
112  const std::vector<MSVehicle::LaneQ>& preb,
113  MSVehicle** lastBlocked,
114  MSVehicle** firstBlocked);
115 
119  virtual int wantsChangeToLeft(
120  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
121  const std::pair<MSVehicle*, SUMOReal>& leader,
122  const std::pair<MSVehicle*, SUMOReal>& neighLead,
123  const std::pair<MSVehicle*, SUMOReal>& neighFollow,
124  const MSLane& neighLane,
125  const std::vector<MSVehicle::LaneQ>& preb,
126  MSVehicle** lastBlocked,
127  MSVehicle** firstBlocked);
128 
130  int& blocked, int dir,
131  const std::pair<MSVehicle*, SUMOReal>& neighLead,
132  const std::pair<MSVehicle*, SUMOReal>& neighFollow);
133 
134  inline bool amBlockingLeader() {
135  return (myOwnState & LCA_AMBLOCKINGLEADER) != 0;
136  }
137  inline bool amBlockingFollower() {
138  return (myOwnState & LCA_AMBLOCKINGFOLLOWER) != 0;
139  }
140  inline bool amBlockingFollowerNB() {
142  }
143  inline bool amBlockingFollowerPlusNB() {
145  }
146  inline bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
147  return dist / (abs(laneOffset)) < lookForwardDist;
148  }
149  inline bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
150  return dist / abs(laneOffset) > lookForwardDist;
151  }
152 
153  typedef std::pair<SUMOReal, int> Info;
154 
155 
156 
157 protected:
159 
162 
163  std::vector<SUMOReal> myVSafes;
165 
166 };
167 
168 
169 #endif
170 
171 /****************************************************************************/
172 
SUMOReal myChangeProbability
Definition: MSLCM_DK2008.h:158
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:82
#define min(a, b)
Definition: polyfonts.c:66
bool amBlockingFollowerNB()
Definition: MSLCM_DK2008.h:140
bool amBlockingFollower()
Definition: MSLCM_DK2008.h:137
The car-following model abstraction.
Definition: MSCFModel.h:60
virtual void prepareStep()
bool amBlockingLeader()
Definition: MSLCM_DK2008.h:134
bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
Definition: MSLCM_DK2008.h:146
SUMOReal myLeadingBlockerLength
Definition: MSLCM_DK2008.h:160
MSLCM_DK2008(MSVehicle &v)
virtual int wantsChangeToLeft(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 to left This method gets the information about ...
#define abs(a)
Definition: polyfonts.c:67
bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
Definition: MSLCM_DK2008.h:149
A class responsible for exchanging messages between cars involved in lane-change interaction.
#define max(a, b)
Definition: polyfonts.c:65
std::pair< SUMOReal, int > Info
Definition: MSLCM_DK2008.h:153
virtual 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.
bool amBlockingFollowerPlusNB()
Definition: MSLCM_DK2008.h:143
int myOwnState
The current state of the vehicle.
virtual ~MSLCM_DK2008()
void informBlocker(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int &blocked, int dir, const std::pair< MSVehicle *, SUMOReal > &neighLead, const std::pair< MSVehicle *, SUMOReal > &neighFollow)
A lane change model developed by D. Krajzewicz between 2004 and 2010.
Definition: MSLCM_DK2008.h:47
virtual int wantsChangeToRight(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 to right This method gets the information about...
#define SUMOReal
Definition: config.h:213
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...
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
virtual void * inform(void *info, MSVehicle *sender)
SUMOReal myLeftSpace
Definition: MSLCM_DK2008.h:161
Interface for lane-change models.
virtual void changed()
std::vector< SUMOReal > myVSafes
Definition: MSLCM_DK2008.h:163