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;
634 const std::pair<MSVehicle*, SUMOReal>& neighLead,
635 const std::pair<MSVehicle*, SUMOReal>& neighFollow) {
637 assert(neighFollow.first != 0);
652 if (neighLead.first != 0 && neighLead.second > 0) {
SUMOReal myChangeProbability
SUMOReal getLength() const
Returns the lane's length.
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
The action is done to help someone else.
virtual bool predInteraction(const std::pair< MSVehicle *, SUMOReal > &leader)
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 SUMOReal followSpeed(const MSVehicle *const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const =0
Computes the vehicle's follow speed (no dawdling)
The car-following model abstraction.
virtual void prepareStep()
void * informNeighFollower(void *info, MSVehicle *sender)
Informs the follower on the desired lane.
SUMOReal getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
SUMOReal getSpeedLimit() const
Returns the lane's maximum allowed speed.
bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
SUMOReal myLeadingBlockerLength
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 ...
The action is due to the wish to be faster (tactical lc)
SUMOReal length
The overall length which may be driven when using this lane without a lane change.
#define UNUSED_PARAMETER(x)
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 (>=0)
std::string gDebugSelectedVehicle
Needs to stay on the current lane.
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.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
The action is urgent (to be defined by lc-model)
std::pair< SUMOReal, int > Info
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.
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
The action is needed to follow the route (navigational lc)
A structure representing the best lanes for continuing the route.
#define LOOK_FORWARD_SPEED_DIVIDER
bool amBlockingFollowerPlusNB()
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
int myOwnState
The current state of the vehicle.
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
MSVehicle & myVehicle
The vehicle this lane-changer belongs to.
void * informNeighLeader(void *info, MSVehicle *sender)
Informs the leader on the desired lane.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
SUMOReal occupation
The overall vehicle sum on consecutive lanes which can be passed without a lane change.
SUMOReal getMaxSpeed() const
Get vehicle's maximum speed [m/s].
void informBlocker(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int &blocked, int dir, const std::pair< MSVehicle *, SUMOReal > &neighLead, const std::pair< MSVehicle *, SUMOReal > &neighFollow)
virtual SUMOReal stopSpeed(const MSVehicle *const veh, const SUMOReal speed, SUMOReal gap) const =0
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling) ...
const SUMOReal SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
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...
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
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 !!!
virtual SUMOReal maxNextSpeed(SUMOReal speed, const MSVehicle *const veh) const
Returns the maximum speed given the 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)
SUMOReal getSpeed() const
Returns the vehicle's current speed.
Interface for lane-change models.
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
virtual bool congested(const MSVehicle *const neighLeader)
std::vector< SUMOReal > myVSafes