40 #ifdef CHECK_MEMORY_LEAKS
42 #endif // CHECK_MEMORY_LEAKS
45 #ifdef DEBUG_VEHICLE_GUI_SELECTION
57 #define LOOK_FORWARD_SPEED_DIVIDER 14.
59 #define LOOK_FORWARD_FAR 15.
60 #define LOOK_FORWARD_NEAR 5.
65 #define JAM_FACTOR2 1.
73 myChangeProbability(0),
74 myLeadingBlockerLength(0), myLeftSpace(0) {}
84 const std::pair<MSVehicle*, SUMOReal>& leader,
85 const std::pair<MSVehicle*, SUMOReal>& neighLead,
86 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
88 const std::vector<MSVehicle::LaneQ>& preb,
90 #ifdef DEBUG_VEHICLE_GUI_SELECTION
96 int bestLaneOffset = 0;
102 for (
int p = 0; p < (
int) preb.size(); ++p) {
106 currentDist = curr.
length;
108 neighDist = preb[p - 1].length;
109 neighExtDist = preb[p - 1].lane->getLength();
110 best = preb[p + bestLaneOffset];
118 if (leader.first != 0
135 if ((*lastBlocked) != 0) {
171 if (neighLead.second > 0 && neighLead.second > leader.second) {
177 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_LEFT) != 0) {
195 SUMOReal maxJam =
MAX2(preb[currIdx - 1].occupation, preb[currIdx].occupation);
208 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < rv)) {
224 (
currentDistAllows(neighDist, bestLaneOffset, rv) || neighDist >= currentDist)) {
244 if (neighLead.first == 0) {
250 if (leader.first == 0) {
259 if (thisLaneVSafe - neighLaneVSafe > 5. / 3.6) {
272 if (neighLaneVSafe >= vmax) {
303 const std::pair<MSVehicle*, SUMOReal>& leader,
304 const std::pair<MSVehicle*, SUMOReal>& neighLead,
305 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
307 const std::vector<MSVehicle::LaneQ>& preb,
309 #ifdef DEBUG_VEHICLE_GUI_SELECTION
315 int bestLaneOffset = 0;
321 for (
int p = 0; p < (
int) preb.size(); ++p) {
325 currentDist = curr.
length;
327 neighDist = preb[p + 1].length;
328 neighExtDist = preb[p + 1].lane->getLength();
329 best = preb[p + bestLaneOffset];
337 if (leader.first != 0
354 if ((*lastBlocked) != 0) {
390 if (neighLead.second > 0 && neighLead.second > leader.second) {
396 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_RIGHT) != 0) {
414 SUMOReal maxJam =
MAX2(preb[currIdx + 1].occupation, preb[currIdx].occupation);
427 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < lv)) {
452 (
currentDistAllows(neighDist, bestLaneOffset, lv) || neighDist >= currentDist)) {
470 if (neighLead.first == 0) {
476 if (leader.first == 0) {
484 if (thisLaneVSafe > neighLaneVSafe) {
511 #ifdef DEBUG_VEHICLE_GUI_SELECTION
530 return MAX2(min, safe);
544 for (std::vector<SUMOReal>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
546 if (v >= min && v <= max) {
547 nVSafe =
MIN2(v, nVSafe);
562 return (min + wanted) / (
SUMOReal) 2.0;
565 return (max + wanted) / (
SUMOReal) 2.0;
567 return (min + wanted) / (
SUMOReal) 2.0;
578 return (min + wanted) / (
SUMOReal) 2.0;
591 return (max + wanted) / (
SUMOReal) 2.0;
597 return (min + wanted) / (
SUMOReal) 2.0;
629 const std::pair<MSVehicle*, SUMOReal>& neighLead,
630 const std::pair<MSVehicle*, SUMOReal>& neighFollow) {
632 assert(neighFollow.first != 0);
647 if (neighLead.first != 0 && neighLead.second > 0) {
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_DK2004(MSVehicle &v)
#define LOOK_FORWARD_NEAR
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
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.
void * informNeighFollower(void *info, MSVehicle *sender)
Informs the follower on the desired lane.
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)
Called to examine whether the vehicle wants to change to right This method gets the information about...
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 getPositionOnLane() const
Get the vehicle's position along the lane.
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)
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 due to the wish to follow the route (navigational lc)
SUMOReal myChangeProbability
A class responsible for exchanging messages between cars involved in lane-change interaction.
MSLane * lane
The described lane.
void informBlocker(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int &blocked, int dir, const std::pair< MSVehicle *, SUMOReal > &neighLead, const std::pair< MSVehicle *, SUMOReal > &neighFollow)
vehicle want's to change to right lane
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
virtual void * inform(void *info, MSVehicle *sender)
bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
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.
SUMOReal getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
int myOwnState
The current state of the vehicle.
#define LOOK_FORWARD_SPEED_DIVIDER
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.
MSVehicle & myVehicle
The vehicle this lane-changer belongs to.
vehicle want's to change to left lane
void * informNeighLeader(void *info, MSVehicle *sender)
Informs the leader on the desired lane.
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::pair< SUMOReal, int > Info
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
SUMOReal getSpeed() const
Returns the vehicle's current speed.
virtual void prepareStep()
vehicle want's to keep the current lane
bool amBlockingFollowerPlusNB()
std::vector< SUMOReal > myVSafes
SUMOReal myLeadingBlockerLength
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.
bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
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.
Interface for lane-change models.
virtual bool congested(const MSVehicle *const neighLeader)
The action is due to the wish to be faster (tactical lc)
MSVehicle::ChangeRequest myChangeRequest