SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSLCM_DK2008.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // A lane change model developed by D. Krajzewicz between 2004 and 2010
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
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*, 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  virtual void* inform(void* info, MSVehicle* sender);
84 
93  virtual SUMOReal patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal 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*, SUMOReal>& leader,
108  const std::pair<MSVehicle*, SUMOReal>& neighLead,
109  const std::pair<MSVehicle*, SUMOReal>& 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*, SUMOReal>& leader,
121  const std::pair<MSVehicle*, SUMOReal>& neighLead,
122  const std::pair<MSVehicle*, SUMOReal>& 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*, SUMOReal>& neighLead,
131  const std::pair<MSVehicle*, SUMOReal>& 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(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
146  return dist / (abs(laneOffset)) < lookForwardDist;
147  }
148  inline bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
149  return dist / abs(laneOffset) > lookForwardDist;
150  }
151 
152  typedef std::pair<SUMOReal, int> Info;
153 
154 
155 
156 protected:
158 
161 
162  std::vector<SUMOReal> myVSafes;
164 
165 };
166 
167 
168 #endif
169 
170 /****************************************************************************/
171 
SUMOReal myChangeProbability
Definition: MSLCM_DK2008.h:157
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
#define min(a, b)
Definition: polyfonts.c:62
bool amBlockingFollowerNB()
Definition: MSLCM_DK2008.h:139
bool amBlockingFollower()
Definition: MSLCM_DK2008.h:136
The car-following model abstraction.
Definition: MSCFModel.h:58
virtual void prepareStep()
bool amBlockingLeader()
Definition: MSLCM_DK2008.h:133
bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
Definition: MSLCM_DK2008.h:145
SUMOReal myLeadingBlockerLength
Definition: MSLCM_DK2008.h:159
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:63
bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
Definition: MSLCM_DK2008.h:148
A class responsible for exchanging messages between cars involved in lane-change interaction.
#define max(a, b)
Definition: polyfonts.c:61
std::pair< SUMOReal, int > Info
Definition: MSLCM_DK2008.h:152
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:142
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:46
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:215
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:77
virtual void * inform(void *info, MSVehicle *sender)
SUMOReal myLeftSpace
Definition: MSLCM_DK2008.h:160
Interface for lane-change models.
virtual void changed()
std::vector< SUMOReal > myVSafes
Definition: MSLCM_DK2008.h:162