48 #define LOOK_FORWARD_SPEED_DIVIDER 14. 50 #define LOOK_FORWARD_FAR 15. 51 #define LOOK_FORWARD_NEAR 5. 56 #define JAM_FACTOR2 1. 64 myChangeProbability(0),
65 myLeadingBlockerLength(0), myLeftSpace(0) {}
75 const std::pair<MSVehicle*, double>& leader,
76 const std::pair<MSVehicle*, double>& neighLead,
77 const std::pair<MSVehicle*, double>& neighFollow,
79 const std::vector<MSVehicle::LaneQ>& preb,
83 return (laneOffset == -1 ?
84 wantsChangeToRight(msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked)
85 :
wantsChangeToLeft(msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked));
93 const std::pair<MSVehicle*, double>& leader,
94 const std::pair<MSVehicle*, double>& neighLead,
95 const std::pair<MSVehicle*, double>& neighFollow,
97 const std::vector<MSVehicle::LaneQ>& preb,
101 #ifdef DEBUG_VEHICLE_GUI_SELECTION 107 int bestLaneOffset = 0;
108 double currentDist = 0;
109 double neighDist = 0;
110 double neighExtDist = 0;
111 double currExtDist = 0;
118 for (
int p = 0; p < (int) preb.size(); ++p) {
119 if (preb[p].lane == prebLane && p > 0) {
122 currentDist = curr.
length;
124 neighDist = preb[p - 1].length;
125 neighExtDist = preb[p - 1].lane->getLength();
126 best = preb[p + bestLaneOffset];
135 if (leader.first != 0
152 if ((*lastBlocked) != 0) {
188 if (neighLead.second > 0 && neighLead.second > leader.second) {
194 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_LEFT) != 0) {
212 double maxJam =
MAX2(preb[currIdx - 1].occupation, preb[currIdx].occupation);
225 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < rv)) {
241 (
currentDistAllows(neighDist, bestLaneOffset, rv) || neighDist >= currentDist)) {
261 if (neighLead.first == 0) {
267 if (leader.first == 0) {
276 if (thisLaneVSafe - neighLaneVSafe > 5. / 3.6) {
288 vmax -= (double)(5. / 2.6);
289 if (neighLaneVSafe >= vmax) {
305 const std::pair<MSVehicle*, double>& leader,
306 const std::pair<MSVehicle*, double>& neighLead,
307 const std::pair<MSVehicle*, double>& neighFollow,
309 const std::vector<MSVehicle::LaneQ>& preb,
313 #ifdef DEBUG_VEHICLE_GUI_SELECTION 319 int bestLaneOffset = 0;
320 double currentDist = 0;
321 double neighDist = 0;
322 double neighExtDist = 0;
323 double currExtDist = 0;
330 for (
int p = 0; p < (int) preb.size(); ++p) {
331 if (preb[p].lane == prebLane) {
334 currentDist = curr.
length;
336 neighDist = preb[p + 1].length;
337 neighExtDist = preb[p + 1].lane->getLength();
338 best = preb[p + bestLaneOffset];
347 if (leader.first != 0
364 if ((*lastBlocked) != 0) {
400 if (neighLead.second > 0 && neighLead.second > leader.second) {
406 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_RIGHT) != 0) {
424 double maxJam =
MAX2(preb[currIdx + 1].occupation, preb[currIdx].occupation);
437 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < lv)) {
462 (
currentDistAllows(neighDist, bestLaneOffset, lv) || neighDist >= currentDist)) {
480 if (neighLead.first == 0) {
486 if (leader.first == 0) {
494 if (thisLaneVSafe > neighLaneVSafe) {
514 #ifdef DEBUG_VEHICLE_GUI_SELECTION 522 double MAGIC_offset = 1.;
532 return MAX2(min, safe);
544 double nVSafe = wanted;
546 for (std::vector<double>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
548 if (v >= min && v <= max) {
549 nVSafe =
MIN2(v, nVSafe);
564 return (min + wanted) / (double) 2.0;
567 return (max + wanted) / (double) 2.0;
569 return (min + wanted) / (double) 2.0;
580 return (min + wanted) / (double) 2.0;
593 return (max + wanted) / (double) 2.0;
599 return (min + wanted) / (double) 2.0;
630 const std::pair<MSVehicle*, double>& neighLead,
631 const std::pair<MSVehicle*, double>& neighFollow) {
633 assert(neighFollow.first != 0);
648 if (neighLead.first != 0 && neighLead.second > 0) {
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
double myChangeProbability
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
The action is done to help someone else.
MSLane * getLane() const
Returns the lane the vehicle is on.
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive...
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel) const =0
Computes the vehicle's follow speed (no dawdling)
The car-following model abstraction.
double getPositionOnLane() const
Get the vehicle's position along the lane.
virtual void prepareStep()
void * informNeighFollower(void *info, MSVehicle *sender)
Informs the follower on the desired lane.
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
bool currentDistDisallows(double dist, int laneOffset, double lookForwardDist)
double getLength() const
Returns the lane's length.
virtual double patchSpeed(const double min, const double wanted, const double max, const MSCFModel &cfModel)
Called to adapt the speed in order to allow a lane change.
virtual bool predInteraction(const std::pair< MSVehicle *, double > &leader)
MSLCM_DK2008(MSVehicle &v)
double length
The overall length which may be driven when using this lane without a lane change.
The action is due to the wish to be faster (tactical lc)
#define UNUSED_PARAMETER(x)
std::string gDebugSelectedVehicle
virtual int wantsChangeToRight(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, const std::pair< MSVehicle *, double > &leader, const std::pair< MSVehicle *, double > &neighLead, const std::pair< MSVehicle *, double > &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...
Needs to stay on the current lane.
A class responsible for exchanging messages between cars involved in lane-change interaction.
MSLane * lane
The described lane.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
blocked in all directions
The action is urgent (to be defined by lc-model)
virtual int wantsChangeToLeft(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, const std::pair< MSVehicle *, double > &leader, const std::pair< MSVehicle *, double > &neighLead, const std::pair< MSVehicle *, double > &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 ...
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
The action is needed to follow the route (navigational lc)
A structure representing the best lanes for continuing the current route starting at 'lane'...
#define LOOK_FORWARD_SPEED_DIVIDER
double getMinGap() const
Get the free space in front of vehicles of this class.
double getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
bool amBlockingFollowerPlusNB()
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
int myOwnState
The current state of the vehicle.
int wantsChange(int laneOffset, MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, const std::pair< MSVehicle *, double > &leader, const std::pair< MSVehicle *, double > &neighLead, const std::pair< MSVehicle *, double > &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...
MSVehicle & myVehicle
The vehicle this lane-changer belongs to.
void * informNeighLeader(void *info, MSVehicle *sender)
Informs the leader on the desired lane.
double 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.
bool currentDistAllows(double dist, int laneOffset, double lookForwardDist)
double myLeadingBlockerLength
std::vector< double > myVSafes
virtual void prepareStep()
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
std::pair< double, int > Info
double getSecureGap(const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
double getSpeed() const
Returns the vehicle's current speed.
The edge is an internal edge.
#define LOOK_FORWARD_NEAR
const std::string & getID() const
Returns the name of the vehicle.
Representation of a lane in the micro simulation.
const MSCFModel & myCarFollowModel
The vehicle's car following model.
virtual void * inform(void *info, MSVehicle *sender)
void informBlocker(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int &blocked, int dir, const std::pair< MSVehicle *, double > &neighLead, const std::pair< MSVehicle *, double > &neighFollow)
Interface for lane-change models.
virtual double stopSpeed(const MSVehicle *const veh, const double speed, double gap) const =0
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling) ...
virtual bool congested(const MSVehicle *const neighLeader)