42 #ifdef CHECK_MEMORY_LEAKS
44 #endif // CHECK_MEMORY_LEAKS
47 #ifdef DEBUG_VEHICLE_GUI_SELECTION
59 #define LOOK_FORWARD_SPEED_DIVIDER (SUMOReal)14.
61 #define LOOK_FORWARD_RIGHT (SUMOReal)10.
62 #define LOOK_FORWARD_LEFT (SUMOReal)20.
64 #define JAM_FACTOR (SUMOReal)1.
66 #define LCA_RIGHT_IMPATIENCE (SUMOReal)-1.
67 #define CUT_IN_LEFT_SPEED_THRESHOLD (SUMOReal)27.
69 #define LOOK_AHEAD_MIN_SPEED (SUMOReal)0.0
70 #define LOOK_AHEAD_SPEED_MEMORY (SUMOReal)0.9
71 #define LOOK_AHEAD_SPEED_DECREMENT 6.
73 #define HELP_DECEL_FACTOR (SUMOReal)1.0
75 #define HELP_OVERTAKE (SUMOReal)(10.0 / 3.6)
76 #define MIN_FALLBEHIND (SUMOReal)(14.0 / 3.6)
78 #define KEEP_RIGHT_HEADWAY (SUMOReal)2.0
80 #define URGENCY (SUMOReal)2.0
82 #define ROUNDABOUT_DIST_BONUS (SUMOReal)80.0
84 #define CHANGE_PROB_THRESHOLD_RIGHT (SUMOReal)2.0
85 #define CHANGE_PROB_THRESHOLD_LEFT (SUMOReal)0.2
86 #define KEEP_RIGHT_TIME (SUMOReal)5.0 // the number of seconds after which a vehicle should move to the right lane
87 #define KEEP_RIGHT_ACCEPTANCE (SUMOReal)2.0 // calibration factor for determining the desire to keep right
89 #define OVERTAKE_RIGHT_FORBIDDEN true // This holds true for german traffic but should be made configurable to model american traffic
98 mySpeedGainProbability(0),
99 myKeepRightProbability(0),
100 myLeadingBlockerLength(0),
115 const std::pair<MSVehicle*, SUMOReal>& leader,
116 const std::pair<MSVehicle*, SUMOReal>& neighLead,
117 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
119 const std::vector<MSVehicle::LaneQ>& preb,
122 const int result =
_wantsChange(laneOffset, msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked);
149 return MAX2(min, safe);
156 for (std::vector<SUMOReal>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
158 if (v >= min && v <= max) {
159 nVSafe =
MIN2(v, nVSafe);
174 return (max + wanted) / (
SUMOReal) 2.0;
178 return (min + wanted) / (
SUMOReal) 2.0;
181 return (max + wanted) / (
SUMOReal) 2.0;
189 return (max + wanted) / (
SUMOReal) 2.0;
216 const std::pair<MSVehicle*, SUMOReal>& neighLead,
220 for (std::vector<SUMOReal>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
223 plannedSpeed =
MIN2(plannedSpeed, v);
227 assert(neighLead.first != 0);
231 const SUMOReal overtakeDist = (neighLead.second
243 || dv * remainingSeconds < overtakeDist) {
266 }
else if (neighLead.first != 0) {
274 return MIN2(targetSpeed, plannedSpeed);
286 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
290 assert(neighFollow.first != 0);
296 if ((neededGap - neighFollow.second) / remainingSeconds < (plannedSpeed - nv->
getSpeed())) {
314 const SUMOReal dv = plannedSpeed - neighNewSpeed1s;
316 const SUMOReal decelGap = neighFollow.second + dv;
318 if (decelGap > 0 && decelGap >= secureGap) {
324 }
else if (dv > 0 && dv * remainingSeconds > (secureGap - decelGap +
POSITION_EPS)) {
345 const SUMOReal overtakeDist = (neighFollow.second
351 const SUMOReal needDV = overtakeDist / remainingSeconds;
395 const std::pair<MSVehicle*, SUMOReal>& leader,
396 const std::pair<MSVehicle*, SUMOReal>& neighLead,
397 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
399 const std::vector<MSVehicle::LaneQ>& preb,
402 assert(laneOffset == 1 || laneOffset == -1);
406 int bestLaneOffset = 0;
415 for (
int p = 0; p < (
int) preb.size(); ++p) {
416 if (preb[p].lane == prebLane && p + laneOffset >= 0) {
417 assert(p + laneOffset < (
int)preb.size());
419 neigh = preb[p + laneOffset];
420 currentDist = curr.
length;
422 bestLaneOffset = curr.bestLaneOffset;
423 if (bestLaneOffset == 0 && preb[p + laneOffset].bestLaneOffset == 0) {
424 bestLaneOffset = laneOffset;
426 best = preb[p + bestLaneOffset];
432 const bool right = (laneOffset == -1);
436 const bool changeToBest = (right && bestLaneOffset < 0) || (!right && bestLaneOffset > 0);
441 if (lastBlocked != firstBlocked) {
473 int roundaboutEdgesAhead = 0;
475 if ((*it) != 0 && (*it)->getEdge().isRoundabout()) {
476 roundaboutEdgesAhead += 1;
477 }
else if (roundaboutEdgesAhead > 0) {
482 int roundaboutEdgesAheadNeigh = 0;
484 if ((*it) != 0 && (*it)->getEdge().isRoundabout()) {
485 roundaboutEdgesAheadNeigh += 1;
486 }
else if (roundaboutEdgesAheadNeigh > 0) {
491 if (roundaboutEdgesAhead > 1) {
497 const SUMOReal maxJam =
MAX2(preb[currIdx + laneOffset].occupation, preb[currIdx].occupation);
527 }
else if (bestLaneOffset == 0 && (neighLeftPlace * 2. < laDist)) {
537 if ((ret & lcaCounter) != 0) {
549 if (changeToBest &&
abs(bestLaneOffset) > 1) {
557 if (*firstBlocked != neighLead.first) {
564 const SUMOReal plannedSpeed =
informLeader(msgPass, blocked, myLca, neighLead, remainingSeconds);
565 if (plannedSpeed >= 0) {
567 informFollower(msgPass, blocked, myLca, neighFollow, remainingSeconds, plannedSpeed);
573 if (roundaboutEdgesAhead > 1) {
621 if (neighLead.first == 0) {
626 &
myVehicle,
myVehicle.
getSpeed(), neighLead.second, neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel()));
628 if (leader.first == 0) {
638 const SUMOReal relativeGain = (neighLaneVSafe - thisLaneVSafe) / neighLaneVSafe;
641 if (thisLaneVSafe - 5 / 3.6 > neighLaneVSafe) {
657 SUMOReal fullSpeedDrivingSeconds =
MIN2(acceptanceTime, fullSpeedGap / vMax);
658 if (neighLead.first != 0 && neighLead.first->getSpeed() < vMax) {
661 vMax, neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel())));
662 fullSpeedDrivingSeconds =
MIN2(fullSpeedDrivingSeconds, fullSpeedGap / (vMax - neighLead.first->getSpeed()));
673 <<
" neighDist=" << neighDist
675 <<
" leaderSpeed=" << (neighLead.first == 0 ? -1 : neighLead.first->getSpeed())
677 myVehicle.
getSpeed(), neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel()))
678 <<
" acceptanceTime=" << acceptanceTime
679 <<
" fullSpeedGap=" << fullSpeedGap
680 <<
" fullSpeedDrivingSeconds=" << fullSpeedDrivingSeconds
681 <<
" dProb=" << deltaProb
695 if (thisLaneVSafe > neighLaneVSafe) {
710 && (right ? mySpeedGainProbability < 0 : mySpeedGainProbability > 0)) {
722 if ((*blocked) != 0) {
734 (*blocked)->getCarFollowModel().getMaxDecel()));
void saveBlockerLength(MSVehicle *blocker, int lcaCounter)
save space for vehicles which need to counter-lane-change
#define CHANGE_PROB_THRESHOLD_RIGHT
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].
MSLCM_LC2013(MSVehicle &v)
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 MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
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.
#define LOOK_FORWARD_RIGHT
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...
#define OVERTAKE_RIGHT_FORBIDDEN
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)
#define KEEP_RIGHT_ACCEPTANCE
The car-following model abstraction.
SUMOReal myKeepRightProbability
void * informNeighFollower(void *info, MSVehicle *sender)
Informs the follower on the desired lane.
SUMOReal getLength() const
Get vehicle's length [m].
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
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 getPositionOnLane() const
Get the vehicle's position along the lane.
std::vector< SUMOReal > myVSafes
The action is due to a TraCI request.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
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)
void informFollower(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, int dir, const std::pair< MSVehicle *, SUMOReal > &neighFollow, SUMOReal remainingSeconds, SUMOReal plannedSpeed)
decide whether we will try cut in before the follower or allow to be overtaken
MSAbstractLaneChangeModel & getLaneChangeModel()
#define ROUNDABOUT_DIST_BONUS
A class responsible for exchanging messages between cars involved in lane-change interaction.
bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
SUMOReal brakeGap(const SUMOReal speed) const
Returns the distance the vehicle needs to halt including driver's reaction time.
SUMOReal myLeadingBlockerLength
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
#define CUT_IN_LEFT_SPEED_THRESHOLD
SUMOReal myLookAheadSpeed
#define LOOK_AHEAD_SPEED_MEMORY
int slowDownForBlocked(MSVehicle **blocked, int state)
compute useful slowdowns for blocked vehicles
#define CHANGE_PROB_THRESHOLD_LEFT
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.
SUMOReal getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
SUMOReal changeRequestRemainingSeconds(const SUMOTime currentTime) const
Return the remaining number of seconds of the current laneTimeLine assuming one exists.
int myOwnState
The current state of the vehicle.
SUMOReal informLeader(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, int dir, const std::pair< MSVehicle *, SUMOReal > &neighLead, SUMOReal remainingSeconds)
virtual void saveBlockerLength(SUMOReal length)
reserve space at the end of the lane to avoid dead locks
std::pair< SUMOReal, int > Info
information regarding save velocity (unused) and state flags of the ego vehicle
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)
helper function for doing the actual work
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)
Influencer & getInfluencer()
Returns the velocity/lane influencer.
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.
std::vector< MSLane * > bestContinuations
Consecutive lane that can be followed without a lane change (contribute to length and occupation) ...
The action is due to the default of keeping right "Rechtsfahrgebot".
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
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.
SUMOReal getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
#define LOOK_FORWARD_LEFT
SUMOReal mySpeedGainProbability
a value for tracking the probability that a change to the offset with the same sign is beneficial ...
bool amBlockingFollowerPlusNB()
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
SUMOReal _patchSpeed(const SUMOReal min, const SUMOReal wanted, const SUMOReal max, const MSCFModel &cfModel)
#define LOOK_AHEAD_MIN_SPEED
#define LCA_RIGHT_IMPATIENCE
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.
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
The edge is an internal edge.
void * inform(void *info, MSVehicle *sender)
Representation of a lane in the micro simulation.
const MSCFModel & myCarFollowModel
The vehicle's car following model.
Interface for lane-change models.
int getBestLaneOffset() const
returns the current offset from the best lane
#define HELP_DECEL_FACTOR
const std::string & getID() const
Returns the name of the vehicle.
The action is due to the wish to be faster (tactical lc)