42 #ifdef CHECK_MEMORY_LEAKS
44 #endif // CHECK_MEMORY_LEAKS
47 #ifdef DEBUG_VEHICLE_GUI_SELECTION
59 #define LOOK_FORWARD_SPEED_DIVIDER 14.
61 #define LOOK_FORWARD_FAR 15.
62 #define LOOK_FORWARD_NEAR 5.
67 #define JAM_FACTOR2 1.
75 myChangeProbability(0),
76 myLeadingBlockerLength(0), myLeftSpace(0) {}
86 const std::pair<MSVehicle*, SUMOReal>& leader,
87 const std::pair<MSVehicle*, SUMOReal>& neighLead,
88 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
90 const std::vector<MSVehicle::LaneQ>& preb,
94 return (laneOffset == -1 ?
95 wantsChangeToRight(msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked)
96 :
wantsChangeToLeft(msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked));
104 const std::pair<MSVehicle*, SUMOReal>& leader,
105 const std::pair<MSVehicle*, SUMOReal>& neighLead,
106 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
108 const std::vector<MSVehicle::LaneQ>& preb,
112 #ifdef DEBUG_VEHICLE_GUI_SELECTION
118 int bestLaneOffset = 0;
129 for (
int p = 0; p < (
int) preb.size(); ++p) {
130 if (preb[p].lane == prebLane && p > 0) {
133 currentDist = curr.
length;
135 neighDist = preb[p - 1].length;
136 neighExtDist = preb[p - 1].lane->getLength();
137 best = preb[p + bestLaneOffset];
146 if (leader.first != 0
163 if ((*lastBlocked) != 0) {
199 if (neighLead.second > 0 && neighLead.second > leader.second) {
205 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_LEFT) != 0) {
223 SUMOReal maxJam =
MAX2(preb[currIdx - 1].occupation, preb[currIdx].occupation);
236 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < rv)) {
252 (
currentDistAllows(neighDist, bestLaneOffset, rv) || neighDist >= currentDist)) {
272 if (neighLead.first == 0) {
278 if (leader.first == 0) {
287 if (thisLaneVSafe - neighLaneVSafe > 5. / 3.6) {
300 if (neighLaneVSafe >= vmax) {
316 const std::pair<MSVehicle*, SUMOReal>& leader,
317 const std::pair<MSVehicle*, SUMOReal>& neighLead,
318 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
320 const std::vector<MSVehicle::LaneQ>& preb,
324 #ifdef DEBUG_VEHICLE_GUI_SELECTION
330 int bestLaneOffset = 0;
341 for (
int p = 0; p < (
int) preb.size(); ++p) {
342 if (preb[p].lane == prebLane) {
345 currentDist = curr.
length;
347 neighDist = preb[p + 1].length;
348 neighExtDist = preb[p + 1].lane->getLength();
349 best = preb[p + bestLaneOffset];
358 if (leader.first != 0
375 if ((*lastBlocked) != 0) {
411 if (neighLead.second > 0 && neighLead.second > leader.second) {
417 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_RIGHT) != 0) {
435 SUMOReal maxJam =
MAX2(preb[currIdx + 1].occupation, preb[currIdx].occupation);
448 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < lv)) {
473 (
currentDistAllows(neighDist, bestLaneOffset, lv) || neighDist >= currentDist)) {
491 if (neighLead.first == 0) {
497 if (leader.first == 0) {
505 if (thisLaneVSafe > neighLaneVSafe) {
525 #ifdef DEBUG_VEHICLE_GUI_SELECTION
543 return MAX2(min, safe);
557 for (std::vector<SUMOReal>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
559 if (v >= min && v <= max) {
560 nVSafe =
MIN2(v, nVSafe);
575 return (min + wanted) / (
SUMOReal) 2.0;
578 return (max + wanted) / (
SUMOReal) 2.0;
580 return (min + wanted) / (
SUMOReal) 2.0;
591 return (min + wanted) / (
SUMOReal) 2.0;
604 return (max + wanted) / (
SUMOReal) 2.0;
610 return (min + wanted) / (
SUMOReal) 2.0;
642 const std::pair<MSVehicle*, SUMOReal>& neighLead,
643 const std::pair<MSVehicle*, SUMOReal>& neighFollow) {
645 assert(neighFollow.first != 0);
660 if (neighLead.first != 0 && neighLead.second > 0) {
SUMOReal myChangeProbability
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
SUMOReal getMaxSpeed() const
Get vehicle's maximum speed [m/s].
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
The action is done to help someone else.
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive...
virtual SUMOReal followSpeed(const MSVehicle *const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const =0
Computes the vehicle's safe speed (no dawdling)
SUMOReal getLength() const
Returns the lane's length.
virtual SUMOReal maxNextSpeed(SUMOReal speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
The car-following model abstraction.
virtual void prepareStep()
void * informNeighFollower(void *info, MSVehicle *sender)
Informs the follower on the desired lane.
bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
virtual bool predInteraction(const MSVehicle *const leader)
SUMOReal getSecureGap(const SUMOReal speed, const SUMOReal leaderSpeed, const SUMOReal leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum.
SUMOReal myLeadingBlockerLength
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
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 ...
SUMOReal length
The overall length which may be driven when using this lane without a lane change.
The action is urgent (to be defined by lc-model)
#define UNUSED_PARAMETER(x)
bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
A class responsible for exchanging messages between cars involved in lane-change interaction.
MSLane * lane
The described lane.
std::pair< SUMOReal, int > Info
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
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.
virtual SUMOReal stopSpeed(const MSVehicle *const veh, const SUMOReal speed, SUMOReal gap2pred) const =0
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling) ...
A structure representing the best lanes for continuing the route.
#define LOOK_FORWARD_SPEED_DIVIDER
SUMOReal getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
bool amBlockingFollowerPlusNB()
int myOwnState
The current state of the vehicle.
MSVehicle & myVehicle
The vehicle this lane-changer belongs to.
void * informNeighLeader(void *info, MSVehicle *sender)
Informs the leader on the desired lane.
The action is needed to follow the route (navigational lc)
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
SUMOTime myLastLaneChangeOffset
information how long ago the vehicle has performed a lane-change
SUMOReal occupation
The overall vehicle sum on consecutive lanes which can be passed without a lane change.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
void informBlocker(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int &blocked, int dir, const std::pair< MSVehicle *, SUMOReal > &neighLead, const std::pair< MSVehicle *, SUMOReal > &neighFollow)
const SUMOReal SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Needs to stay on the current lane.
SUMOReal getSpeed() const
Returns the vehicle's current speed.
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...
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...
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
MSLane * getLane() const
Returns the lane the vehicle is on.
The edge is an internal edge.
#define LOOK_FORWARD_NEAR
GUISelectedStorage gSelected
A global holder of selected objects.
Representation of a lane in the micro simulation.
const MSCFModel & myCarFollowModel
The vehicle's car following model.
virtual void * inform(void *info, MSVehicle *sender)
Interface for lane-change models.
virtual bool congested(const MSVehicle *const neighLeader)
The action is due to the wish to be faster (tactical lc)
std::vector< SUMOReal > myVSafes