42 #ifdef CHECK_MEMORY_LEAKS 44 #endif // CHECK_MEMORY_LEAKS 52 #define LOOK_FORWARD_SPEED_DIVIDER 14. 54 #define LOOK_FORWARD_FAR 15. 55 #define LOOK_FORWARD_NEAR 5. 60 #define JAM_FACTOR2 1. 68 myChangeProbability(0),
69 myLeadingBlockerLength(0), myLeftSpace(0) {}
79 const std::pair<MSVehicle*, SUMOReal>& leader,
80 const std::pair<MSVehicle*, SUMOReal>& neighLead,
81 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
83 const std::vector<MSVehicle::LaneQ>& preb,
87 return (laneOffset == -1 ?
88 wantsChangeToRight(msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked)
89 :
wantsChangeToLeft(msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked));
97 const std::pair<MSVehicle*, SUMOReal>& leader,
98 const std::pair<MSVehicle*, SUMOReal>& neighLead,
99 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
101 const std::vector<MSVehicle::LaneQ>& preb,
105 #ifdef DEBUG_VEHICLE_GUI_SELECTION 111 int bestLaneOffset = 0;
122 for (
int p = 0; p < (int) preb.size(); ++p) {
123 if (preb[p].lane == prebLane && p > 0) {
126 currentDist = curr.
length;
128 neighDist = preb[p - 1].length;
129 neighExtDist = preb[p - 1].lane->getLength();
130 best = preb[p + bestLaneOffset];
139 if (leader.first != 0
156 if ((*lastBlocked) != 0) {
192 if (neighLead.second > 0 && neighLead.second > leader.second) {
198 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_LEFT) != 0) {
216 SUMOReal maxJam =
MAX2(preb[currIdx - 1].occupation, preb[currIdx].occupation);
229 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < rv)) {
245 (
currentDistAllows(neighDist, bestLaneOffset, rv) || neighDist >= currentDist)) {
265 if (neighLead.first == 0) {
271 if (leader.first == 0) {
280 if (thisLaneVSafe - neighLaneVSafe > 5. / 3.6) {
293 if (neighLaneVSafe >= vmax) {
309 const std::pair<MSVehicle*, SUMOReal>& leader,
310 const std::pair<MSVehicle*, SUMOReal>& neighLead,
311 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
313 const std::vector<MSVehicle::LaneQ>& preb,
317 #ifdef DEBUG_VEHICLE_GUI_SELECTION 323 int bestLaneOffset = 0;
334 for (
int p = 0; p < (int) preb.size(); ++p) {
335 if (preb[p].lane == prebLane) {
338 currentDist = curr.
length;
340 neighDist = preb[p + 1].length;
341 neighExtDist = preb[p + 1].lane->getLength();
342 best = preb[p + bestLaneOffset];
351 if (leader.first != 0
368 if ((*lastBlocked) != 0) {
404 if (neighLead.second > 0 && neighLead.second > leader.second) {
410 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_RIGHT) != 0) {
428 SUMOReal maxJam =
MAX2(preb[currIdx + 1].occupation, preb[currIdx].occupation);
441 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < lv)) {
466 (
currentDistAllows(neighDist, bestLaneOffset, lv) || neighDist >= currentDist)) {
484 if (neighLead.first == 0) {
490 if (leader.first == 0) {
498 if (thisLaneVSafe > neighLaneVSafe) {
518 #ifdef DEBUG_VEHICLE_GUI_SELECTION 536 return MAX2(min, safe);
550 for (std::vector<SUMOReal>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
552 if (v >= min && v <= max) {
553 nVSafe =
MIN2(v, nVSafe);
568 return (min + wanted) / (
SUMOReal) 2.0;
571 return (max + wanted) / (
SUMOReal) 2.0;
573 return (min + wanted) / (
SUMOReal) 2.0;
584 return (min + wanted) / (
SUMOReal) 2.0;
597 return (max + wanted) / (
SUMOReal) 2.0;
603 return (min + wanted) / (
SUMOReal) 2.0;
635 const std::pair<MSVehicle*, SUMOReal>& neighLead,
636 const std::pair<MSVehicle*, SUMOReal>& neighFollow) {
638 assert(neighFollow.first != 0);
653 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 follow 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)
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.
void initLastLaneChangeOffset(int dir)
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)
std::string gDebugSelectedVehicle
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 void changed(int dir)
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) ...
SUMOReal getSpeedLimit() const
Returns the lane's maximum allowed speed.
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)
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
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.
const std::string & getID() const
Returns the name of the vehicle.
virtual bool congested(const MSVehicle *const neighLeader)
The action is due to the wish to be faster (tactical lc)
std::vector< SUMOReal > myVSafes