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
518 #ifdef DEBUG_INFORMER
521 <<
" cannot overtake leader nv=" << nv->
getID()
525 <<
" overtakeDist=" << overtakeDist
526 <<
" overtakeTime=" << overtakeTime
527 <<
" remainingSeconds=" << remainingSeconds
528 <<
" currentGap=" << neighLead.second
531 <<
" targetSpeed=" << targetSpeed
532 <<
" nextSpeed=" << nextSpeed
540 #ifdef DEBUG_INFORMER
543 <<
" cannot overtake fast leader nv=" << nv->
getID()
547 <<
" overtakeDist=" << overtakeDist
549 <<
" overtakeTime=" << overtakeTime
550 <<
" remainingSeconds=" << remainingSeconds
551 <<
" currentGap=" << neighLead.second
552 <<
" targetSpeed=" << targetSpeed
561 #ifdef DEBUG_INFORMER
564 <<
" wants to overtake leader nv=" << nv->
getID()
566 <<
" overtakeDist=" << overtakeDist
567 <<
" remainingSeconds=" << remainingSeconds
568 <<
" overtakeTime=" << overtakeTime
569 <<
" currentGap=" << neighLead.second
577 }
else if (neighLead.first != 0) {
585 #ifdef DEBUG_INFORMER
587 std::cout <<
" not blocked by leader nv=" << nv->
getID()
589 <<
" gap=" << neighLead.second
590 <<
" nextGap=" << neighLead.second - dv
592 <<
" targetSpeed=" << targetSpeed
596 return MIN2(targetSpeed, plannedSpeed);
607 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
614 #ifdef DEBUG_INFORMER
616 std::cout <<
"\nINFORM_FOLLOWER"
623 #ifdef DEBUG_INFORMER
625 std::cout <<
" blocked by follower nv=" << nv->
getID() <<
" nvSpeed=" << nv->
getSpeed() <<
" needGap="
633 if ((neededGap - neighFollow.second) / remainingSeconds < (
MAX2(plannedSpeed, (
SUMOReal)0.) - nv->
getSpeed())) {
634 #ifdef DEBUG_INFORMER
636 std::cout <<
" wants to cut in before nv=" << nv->
getID() <<
" without any help." <<
"\nneededGap = " << neededGap <<
"\n";
668 dv = plannedSpeed - neighNewSpeed1s;
675 decelGap = neighFollow.second + dv;
682 neighNewSpeed1s = nv->
getSpeed() - helpDecel;
692 #ifdef DEBUG_INFORMER
696 <<
" plannedSpeed=" << plannedSpeed
697 <<
" neighNewSpeed=" << neighNewSpeed
698 <<
" neighNewSpeed1s=" << neighNewSpeed1s
700 <<
" gap=" << neighFollow.second
701 <<
" decelGap=" << decelGap
702 <<
" secureGap=" << secureGap
707 if (decelGap > 0 && decelGap >= secureGap) {
724 assert(vsafe <= vsafe1);
735 #ifdef DEBUG_INFORMER
737 std::cout <<
"nextGap=" << nextGap <<
" (without help decel) \n";
753 nv->
getSpeed(), plannedAccel, -decel2,
767 assert(vsafe >= vsafe1);
769 #ifdef DEBUG_INFORMER
771 std::cout <<
"nextGap=" << nextGap
772 <<
" (with vsafe1 and help decel) \nvsafe1=" << vsafe1
773 <<
" vsafe=" << vsafe
782 if (nextGap < nextSecureGap) {
784 vsafe = neighNewSpeed;
787 #ifdef DEBUG_INFORMER
789 std::cout <<
"nextGap=" << nextGap
790 <<
" minNextSecureGap=" << nextSecureGap
791 <<
" vsafe=" << vsafe <<
"\n";
799 #ifdef DEBUG_INFORMER
801 std::cout <<
" wants to cut in before nv=" << nv->
getID()
802 <<
" vsafe1=" << vsafe1 <<
" vsafe=" << vsafe
828 #ifdef DEBUG_INFORMER
830 std::cout <<
" wants to cut in before nv=" << nv->
getID() <<
" (eventually)\n";
837 #ifdef DEBUG_INFORMER
839 std::cout <<
" wants to cut in before nv=" << nv->
getID() <<
" (nv cannot overtake right)\n";
858 #ifdef DEBUG_INFORMER
862 std::cout <<
" wants right follower to slow down a bit\n";
869 #ifdef DEBUG_INFORMER
872 std::cout <<
" wants to cut in before right follower nv=" << nv->
getID() <<
" (eventually)\n";
894 if (gapAfterRemainingSecs >= secureGapAfterRemainingSecs) {
895 #ifdef DEBUG_INFORMER
897 std::cout <<
" wants to cut in before follower nv=" << nv->
getID() <<
" (eventually)\n";
910 #ifdef DEBUG_INFORMER
914 <<
" informs follower " << nv->
getID()
915 <<
" vhelp=" << vhelp
924 const SUMOReal needDV = overtakeDist / remainingSeconds;
928 #ifdef DEBUG_INFORMER
932 <<
" wants to be overtaken by=" << nv->
getID()
933 <<
" overtakeDist=" << overtakeDist
935 <<
" vhelp=" << vhelp
936 <<
" needDV=" << needDV
942 }
else if (neighFollow.first != 0) {
973 if (anticipatedGap > secureGap) {
980 if (anticipatedGap < secureGap) {
991 #ifdef DEBUG_INFORMER
993 std::cout <<
" wants to cut in before non-blocking follower nv=" << nv->
getID() <<
"\n";
1036 const std::pair<MSVehicle*, SUMOReal>& leader,
1037 const std::pair<MSVehicle*, SUMOReal>& neighLead,
1038 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
1040 const std::vector<MSVehicle::LaneQ>& preb,
1043 assert(laneOffset == 1 || laneOffset == -1);
1047 int bestLaneOffset = 0;
1062 const int prebOffset = (checkOpposite ? 0 : laneOffset);
1063 for (
int p = 0; p < (int) preb.size(); ++p) {
1064 if (preb[p].lane == prebLane && p + laneOffset >= 0) {
1065 assert(p + prebOffset < (
int)preb.size());
1067 neigh = preb[p + prebOffset];
1068 currentDist = curr.
length;
1069 neighDist = neigh.
length;
1070 bestLaneOffset = curr.bestLaneOffset;
1071 if (bestLaneOffset == 0 && preb[p + prebOffset].bestLaneOffset == 0) {
1072 #ifdef DEBUG_WANTS_CHANGE
1076 <<
" bestLaneOffsetOld=" << bestLaneOffset
1077 <<
" bestLaneOffsetNew=" << laneOffset
1081 bestLaneOffset = prebOffset;
1083 best = preb[p + bestLaneOffset];
1089 const bool right = (laneOffset == -1);
1091 neigh = preb[preb.size() - 1];
1094 bestLaneOffset = -1;
1096 neighDist = neigh.
length;
1097 currentDist = curr.
length;
1103 const bool changeToBest = (right && bestLaneOffset < 0) || (!right && bestLaneOffset > 0);
1109 if (lastBlocked != firstBlocked) {
1113 #ifdef DEBUG_WANTS_CHANGE
1122 <<
" leaderGap=" << leader.second
1124 <<
" neighLeadGap=" << neighLead.second
1126 <<
" neighFollowGap=" << neighFollow.second
1149 assert(memoryFactor > 0.);
1157 if (bestLaneOffset == 0 && leader.first != 0 && leader.first->isStopped()) {
1162 + leader.first->getVehicleType().getLengthWithGap());
1163 }
else if (bestLaneOffset == laneOffset && neighLead.first != 0 && neighLead.first->isStopped()) {
1166 + neighLead.first->getVehicleType().getLengthWithGap();
1182 SUMOReal roundaboutDistanceAheadNeigh;
1183 int roundaboutEdgesAhead;
1184 int roundaboutEdgesAheadNeigh;
1185 getRoundaboutAheadInfo(
this, curr, neigh, roundaboutDistanceAhead, roundaboutDistanceAheadNeigh, roundaboutEdgesAhead, roundaboutEdgesAheadNeigh);
1188 neighDist +=
roundaboutDistBonus(roundaboutDistanceAheadNeigh, roundaboutEdgesAheadNeigh);
1190 #ifdef DEBUG_WANTS_CHANGE
1192 if (roundaboutEdgesAhead > 0) {
1193 std::cout <<
" roundaboutEdgesAhead=" << roundaboutEdgesAhead <<
" roundaboutEdgesAheadNeigh=" << roundaboutEdgesAheadNeigh <<
"\n";
1201 const SUMOReal maxJam =
MAX2(preb[currIdx + prebOffset].occupation, preb[currIdx].occupation);
1204 #ifdef DEBUG_WANTS_CHANGE
1209 <<
" laDist=" << laDist
1210 <<
" currentDist=" << currentDist
1211 <<
" usableDist=" << usableDist
1212 <<
" bestLaneOffset=" << bestLaneOffset
1214 <<
" best.length=" << best.
length
1215 <<
" maxJam=" << maxJam
1216 <<
" neighLeftPlace=" << neighLeftPlace
1238 #ifdef DEBUG_WANTS_CHANGE
1241 <<
" avoid overtaking on the right nv=" << nv->
getID()
1244 <<
" plannedSpeed=" <<
myVSafes.back()
1258 #ifdef DEBUG_WANTS_CHANGE
1260 std::cout <<
" veh=" <<
myVehicle.
getID() <<
" could not change back and forth in time (1) neighLeftPlace=" << neighLeftPlace <<
"\n";
1264 }
else if (bestLaneOffset == 0 && (neighLeftPlace * 2. < laDist)) {
1269 #ifdef DEBUG_WANTS_CHANGE
1271 std::cout <<
" veh=" <<
myVehicle.
getID() <<
" could not change back and forth in time (2) neighLeftPlace=" << neighLeftPlace <<
"\n";
1275 }
else if (bestLaneOffset == 0
1276 && (leader.first == 0 || !leader.first->isStopped())
1278 && roundaboutEdgesAhead == 0
1283 #ifdef DEBUG_WANTS_CHANGE
1285 std::cout <<
" veh=" <<
myVehicle.
getID() <<
" does not want to leave the bestLane (neighDist=" << neighDist <<
")\n";
1292 #ifdef DEBUG_WANTS_CHANGE
1298 if ((ret & lcaCounter) != 0) {
1302 #ifdef DEBUG_WANTS_CHANGE
1304 std::cout <<
" retAfterInfluence=" << ret <<
"\n";
1315 if (changeToBest &&
abs(bestLaneOffset) > 1) {
1317 #ifdef DEBUG_WANTS_CHANGE
1319 std::cout <<
" reserving space for unseen blockers\n";
1328 if (*firstBlocked != neighLead.first) {
1336 const SUMOReal plannedSpeed =
informLeader(msgPass, blocked, myLca, neighLead, remainingSeconds);
1341 informFollower(msgPass, blocked, myLca, neighFollow, remainingSeconds, plannedSpeed);
1344 #ifdef DEBUG_WANTS_CHANGE
1349 <<
" remainingSeconds=" << remainingSeconds
1350 <<
" plannedSpeed=" << plannedSpeed
1365 if (roundaboutEdgesAhead > 1) {
1367 #ifdef DEBUG_WANTS_CHANGE
1371 <<
" roundaboutEdgesAhead=" << roundaboutEdgesAhead
1401 #ifdef DEBUG_WANTS_CHANGE
1403 std::cout <<
" veh=" <<
myVehicle.
getID() <<
" does not want to get stranded on the on-ramp of a highway\n";
1423 && (!speedGainInconvenient)
1428 #ifdef DEBUG_WANTS_CHANGE
1432 <<
" wantsChangeToHelp=" << (right ?
"right" :
"left")
1482 if (neighLead.first == 0) {
1487 &
myVehicle, correctedSpeed, neighLead.second, neighLead.first->
getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel()));
1489 if (leader.first == 0) {
1494 &
myVehicle, correctedSpeed, leader.second, leader.first->
getSpeed(), leader.first->getCarFollowModel().getMaxDecel()));
1498 thisLaneVSafe =
MIN2(thisLaneVSafe, vMax);
1499 neighLaneVSafe =
MIN2(neighLaneVSafe, vMax);
1500 const SUMOReal relativeGain = (neighLaneVSafe - thisLaneVSafe) /
MAX2(neighLaneVSafe,
1507 #ifdef DEBUG_WANTS_CHANGE
1511 <<
" currentDist=" << currentDist
1512 <<
" neighDist=" << neighDist
1522 if (thisLaneVSafe - 5 / 3.6 > neighLaneVSafe) {
1539 if (mySpeedGainProbability < 0 || relativeGain > 0) {
1548 SUMOReal fullSpeedDrivingSeconds =
MIN2(acceptanceTime, fullSpeedGap / vMax);
1549 if (neighLead.first != 0 && neighLead.first->getSpeed() < vMax) {
1552 vMax, neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel())));
1553 fullSpeedDrivingSeconds =
MIN2(fullSpeedDrivingSeconds, fullSpeedGap / (vMax - neighLead.first->getSpeed()));
1560 #ifdef DEBUG_WANTS_CHANGE
1565 <<
" neighDist=" << neighDist
1567 <<
" leaderSpeed=" << (neighLead.first == 0 ? -1 : neighLead.first->getSpeed())
1569 myVehicle.
getSpeed(), neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel()))
1570 <<
" acceptanceTime=" << acceptanceTime
1571 <<
" fullSpeedGap=" << fullSpeedGap
1572 <<
" fullSpeedDrivingSeconds=" << fullSpeedDrivingSeconds
1573 <<
" dProb=" << deltaProb
1586 #ifdef DEBUG_WANTS_CHANGE
1592 <<
" thisLaneVSafe=" << thisLaneVSafe
1593 <<
" neighLaneVSafe=" << neighLaneVSafe
1594 <<
" relativeGain=" << relativeGain
1595 <<
" blocked=" << blocked
1609 if (thisLaneVSafe > neighLaneVSafe) {
1628 #ifdef DEBUG_WANTS_CHANGE
1634 <<
" thisLaneVSafe=" << thisLaneVSafe
1635 <<
" neighLaneVSafe=" << neighLaneVSafe
1636 <<
" relativeGain=" << relativeGain
1637 <<
" blocked=" << blocked
1651 && (right ? mySpeedGainProbability < 0 : mySpeedGainProbability > 0)) {
1658 #ifdef DEBUG_WANTS_CHANGE
1664 <<
" thisLaneVSafe=" << thisLaneVSafe
1665 <<
" neighLaneVSafe=" << neighLaneVSafe
1676 SUMOReal& roundaboutDistanceAhead,
SUMOReal& roundaboutDistanceAheadNeigh,
int& roundaboutEdgesAhead,
int& roundaboutEdgesAheadNeigh) {
1688 roundaboutDistanceAheadNeigh = 0;
1690 #ifdef HAVE_INTERNAL_LANES
1700 if (*i != 0 && *i != veh.
getLane()) {
1705 assert(nextLane != 0);
1715 #ifdef DEBUG_WANTS_CHANGE
1717 std::cout <<
"roundaboutDistanceAhead = " << roundaboutDistanceAhead
1718 <<
" roundaboutDistanceAheadNeigh = " << roundaboutDistanceAheadNeigh
1725 roundaboutEdgesAhead = 0;
1727 const MSLane* lane = *it;
1729 roundaboutEdgesAhead += 1;
1730 }
else if (roundaboutEdgesAhead > 0) {
1735 roundaboutEdgesAheadNeigh = 0;
1737 if ((*it) != 0 && (*it)->getEdge().isRoundabout()) {
1738 roundaboutEdgesAheadNeigh += 1;
1739 }
else if (roundaboutEdgesAheadNeigh > 0) {
1756 if (roundaboutEdgesAhead > 1) {
1779 for (std::vector<MSLane*>::const_iterator i = continuationLanes.begin(); i != continuationLanes.end(); i++) {
1784 bool encounteredRoundabout =
false;
1785 SUMOReal roundaboutDistanceAhead = 0.;
1788 std::vector<MSLane*>::const_iterator j = continuationLanes.begin();
1789 while (j != continuationLanes.end() && *j == 0) {
1794 if (j == continuationLanes.end()) {
1796 assert(initialLane == 0);
1798 }
else if (initialLane == 0) {
1803 }
else if (!initialLane->
isInternal() && initialLane != *j) {
1810 assert(position >= 0. && position <= initialLane->getLength());
1812 assert(initialLane == *j);
1813 roundaboutDistanceAhead += initialLane->
getLength() - position;
1814 if (j + 1 == continuationLanes.end() || *(j + 1) == 0 || !(*(j + 1))->getEdge().isRoundabout()) {
1818 const MSLane* nextLane = *(j + 1);
1826 roundaboutDistanceAhead += initialLane->
getLength() - position;
1828 roundaboutDistanceAhead += initialLane->
getLinkCont()[0]->getInternalLengthsAfter();
1833 for (std::vector<MSLane*>::const_iterator it = j; it != continuationLanes.end(); ++it) {
1834 const MSLane* lane = *it;
1837 encounteredRoundabout =
true;
1839 roundaboutDistanceAhead += lane->
getLength();
1844 if (it + 1 != continuationLanes.end() && *(it + 1) != 0 && (*(it + 1))->getEdge().isRoundabout()) {
1849 roundaboutDistanceAhead += linkLength;
1851 }
else if (encounteredRoundabout) {
1856 return roundaboutDistanceAhead;
1864 if ((*blocked) != 0) {
1866 #ifdef DEBUG_SLOW_DOWN
1890 (*blocked)->getCarFollowModel().getMaxDecel()));
1893 #ifdef DEBUG_SLOW_DOWN
1897 <<
" slowing down for"
1899 <<
" helpSpeed=" <<
myVSafes.back()
1919 #ifdef DEBUG_SAVE_BLOCKER_LENGTH
1935 #ifdef DEBUG_SAVE_BLOCKER_LENGTH
1947 #ifdef DEBUG_SAVE_BLOCKER_LENGTH
1953 <<
" 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
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)
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)
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...
SUMOReal getMaxSpeedOnLane() const
Returns the maximal speed for the vehicle on its current lane (including speed factor and deviation...
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
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 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.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
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.
std::vector< MSLane * > bestContinuations
Consecutive lane that can be followed without a lane change (contribute to length and occupation) ...
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
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
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.
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
returns the current offset from the best lane
bool hasLaneChanger() const
#define HELP_DECEL_FACTOR
const std::string & getID() const
Returns the name of the vehicle.