45 #ifdef CHECK_MEMORY_LEAKS 47 #endif // CHECK_MEMORY_LEAKS 54 #define LOOK_FORWARD_SPEED_DIVIDER (SUMOReal)14. 56 #define LOOK_FORWARD_RIGHT (SUMOReal)10. 57 #define LOOK_FORWARD_LEFT (SUMOReal)20. 59 #define JAM_FACTOR (SUMOReal)1. 61 #define LCA_RIGHT_IMPATIENCE (SUMOReal)-1. 62 #define CUT_IN_LEFT_SPEED_THRESHOLD (SUMOReal)27. 64 #define LOOK_AHEAD_MIN_SPEED (SUMOReal)0.0 65 #define LOOK_AHEAD_SPEED_MEMORY (SUMOReal)0.9 66 #define LOOK_AHEAD_SPEED_DECREMENT 6. 68 #define HELP_DECEL_FACTOR (SUMOReal)1.0 70 #define HELP_OVERTAKE (SUMOReal)(10.0 / 3.6) 71 #define MIN_FALLBEHIND (SUMOReal)(7.0 / 3.6) 73 #define RELGAIN_NORMALIZATION_MIN_SPEED (SUMOReal)10.0 74 #define URGENCY (SUMOReal)2.0 76 #define KEEP_RIGHT_TIME (SUMOReal)5.0 // the number of seconds after which a vehicle should move to the right lane 77 #define KEEP_RIGHT_ACCEPTANCE (SUMOReal)7.0 // calibration factor for determining the desire to keep right 78 #define ROUNDABOUT_DIST_BONUS (SUMOReal)100.0 // valence (distance) for to faked per roundabout edge in front (inducing inner lane usage in roundabouts by decreasing sense of lc-urgency) 80 #define ROUNDABOUT_DIST_FACTOR (SUMOReal)10.0 // Must be >=1.0, serves an alternative way of decreasing sense lc-urgency by multiplying the distance along the next roundabout 81 #define ROUNDABOUT_DIST_TRESH (SUMOReal)10.0 // roundabout distances below ROUNDABOUT_DIST_TRESH are not multiplied by ROUNDABOUT_DIST_FACTOR 83 #define KEEP_RIGHT_HEADWAY (SUMOReal)2.0 84 #define MAX_ONRAMP_LENGTH (SUMOReal)200. 85 #define TURN_LANE_DIST (SUMOReal)200.0 // the distance at which a lane leading elsewhere is considered to be a turn-lane that must be avoided 98 #define DEBUG_COND (myVehicle.getID() == "disabled") 105 mySpeedGainProbability(0),
106 myKeepRightProbability(0),
107 myLeadingBlockerLength(0),
114 myChangeProbThresholdRight(2.0 * myKeepRightParam /
MAX2(
NUMERICAL_EPS, mySpeedGainParam)),
116 #ifdef DEBUG_CONSTRUCTOR 145 const std::pair<MSVehicle*, SUMOReal>& leader,
146 const std::pair<MSVehicle*, SUMOReal>& neighLead,
147 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
149 const std::vector<MSVehicle::LaneQ>& preb,
153 #ifdef DEBUG_WANTS_CHANGE 162 <<
" considerChangeTo=" << (laneOffset == -1 ?
"right" :
"left")
167 const int result =
_wantsChange(laneOffset, msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked);
169 #ifdef DEBUG_WANTS_CHANGE 174 <<
" wantsChangeTo=" << (laneOffset == -1 ?
"right" :
"left")
181 << ((result &
LCA_TRACI) ?
" (traci)" :
"")
196 #ifdef DEBUG_PATCH_SPEED 198 std::cout <<
"\nPATCH_SPEED\n" 204 <<
" wanted=" << wanted <<
"\n";
210 #ifdef DEBUG_PATCH_SPEED 212 const std::string patched = (wanted != newSpeed ?
" patched=" +
toString(newSpeed) :
"");
225 #ifdef DEBUG_PATCH_SPEED 231 <<
" wanted=" << wanted << std::endl;
240 #ifdef DEBUG_PATCH_SPEED 251 #ifdef DEBUG_PATCH_SPEED 253 std::cout << time <<
" veh=" <<
myVehicle.
getID() <<
" slowing down for leading blocker, safe=" << safe << (safe +
NUMERICAL_EPS < min ?
" (not enough)" :
"") <<
"\n";
256 return MAX2(min, safe);
263 for (std::vector<SUMOReal>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
275 #ifdef DEBUG_PATCH_SPEED 277 std::cout << time <<
" veh=" <<
myVehicle.
getID() <<
" got nVSafe=" << nVSafe <<
"\n";
282 #ifdef DEBUG_PATCH_SPEED 284 std::cout << time <<
" veh=" <<
myVehicle.
getID() <<
" ignoring low nVSafe=" << v <<
" min=" << min <<
"\n";
288 #ifdef DEBUG_PATCH_SPEED 290 std::cout << time <<
" veh=" <<
myVehicle.
getID() <<
" ignoring high nVSafe=" << v <<
" max=" << max <<
"\n";
298 #ifdef DEBUG_PATCH_SPEED 300 std::cout << time <<
" veh=" <<
myVehicle.
getID() <<
" got vSafe\n";
311 #ifdef DEBUG_PATCH_SPEED 313 std::cout << time <<
" veh=" <<
myVehicle.
getID() <<
" LCA_WANTS_LANECHANGE (strat, no vSafe)\n";
316 return (max + wanted) / (
SUMOReal) 2.0;
320 #ifdef DEBUG_PATCH_SPEED 322 std::cout << time <<
" veh=" <<
myVehicle.
getID() <<
" LCA_BLOCKED_BY_LEADER (coop)\n";
332 #ifdef DEBUG_PATCH_SPEED 334 std::cout << time <<
" veh=" <<
myVehicle.
getID() <<
" LCA_BLOCKED_BY_FOLLOWER (coop)\n";
337 return (max + wanted) / (
SUMOReal) 2.0;
378 #ifdef DEBUG_PATCH_SPEED 380 std::cout << time <<
" veh=" <<
myVehicle.
getID() <<
" LCA_AMBLOCKINGLEADER\n";
383 return (max + wanted) / (
SUMOReal) 2.0;
387 #ifdef DEBUG_PATCH_SPEED 389 std::cout << time <<
" veh=" <<
myVehicle.
getID() <<
" LCA_AMBLOCKINGFOLLOWER_DONTBRAKE\n";
415 #ifdef DEBUG_INFORMED 419 <<
" informedBy=" << sender->
getID()
420 <<
" info=" << pinfo->second
421 <<
" vSafe=" << pinfo->first
446 const std::pair<MSVehicle*, SUMOReal>& neighLead,
450 for (std::vector<SUMOReal>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
453 plannedSpeed =
MIN2(plannedSpeed, v);
456 #ifdef DEBUG_INFORMER 458 std::cout <<
"\nINFORM_LEADER" 464 assert(neighLead.first != 0);
466 #ifdef DEBUG_INFORMER 468 std::cout <<
" blocked by leader nv=" << nv->
getID() <<
" nvSpeed=" << nv->
getSpeed() <<
" needGap=" 478 overtakeTime = overtakeDist / dv;
481 overtakeTime = remainingSeconds + 1;
484 #ifdef DEBUG_INFORMER 487 <<
"\nnv = " << nv->
getID()
488 <<
"\nplannedSpeed = " << plannedSpeed
489 <<
"\nleaderSpeed = " << nv->
getSpeed()
491 <<
"\nremainingSeconds = " << remainingSeconds
492 <<
"\novertakeDist = " << overtakeDist
493 <<
"\novertakeTime = " << overtakeTime
508 && !(
isOpposite() && neighLead.second < 0 && neighLead.first->isStopped())) {
520 #ifdef DEBUG_INFORMER 523 <<
" cannot overtake leader nv=" << nv->
getID()
527 <<
" overtakeDist=" << overtakeDist
528 <<
" overtakeTime=" << overtakeTime
529 <<
" remainingSeconds=" << remainingSeconds
530 <<
" currentGap=" << neighLead.second
533 <<
" targetSpeed=" << targetSpeed
534 <<
" nextSpeed=" << nextSpeed
542 #ifdef DEBUG_INFORMER 545 <<
" cannot overtake fast leader nv=" << nv->
getID()
549 <<
" overtakeDist=" << overtakeDist
551 <<
" overtakeTime=" << overtakeTime
552 <<
" remainingSeconds=" << remainingSeconds
553 <<
" currentGap=" << neighLead.second
554 <<
" targetSpeed=" << targetSpeed
563 #ifdef DEBUG_INFORMER 566 <<
" wants to overtake leader nv=" << nv->
getID()
568 <<
" overtakeDist=" << overtakeDist
569 <<
" remainingSeconds=" << remainingSeconds
570 <<
" overtakeTime=" << overtakeTime
571 <<
" currentGap=" << neighLead.second
579 }
else if (neighLead.first != 0) {
587 #ifdef DEBUG_INFORMER 589 std::cout <<
" not blocked by leader nv=" << nv->
getID()
591 <<
" gap=" << neighLead.second
592 <<
" nextGap=" << neighLead.second - dv
594 <<
" targetSpeed=" << targetSpeed
598 return MIN2(targetSpeed, plannedSpeed);
609 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
616 #ifdef DEBUG_INFORMER 618 std::cout <<
"\nINFORM_FOLLOWER" 625 #ifdef DEBUG_INFORMER 627 std::cout <<
" blocked by follower nv=" << nv->
getID() <<
" nvSpeed=" << nv->
getSpeed() <<
" needGap=" 635 if ((neededGap - neighFollow.second) / remainingSeconds < (
MAX2(plannedSpeed, (
SUMOReal)0.) - nv->
getSpeed())) {
636 #ifdef DEBUG_INFORMER 638 std::cout <<
" wants to cut in before nv=" << nv->
getID() <<
" without any help." <<
"\nneededGap = " << neededGap <<
"\n";
670 dv = plannedSpeed - neighNewSpeed1s;
677 decelGap = neighFollow.second + dv;
684 neighNewSpeed1s = nv->
getSpeed() - helpDecel;
694 #ifdef DEBUG_INFORMER 698 <<
" plannedSpeed=" << plannedSpeed
699 <<
" neighNewSpeed=" << neighNewSpeed
700 <<
" neighNewSpeed1s=" << neighNewSpeed1s
702 <<
" gap=" << neighFollow.second
703 <<
" decelGap=" << decelGap
704 <<
" secureGap=" << secureGap
709 if (decelGap > 0 && decelGap >= secureGap) {
726 assert(vsafe <= vsafe1);
737 #ifdef DEBUG_INFORMER 739 std::cout <<
"nextGap=" << nextGap <<
" (without help decel) \n";
755 nv->
getSpeed(), plannedAccel, -decel2,
769 assert(vsafe >= vsafe1);
771 #ifdef DEBUG_INFORMER 773 std::cout <<
"nextGap=" << nextGap
774 <<
" (with vsafe1 and help decel) \nvsafe1=" << vsafe1
775 <<
" vsafe=" << vsafe
784 if (nextGap < nextSecureGap) {
786 vsafe = neighNewSpeed;
789 #ifdef DEBUG_INFORMER 791 std::cout <<
"nextGap=" << nextGap
792 <<
" minNextSecureGap=" << nextSecureGap
793 <<
" vsafe=" << vsafe <<
"\n";
801 #ifdef DEBUG_INFORMER 803 std::cout <<
" wants to cut in before nv=" << nv->
getID()
804 <<
" vsafe1=" << vsafe1 <<
" vsafe=" << vsafe
830 #ifdef DEBUG_INFORMER 832 std::cout <<
" wants to cut in before nv=" << nv->
getID() <<
" (eventually)\n";
839 #ifdef DEBUG_INFORMER 841 std::cout <<
" wants to cut in before nv=" << nv->
getID() <<
" (nv cannot overtake right)\n";
860 #ifdef DEBUG_INFORMER 864 std::cout <<
" wants right follower to slow down a bit\n";
871 #ifdef DEBUG_INFORMER 874 std::cout <<
" wants to cut in before right follower nv=" << nv->
getID() <<
" (eventually)\n";
896 if (gapAfterRemainingSecs >= secureGapAfterRemainingSecs) {
897 #ifdef DEBUG_INFORMER 899 std::cout <<
" wants to cut in before follower nv=" << nv->
getID() <<
" (eventually)\n";
912 #ifdef DEBUG_INFORMER 916 <<
" informs follower " << nv->
getID()
917 <<
" vhelp=" << vhelp
926 const SUMOReal needDV = overtakeDist / remainingSeconds;
930 #ifdef DEBUG_INFORMER 934 <<
" wants to be overtaken by=" << nv->
getID()
935 <<
" overtakeDist=" << overtakeDist
937 <<
" vhelp=" << vhelp
938 <<
" needDV=" << needDV
944 }
else if (neighFollow.first != 0) {
975 if (anticipatedGap > secureGap) {
982 if (anticipatedGap < secureGap) {
993 #ifdef DEBUG_INFORMER 995 std::cout <<
" wants to cut in before non-blocking follower nv=" << nv->
getID() <<
"\n";
1038 const std::pair<MSVehicle*, SUMOReal>& leader,
1039 const std::pair<MSVehicle*, SUMOReal>& neighLead,
1040 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
1042 const std::vector<MSVehicle::LaneQ>& preb,
1045 assert(laneOffset == 1 || laneOffset == -1);
1049 int bestLaneOffset = 0;
1064 const int prebOffset = (checkOpposite ? 0 : laneOffset);
1065 for (
int p = 0; p < (int) preb.size(); ++p) {
1066 if (preb[p].lane == prebLane && p + laneOffset >= 0) {
1067 assert(p + prebOffset < (
int)preb.size());
1069 neigh = preb[p + prebOffset];
1070 currentDist = curr.
length;
1071 neighDist = neigh.
length;
1072 bestLaneOffset = curr.bestLaneOffset;
1073 if (bestLaneOffset == 0 && preb[p + prebOffset].bestLaneOffset == 0) {
1074 #ifdef DEBUG_WANTS_CHANGE 1078 <<
" bestLaneOffsetOld=" << bestLaneOffset
1079 <<
" bestLaneOffsetNew=" << laneOffset
1083 bestLaneOffset = prebOffset;
1085 best = preb[p + bestLaneOffset];
1091 const bool right = (laneOffset == -1);
1093 neigh = preb[preb.size() - 1];
1096 bestLaneOffset = -1;
1098 neighDist = neigh.
length;
1099 currentDist = curr.
length;
1105 const bool changeToBest = (right && bestLaneOffset < 0) || (!right && bestLaneOffset > 0);
1111 if (lastBlocked != firstBlocked) {
1115 #ifdef DEBUG_WANTS_CHANGE 1124 <<
" leaderGap=" << leader.second
1126 <<
" neighLeadGap=" << neighLead.second
1128 <<
" neighFollowGap=" << neighFollow.second
1151 assert(memoryFactor > 0.);
1159 if (bestLaneOffset == 0 && leader.first != 0 && leader.first->isStopped()) {
1164 + leader.first->getVehicleType().getLengthWithGap());
1165 }
else if (bestLaneOffset == laneOffset && neighLead.first != 0 && neighLead.first->isStopped()) {
1168 + neighLead.first->getVehicleType().getLengthWithGap();
1183 SUMOReal roundaboutDistanceAhead = 0;
1184 SUMOReal roundaboutDistanceAheadNeigh = 0;
1185 int roundaboutEdgesAhead = 0;
1186 int roundaboutEdgesAheadNeigh = 0;
1188 getRoundaboutAheadInfo(
this, curr, neigh, roundaboutDistanceAhead, roundaboutDistanceAheadNeigh, roundaboutEdgesAhead, roundaboutEdgesAheadNeigh);
1192 neighDist +=
roundaboutDistBonus(roundaboutDistanceAheadNeigh, roundaboutEdgesAheadNeigh);
1194 #ifdef DEBUG_WANTS_CHANGE 1196 if (roundaboutEdgesAhead > 0) {
1197 std::cout <<
" roundaboutEdgesAhead=" << roundaboutEdgesAhead <<
" roundaboutEdgesAheadNeigh=" << roundaboutEdgesAheadNeigh <<
"\n";
1205 const SUMOReal maxJam =
MAX2(preb[currIdx + prebOffset].occupation, preb[currIdx].occupation);
1208 #ifdef DEBUG_WANTS_CHANGE 1213 <<
" laDist=" << laDist
1214 <<
" currentDist=" << currentDist
1215 <<
" usableDist=" << usableDist
1216 <<
" bestLaneOffset=" << bestLaneOffset
1218 <<
" best.length=" << best.
length 1219 <<
" maxJam=" << maxJam
1220 <<
" neighLeftPlace=" << neighLeftPlace
1242 #ifdef DEBUG_WANTS_CHANGE 1245 <<
" avoid overtaking on the right nv=" << nv->
getID()
1248 <<
" plannedSpeed=" <<
myVSafes.back()
1262 #ifdef DEBUG_WANTS_CHANGE 1264 std::cout <<
" veh=" <<
myVehicle.
getID() <<
" could not change back and forth in time (1) neighLeftPlace=" << neighLeftPlace <<
"\n";
1268 }
else if (bestLaneOffset == 0 && (neighLeftPlace * 2. < laDist)) {
1273 #ifdef DEBUG_WANTS_CHANGE 1275 std::cout <<
" veh=" <<
myVehicle.
getID() <<
" could not change back and forth in time (2) neighLeftPlace=" << neighLeftPlace <<
"\n";
1279 }
else if (bestLaneOffset == 0
1280 && (leader.first == 0 || !leader.first->isStopped())
1282 && roundaboutEdgesAhead == 0
1287 #ifdef DEBUG_WANTS_CHANGE 1289 std::cout <<
" veh=" <<
myVehicle.
getID() <<
" does not want to leave the bestLane (neighDist=" << neighDist <<
")\n";
1296 #ifdef DEBUG_WANTS_CHANGE 1302 if ((ret & lcaCounter) != 0) {
1306 #ifdef DEBUG_WANTS_CHANGE 1308 std::cout <<
" retAfterInfluence=" << ret <<
"\n";
1319 if (changeToBest &&
abs(bestLaneOffset) > 1) {
1321 #ifdef DEBUG_WANTS_CHANGE 1323 std::cout <<
" reserving space for unseen blockers\n";
1332 if (*firstBlocked != neighLead.first) {
1340 const SUMOReal plannedSpeed =
informLeader(msgPass, blocked, myLca, neighLead, remainingSeconds);
1345 informFollower(msgPass, blocked, myLca, neighFollow, remainingSeconds, plannedSpeed);
1348 #ifdef DEBUG_WANTS_CHANGE 1353 <<
" remainingSeconds=" << remainingSeconds
1354 <<
" plannedSpeed=" << plannedSpeed
1369 if (roundaboutEdgesAhead > 1) {
1371 #ifdef DEBUG_WANTS_CHANGE 1375 <<
" roundaboutEdgesAhead=" << roundaboutEdgesAhead
1405 #ifdef DEBUG_WANTS_CHANGE 1407 std::cout <<
" veh=" <<
myVehicle.
getID() <<
" does not want to get stranded on the on-ramp of a highway\n";
1427 && (!speedGainInconvenient)
1432 #ifdef DEBUG_WANTS_CHANGE 1436 <<
" wantsChangeToHelp=" << (right ?
"right" :
"left")
1486 if (neighLead.first == 0) {
1491 &
myVehicle, correctedSpeed, neighLead.second, neighLead.first->
getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel()));
1493 if (leader.first == 0) {
1498 &
myVehicle, correctedSpeed, leader.second, leader.first->
getSpeed(), leader.first->getCarFollowModel().getMaxDecel()));
1502 thisLaneVSafe =
MIN2(thisLaneVSafe, vMax);
1503 neighLaneVSafe =
MIN2(neighLaneVSafe, vMax);
1504 const SUMOReal relativeGain = (neighLaneVSafe - thisLaneVSafe) /
MAX2(neighLaneVSafe,
1511 #ifdef DEBUG_WANTS_CHANGE 1515 <<
" currentDist=" << currentDist
1516 <<
" neighDist=" << neighDist
1526 if (thisLaneVSafe - 5 / 3.6 > neighLaneVSafe) {
1543 if (mySpeedGainProbability < 0 || relativeGain > 0) {
1552 SUMOReal fullSpeedDrivingSeconds =
MIN2(acceptanceTime, fullSpeedGap / vMax);
1553 if (neighLead.first != 0 && neighLead.first->getSpeed() < vMax) {
1556 vMax, neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel())));
1557 fullSpeedDrivingSeconds =
MIN2(fullSpeedDrivingSeconds, fullSpeedGap / (vMax - neighLead.first->getSpeed()));
1564 #ifdef DEBUG_WANTS_CHANGE 1569 <<
" neighDist=" << neighDist
1571 <<
" leaderSpeed=" << (neighLead.first == 0 ? -1 : neighLead.first->getSpeed())
1573 myVehicle.
getSpeed(), neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel()))
1574 <<
" acceptanceTime=" << acceptanceTime
1575 <<
" fullSpeedGap=" << fullSpeedGap
1576 <<
" fullSpeedDrivingSeconds=" << fullSpeedDrivingSeconds
1577 <<
" dProb=" << deltaProb
1590 #ifdef DEBUG_WANTS_CHANGE 1596 <<
" thisLaneVSafe=" << thisLaneVSafe
1597 <<
" neighLaneVSafe=" << neighLaneVSafe
1598 <<
" relativeGain=" << relativeGain
1599 <<
" blocked=" << blocked
1613 if (thisLaneVSafe > neighLaneVSafe) {
1632 #ifdef DEBUG_WANTS_CHANGE 1638 <<
" thisLaneVSafe=" << thisLaneVSafe
1639 <<
" neighLaneVSafe=" << neighLaneVSafe
1640 <<
" relativeGain=" << relativeGain
1641 <<
" blocked=" << blocked
1655 && (right ? mySpeedGainProbability < 0 : mySpeedGainProbability > 0)) {
1662 #ifdef DEBUG_WANTS_CHANGE 1668 <<
" thisLaneVSafe=" << thisLaneVSafe
1669 <<
" neighLaneVSafe=" << neighLaneVSafe
1680 SUMOReal& roundaboutDistanceAhead,
SUMOReal& roundaboutDistanceAheadNeigh,
int& roundaboutEdgesAhead,
int& roundaboutEdgesAheadNeigh) {
1692 roundaboutDistanceAheadNeigh = 0;
1694 #ifdef HAVE_INTERNAL_LANES 1704 if (*i != 0 && *i != veh.
getLane()) {
1709 assert(nextLane != 0);
1719 #ifdef DEBUG_WANTS_CHANGE 1721 std::cout <<
"roundaboutDistanceAhead = " << roundaboutDistanceAhead
1722 <<
" roundaboutDistanceAheadNeigh = " << roundaboutDistanceAheadNeigh
1729 roundaboutEdgesAhead = 0;
1731 const MSLane* lane = *it;
1733 roundaboutEdgesAhead += 1;
1734 }
else if (roundaboutEdgesAhead > 0) {
1739 roundaboutEdgesAheadNeigh = 0;
1741 if ((*it) != 0 && (*it)->getEdge().isRoundabout()) {
1742 roundaboutEdgesAheadNeigh += 1;
1743 }
else if (roundaboutEdgesAheadNeigh > 0) {
1760 if (roundaboutEdgesAhead > 1) {
1783 for (std::vector<MSLane*>::const_iterator i = continuationLanes.begin(); i != continuationLanes.end(); i++) {
1788 bool encounteredRoundabout =
false;
1789 SUMOReal roundaboutDistanceAhead = 0.;
1792 std::vector<MSLane*>::const_iterator j = continuationLanes.begin();
1793 while (j != continuationLanes.end() && *j == 0) {
1798 if (j == continuationLanes.end()) {
1800 assert(initialLane == 0);
1802 }
else if (initialLane == 0) {
1807 }
else if (!initialLane->
isInternal() && initialLane != *j) {
1814 assert(position >= 0. && position <= initialLane->getLength());
1816 assert(initialLane == *j);
1817 roundaboutDistanceAhead += initialLane->
getLength() - position;
1818 if (j + 1 == continuationLanes.end() || *(j + 1) == 0 || !(*(j + 1))->getEdge().isRoundabout()) {
1822 const MSLane* nextLane = *(j + 1);
1830 roundaboutDistanceAhead += initialLane->
getLength() - position;
1832 roundaboutDistanceAhead += initialLane->
getLinkCont()[0]->getInternalLengthsAfter();
1837 for (std::vector<MSLane*>::const_iterator it = j; it != continuationLanes.end(); ++it) {
1838 const MSLane* lane = *it;
1841 encounteredRoundabout =
true;
1843 roundaboutDistanceAhead += lane->
getLength();
1848 if (it + 1 != continuationLanes.end() && *(it + 1) != 0 && (*(it + 1))->getEdge().isRoundabout()) {
1853 roundaboutDistanceAhead += linkLength;
1855 }
else if (encounteredRoundabout) {
1860 return roundaboutDistanceAhead;
1868 if ((*blocked) != 0) {
1870 #ifdef DEBUG_SLOW_DOWN 1894 (*blocked)->getCarFollowModel().getMaxDecel()));
1897 #ifdef DEBUG_SLOW_DOWN 1901 <<
" slowing down for" 1903 <<
" helpSpeed=" <<
myVSafes.back()
1923 #ifdef DEBUG_SAVE_BLOCKER_LENGTH 1939 #ifdef DEBUG_SAVE_BLOCKER_LENGTH 1951 #ifdef DEBUG_SAVE_BLOCKER_LENGTH 1957 <<
" potential=" << potential
bool debugVehicle() const
whether the current vehicles shall be debugged
void saveBlockerLength(MSVehicle *blocker, int lcaCounter)
save space for vehicles which need to counter-lane-change
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)
The action is due to the default of keeping right "Rechtsfahrgebot".
The action is done to help someone else.
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.
static SUMOReal distanceAlongNextRoundabout(SUMOReal position, const MSLane *initialLane, const std::vector< MSLane * > &continuationLanes)
compute the distance on the next upcoming roundabout along a given sequence of lanes.
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
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...
const SUMOReal myChangeProbThresholdRight
SUMOReal getLength() const
Returns the lane's length.
#define KEEP_RIGHT_ACCEPTANCE
The car-following model abstraction.
SUMOReal myKeepRightProbability
void * informNeighFollower(void *info, MSVehicle *sender)
Informs the follower on the desired lane.
#define MAX_ONRAMP_LENGTH
SUMOReal getLength() const
Get vehicle's length [m].
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
const SUMOReal myKeepRightParam
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const SUMOReal myChangeProbThresholdLeft
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)
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) ...
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
static void getRoundaboutAheadInfo(const MSLCM_LC2013 *lcm, const MSVehicle::LaneQ &curr, const MSVehicle::LaneQ &neigh, SUMOReal &roundaboutDistanceAhead, SUMOReal &roundaboutDistanceAheadNeigh, int &roundaboutEdgesAhead, int &roundaboutEdgesAheadNeigh)
computes the distance and number of edges in the next upcoming roundabout along the lane continuation...
std::vector< SUMOReal > myVSafes
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
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.
const SUMOReal myCooperativeParam
#define UNUSED_PARAMETER(x)
#define ROUNDABOUT_DIST_FACTOR
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()
SUMOReal getInternalLengthsAfter() const
Returns the cumulative length of all internal lanes after this link.
SUMOReal getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Needs to stay on the current lane.
const SUMOReal myStrategicParam
#define ROUNDABOUT_DIST_BONUS
static bool myAllowOvertakingRight
whether overtaking on the right is permitted
A class responsible for exchanging messages between cars involved in lane-change interaction.
const std::string & getID() const
Returns the id.
bool currentDistDisallows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
MSLane * lane
The described lane.
A lane change model developed by D. Krajzewicz, J. Erdmann et al. between 2004 and 2013...
bool currentDistAllows(SUMOReal dist, int laneOffset, SUMOReal lookForwardDist)
bool cancelRequest(int state)
whether the influencer cancels the given request
SUMOReal brakeGap(const SUMOReal speed) const
Returns the distance the vehicle needs to halt including driver's reaction time, assuming that during...
blocked in all directions
SUMOReal getMaxSpeedOnLane() const
Returns the maximal speed for the vehicle on its current lane (including speed factor and deviation...
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
The action is urgent (to be defined by lc-model)
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
bool isStopped() const
Returns whether the vehicle is at a stop.
static SUMOReal overtakeDistance(const MSVehicle *follower, const MSVehicle *leader, const SUMOReal gap, SUMOReal followerSpeed=INVALID_SPEED, SUMOReal leaderSpeed=INVALID_SPEED)
int slowDownForBlocked(MSVehicle **blocked, int state)
compute useful slowdowns for blocked vehicles
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)
bool isRoundabout() const
#define RELGAIN_NORMALIZATION_MIN_SPEED
The action is needed to follow the route (navigational lc)
SUMOReal getSpeedLimit() const
Returns the lane's maximum allowed speed.
A structure representing the best lanes for continuing the current route starting at 'lane'...
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
SUMOReal getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
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.
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
Influencer & getInfluencer()
Returns the velocity/lane influencer.
static MSLink * getConnectingLink(const MSLane &from, const MSLane &to)
Returns the link connecting both lanes Both lanes have to be non-internal; 0 may be returned if no co...
SUMOReal occupation
The overall vehicle sum on consecutive lanes which can be passed without a lane change.
The vehicle is blocked being overlapping.
std::vector< MSLane * > bestContinuations
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.
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 ...
The action is due to a TraCI request.
SUMOReal getOppositePos(SUMOReal pos) const
return the corresponding position on the opposite lane
static bool gSemiImplicitEulerUpdate
bool amBlockingFollowerPlusNB()
#define ROUNDABOUT_DIST_TRESH
static SUMOReal gapExtrapolation(const SUMOReal duration, const SUMOReal currentGap, SUMOReal v1, SUMOReal v2, SUMOReal a1=0, SUMOReal a2=0, const SUMOReal maxV1=std::numeric_limits< SUMOReal >::max(), const SUMOReal maxV2=std::numeric_limits< SUMOReal >::max())
return the resulting gap if, starting with gap currentGap, two vehicles continue with constant accele...
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
SUMOReal roundaboutDistBonus(SUMOReal roundaboutDistAhead, int roundaboutEdgesAhead) const
Computes the artificial bonus distance for roundabout lanes this additional distance reduces the sens...
The edge is an internal edge.
SUMOReal getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
void * inform(void *info, MSVehicle *sender)
Representation of a lane in the micro simulation.
const MSCFModel & myCarFollowModel
The vehicle's car following model.
const SUMOReal mySpeedGainParam
Interface for lane-change models.
int getBestLaneOffset() const
bool hasLaneChanger() const
#define HELP_DECEL_FACTOR
const std::string & getID() const
Returns the name of the vehicle.