SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSLCM_DK2004.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-2013 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_DK2004_h
24 #define MSLCM_DK2004_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 // enumeration definition
41 // ===========================================================================
42 enum MyLCAEnum {
45  LCA_MRIGHT = 1024, // 2
46  LCA_MLEFT = 2048,// 3
47  // !!! never set LCA_UNBLOCK = 4096,// 4
49  // !!! never used LCA_AMBLOCKINGSECONDFOLLOWER = 16384, // 6
50  // !!! never read LCA_KEEP1 = 65536,// 8
51  // !!! never used LCA_KEEP2 = 131072,// 9
52  LCA_AMBACKBLOCKER = 262144,// 10
54 
55 };
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
65 public:
67 
68  virtual ~MSLCM_DK2004();
69 
73  virtual int wantsChangeToRight(
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 
85  virtual int wantsChangeToLeft(
86  MSAbstractLaneChangeModel::MSLCMessager& msgPass, int blocked,
87  const std::pair<MSVehicle*, SUMOReal>& leader,
88  const std::pair<MSVehicle*, SUMOReal>& neighLead,
89  const std::pair<MSVehicle*, SUMOReal>& neighFollow,
90  const MSLane& neighLane,
91  const std::vector<MSVehicle::LaneQ>& preb,
92  MSVehicle** lastBlocked);
93 
94  virtual void* inform(void* info, MSVehicle* sender);
95 
104  virtual SUMOReal patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal max,
105  const MSCFModel& cfModel);
106 
107  virtual void changed();
108 
109  SUMOReal getProb() const;
110  virtual void prepareStep();
111 
113  return myChangeProbability;
114  }
115 
116 
117 protected:
119  int& blocked, int dir,
120  const std::pair<MSVehicle*, SUMOReal>& neighLead,
121  const std::pair<MSVehicle*, SUMOReal>& neighFollow);
122 
123  inline bool amBlockingLeader() {
124  return (myOwnState & LCA_AMBLOCKINGLEADER) != 0;
125  }
126  inline bool amBlockingFollower() {
127  return (myOwnState & LCA_AMBLOCKINGFOLLOWER) != 0;
128  }
129  inline bool amBlockingFollowerNB() {
131  }
132  inline bool amBlockingFollowerPlusNB() {
134  }
135  inline bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
136  return dist / (abs(laneOffset)) < lookForwardDist;
137  }
138  inline bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist) {
139  return dist / abs(laneOffset) > lookForwardDist;
140  }
141 
142  typedef std::pair<SUMOReal, int> Info;
143 
144 
145 
146 protected:
148 
151 
152  std::vector<SUMOReal> myVSafes;
154 
155 };
156 
157 
158 #endif
159 
160 /****************************************************************************/
161 
bool amBlockingLeader()
Definition: MSLCM_DK2004.h:123
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
MSLCM_DK2004(MSVehicle &v)
#define min(a, b)
Definition: polyfonts.c:62
The car-following model abstraction.
Definition: MSCFModel.h:58
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)
Called to examine whether the vehicle wants to change to right This method gets the information about...
SUMOReal getChangeProbability() const
Definition: MSLCM_DK2004.h:112
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)
Called to examine whether the vehicle wants to change to left This method gets the information about ...
#define abs(a)
Definition: polyfonts.c:63
SUMOReal myChangeProbability
Definition: MSLCM_DK2004.h:147
A class responsible for exchanging messages between cars involved in lane-change interaction.
#define max(a, b)
Definition: polyfonts.c:61
void informBlocker(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int &blocked, int dir, const std::pair< MSVehicle *, SUMOReal > &neighLead, const std::pair< MSVehicle *, SUMOReal > &neighFollow)
SUMOReal myLeftSpace
Definition: MSLCM_DK2004.h:150
virtual void changed()
SUMOReal getProb() const
virtual void * inform(void *info, MSVehicle *sender)
bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
Definition: MSLCM_DK2004.h:135
virtual ~MSLCM_DK2004()
bool amBlockingFollower()
Definition: MSLCM_DK2004.h:126
int myOwnState
The current state of the vehicle.
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 amBlockingFollowerNB()
Definition: MSLCM_DK2004.h:129
std::pair< SUMOReal, int > Info
Definition: MSLCM_DK2004.h:142
virtual void prepareStep()
#define SUMOReal
Definition: config.h:221
bool amBlockingFollowerPlusNB()
Definition: MSLCM_DK2004.h:132
std::vector< SUMOReal > myVSafes
Definition: MSLCM_DK2004.h:152
SUMOReal myLeadingBlockerLength
Definition: MSLCM_DK2004.h:149
MyLCAEnum
Definition: MSLCM_DK2004.h:42
bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
Definition: MSLCM_DK2004.h:138
Representation of a lane in the micro simulation.
Definition: MSLane.h:73
A lane change model developed by D. Krajzewicz between 2004 and 2010.
Definition: MSLCM_DK2004.h:64
Interface for lane-change models.