52 #define LOOK_FORWARD_SPEED_DIVIDER (double)14. 54 #define LOOK_FORWARD_RIGHT (double)10. 55 #define LOOK_FORWARD_LEFT (double)20. 57 #define JAM_FACTOR (double)1. 59 #define LCA_RIGHT_IMPATIENCE (double)-1. 60 #define CUT_IN_LEFT_SPEED_THRESHOLD (double)27. 62 #define LOOK_AHEAD_MIN_SPEED 0.0 63 #define LOOK_AHEAD_SPEED_MEMORY 0.9 65 #define HELP_DECEL_FACTOR (double)1.0 67 #define HELP_OVERTAKE (double)(10.0 / 3.6) 68 #define MIN_FALLBEHIND (double)(7.0 / 3.6) 71 #define OVERTAKE_RIGHT_THRESHOLD (double)(5/3.6) 73 #define RELGAIN_NORMALIZATION_MIN_SPEED (double)10.0 74 #define URGENCY (double)2.0 76 #define KEEP_RIGHT_TIME (double)5.0 // the number of seconds after which a vehicle should move to the right lane 77 #define KEEP_RIGHT_ACCEPTANCE (double)7.0 // calibration factor for determining the desire to keep right 78 #define ROUNDABOUT_DIST_BONUS (double)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 (double)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 (double)10.0 // roundabout distances below ROUNDABOUT_DIST_TRESH are not multiplied by ROUNDABOUT_DIST_FACTOR 83 #define KEEP_RIGHT_HEADWAY (double)2.0 84 #define MAX_ONRAMP_LENGTH (double)200. 85 #define TURN_LANE_DIST (double)200.0 // the distance at which a lane leading elsewhere is considered to be a turn-lane that must be avoided 99 #define DEBUG_COND (myVehicle.isSelected()) 106 mySpeedGainProbability(0),
107 myKeepRightProbability(0),
108 myLeadingBlockerLength(0),
116 myChangeProbThresholdRight(2.0 * myKeepRightParam /
MAX2(
NUMERICAL_EPS, mySpeedGainParam)),
118 #ifdef DEBUG_CONSTRUCTOR 147 const std::pair<MSVehicle*, double>& leader,
148 const std::pair<MSVehicle*, double>& neighLead,
149 const std::pair<MSVehicle*, double>& neighFollow,
151 const std::vector<MSVehicle::LaneQ>& preb,
155 #ifdef DEBUG_WANTS_CHANGE 157 std::cout <<
"\nWANTS_CHANGE\n" <<
SIMTIME 164 <<
" considerChangeTo=" << (laneOffset == -1 ?
"right" :
"left")
169 const int result =
_wantsChange(laneOffset, msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked);
171 #ifdef DEBUG_WANTS_CHANGE 184 #ifdef DEBUG_PATCH_SPEED 186 std::cout <<
"\nPATCH_SPEED\n" 192 <<
" wanted=" << wanted <<
"\n";
196 const double newSpeed =
_patchSpeed(min, wanted, max, cfModel);
198 #ifdef DEBUG_PATCH_SPEED 200 const std::string patched = (wanted != newSpeed ?
" patched=" +
toString(newSpeed) :
"");
213 #ifdef DEBUG_PATCH_SPEED 219 <<
" wanted=" << wanted << std::endl;
224 double MAGIC_offset = 1.;
228 #ifdef DEBUG_PATCH_SPEED 239 #ifdef DEBUG_PATCH_SPEED 241 std::cout <<
SIMTIME <<
" veh=" <<
myVehicle.
getID() <<
" slowing down for leading blocker, safe=" << safe << (safe +
NUMERICAL_EPS < min ?
" (not enough)" :
"") <<
"\n";
244 return MAX2(min, safe);
249 double nVSafe = wanted;
251 for (std::vector<double>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
263 #ifdef DEBUG_PATCH_SPEED 270 #ifdef DEBUG_PATCH_SPEED 272 std::cout <<
SIMTIME <<
" veh=" <<
myVehicle.
getID() <<
" ignoring low nVSafe=" << v <<
" min=" << min <<
"\n";
276 #ifdef DEBUG_PATCH_SPEED 278 std::cout <<
SIMTIME <<
" veh=" <<
myVehicle.
getID() <<
" ignoring high nVSafe=" << v <<
" max=" << max <<
"\n";
286 #ifdef DEBUG_PATCH_SPEED 299 #ifdef DEBUG_PATCH_SPEED 304 return (max + wanted) / (double) 2.0;
308 #ifdef DEBUG_PATCH_SPEED 314 return (
MAX2(0., min) + wanted) / (double) 2.0;
320 #ifdef DEBUG_PATCH_SPEED 325 return (max + wanted) / (double) 2.0;
366 #ifdef DEBUG_PATCH_SPEED 371 return (max + wanted) / (double) 2.0;
375 #ifdef DEBUG_PATCH_SPEED 403 #ifdef DEBUG_INFORMED 407 <<
" informedBy=" << sender->
getID()
408 <<
" info=" << pinfo->second
409 <<
" vSafe=" << pinfo->first
421 double overtakeDist = (gap
426 return MAX2(overtakeDist, 0.);
434 const std::pair<MSVehicle*, double>& neighLead,
435 double remainingSeconds) {
438 for (std::vector<double>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
441 plannedSpeed =
MIN2(plannedSpeed, v);
444 #ifdef DEBUG_INFORMER 446 std::cout <<
"\nINFORM_LEADER" 452 assert(neighLead.first != 0);
454 #ifdef DEBUG_INFORMER 456 std::cout <<
" blocked by leader nv=" << nv->
getID() <<
" nvSpeed=" << nv->
getSpeed() <<
" needGap=" 463 const double dv = plannedSpeed - nv->
getSpeed();
466 overtakeTime = overtakeDist / dv;
469 overtakeTime = remainingSeconds + 1;
472 #ifdef DEBUG_INFORMER 475 <<
"\nnv = " << nv->
getID()
476 <<
"\nplannedSpeed = " << plannedSpeed
477 <<
"\nleaderSpeed = " << nv->
getSpeed()
479 <<
"\nremainingSeconds = " << remainingSeconds
480 <<
"\novertakeDist = " << overtakeDist
481 <<
"\novertakeTime = " << overtakeTime
496 && !(
isOpposite() && neighLead.second < 0 && neighLead.first->isStopped())) {
508 #ifdef DEBUG_INFORMER 511 <<
" cannot overtake leader nv=" << nv->
getID()
515 <<
" overtakeDist=" << overtakeDist
516 <<
" overtakeTime=" << overtakeTime
517 <<
" remainingSeconds=" << remainingSeconds
518 <<
" currentGap=" << neighLead.second
521 <<
" targetSpeed=" << targetSpeed
522 <<
" nextSpeed=" << nextSpeed
530 #ifdef DEBUG_INFORMER 533 <<
" cannot overtake fast leader nv=" << nv->
getID()
537 <<
" overtakeDist=" << overtakeDist
539 <<
" overtakeTime=" << overtakeTime
540 <<
" remainingSeconds=" << remainingSeconds
541 <<
" currentGap=" << neighLead.second
542 <<
" targetSpeed=" << targetSpeed
551 #ifdef DEBUG_INFORMER 554 <<
" wants to overtake leader nv=" << nv->
getID()
556 <<
" overtakeDist=" << overtakeDist
557 <<
" remainingSeconds=" << remainingSeconds
558 <<
" overtakeTime=" << overtakeTime
559 <<
" currentGap=" << neighLead.second
567 }
else if (neighLead.first != 0) {
575 #ifdef DEBUG_INFORMER 577 std::cout <<
" not blocked by leader nv=" << nv->
getID()
579 <<
" gap=" << neighLead.second
580 <<
" nextGap=" << neighLead.second - dv
582 <<
" targetSpeed=" << targetSpeed
586 return MIN2(targetSpeed, plannedSpeed);
597 const std::pair<MSVehicle*, double>& neighFollow,
598 double remainingSeconds,
599 double plannedSpeed) {
604 #ifdef DEBUG_INFORMER 606 std::cout <<
"\nINFORM_FOLLOWER" 613 #ifdef DEBUG_INFORMER 615 std::cout <<
" blocked by follower nv=" << nv->
getID() <<
" nvSpeed=" << nv->
getSpeed() <<
" needGap=" 623 if ((neededGap - neighFollow.second) / remainingSeconds < (
MAX2(plannedSpeed, 0.) - nv->
getSpeed())) {
624 #ifdef DEBUG_INFORMER 626 std::cout <<
" wants to cut in before nv=" << nv->
getID() <<
" without any help." <<
"\nneededGap = " << neededGap <<
"\n";
646 double neighNewSpeed;
648 double neighNewSpeed1s;
658 dv = plannedSpeed - neighNewSpeed1s;
665 decelGap = neighFollow.second + dv;
672 neighNewSpeed1s = nv->
getSpeed() - helpDecel;
684 #ifdef DEBUG_INFORMER 688 <<
" plannedSpeed=" << plannedSpeed
689 <<
" threshold=" << onRampThreshold
690 <<
" neighNewSpeed=" << neighNewSpeed
691 <<
" neighNewSpeed1s=" << neighNewSpeed1s
693 <<
" gap=" << neighFollow.second
694 <<
" decelGap=" << decelGap
695 <<
" secureGap=" << secureGap
702 && neighNewSpeed1s < onRampThreshold) {
706 if (decelGap > 0 && decelGap >= secureGap) {
714 double vsafe, vsafe1;
723 assert(vsafe <= vsafe1);
734 #ifdef DEBUG_INFORMER 736 std::cout <<
"nextGap=" << nextGap <<
" (without help decel) \n";
744 MAX2(0., plannedSpeed),
752 nv->
getSpeed(), plannedAccel, -decel2,
763 MAX2(0., plannedSpeed),
766 assert(vsafe >= vsafe1);
768 #ifdef DEBUG_INFORMER 770 std::cout <<
"nextGap=" << nextGap
771 <<
" (with vsafe1 and help decel) \nvsafe1=" << vsafe1
772 <<
" vsafe=" << vsafe
781 if (nextGap < nextSecureGap) {
783 vsafe = neighNewSpeed;
786 #ifdef DEBUG_INFORMER 788 std::cout <<
"nextGap=" << nextGap
789 <<
" minNextSecureGap=" << nextSecureGap
790 <<
" vsafe=" << vsafe <<
"\n";
798 #ifdef DEBUG_INFORMER 800 std::cout <<
" wants to cut in before nv=" << nv->
getID()
801 <<
" vsafe1=" << vsafe1 <<
" vsafe=" << vsafe
827 #ifdef DEBUG_INFORMER 829 std::cout <<
" wants to cut in before nv=" << nv->
getID() <<
" (eventually)\n";
836 #ifdef DEBUG_INFORMER 838 std::cout <<
" wants to cut in before nv=" << nv->
getID() <<
" (nv cannot overtake right)\n";
857 #ifdef DEBUG_INFORMER 861 std::cout <<
" wants right follower to slow down a bit\n";
868 #ifdef DEBUG_INFORMER 871 std::cout <<
" wants to cut in before right follower nv=" << nv->
getID() <<
" (eventually)\n";
893 if (gapAfterRemainingSecs >= secureGapAfterRemainingSecs) {
894 #ifdef DEBUG_INFORMER 896 std::cout <<
" wants to cut in before follower nv=" << nv->
getID() <<
" (eventually)\n";
909 #ifdef DEBUG_INFORMER 913 <<
" informs follower " << nv->
getID()
914 <<
" vhelp=" << vhelp
923 const double needDV = overtakeDist / remainingSeconds;
927 #ifdef DEBUG_INFORMER 931 <<
" wants to be overtaken by=" << nv->
getID()
932 <<
" overtakeDist=" << overtakeDist
934 <<
" vhelp=" << vhelp
935 <<
" needDV=" << needDV
944 double vsafe, vsafe1;
958 double anticipationTime = 1.;
969 if (anticipatedGap > secureGap) {
976 if (anticipatedGap < secureGap) {
987 #ifdef DEBUG_INFORMER 989 std::cout <<
" wants to cut in before non-blocking follower nv=" << nv->
getID() <<
"\n";
1033 const std::pair<MSVehicle*, double>& leader,
1034 const std::pair<MSVehicle*, double>& neighLead,
1035 const std::pair<MSVehicle*, double>& neighFollow,
1037 const std::vector<MSVehicle::LaneQ>& preb,
1040 assert(laneOffset == 1 || laneOffset == -1);
1044 int bestLaneOffset = 0;
1049 double currentDist = 0;
1050 double neighDist = 0;
1059 const int prebOffset = (checkOpposite ? 0 : laneOffset);
1060 for (
int p = 0; p < (int) preb.size(); ++p) {
1061 if (preb[p].lane == prebLane && p + laneOffset >= 0) {
1062 assert(p + prebOffset < (
int)preb.size());
1064 neigh = preb[p + prebOffset];
1065 currentDist = curr.
length;
1066 neighDist = neigh.
length;
1067 bestLaneOffset = curr.bestLaneOffset;
1068 if (bestLaneOffset == 0 && preb[p + prebOffset].bestLaneOffset == 0) {
1069 #ifdef DEBUG_WANTS_CHANGE 1073 <<
" bestLaneOffsetOld=" << bestLaneOffset
1074 <<
" bestLaneOffsetNew=" << laneOffset
1078 bestLaneOffset = prebOffset;
1080 best = preb[p + bestLaneOffset];
1086 const bool right = (laneOffset == -1);
1088 neigh = preb[preb.size() - 1];
1091 bestLaneOffset = -1;
1093 neighDist = neigh.
length;
1094 currentDist = curr.
length;
1100 const bool changeToBest = (right && bestLaneOffset < 0) || (!right && bestLaneOffset > 0);
1106 if (lastBlocked != firstBlocked) {
1110 #ifdef DEBUG_WANTS_CHANGE 1119 <<
" leaderGap=" << leader.second
1121 <<
" neighLeadGap=" << neighLead.second
1123 <<
" neighFollowGap=" << neighFollow.second
1146 assert(memoryFactor > 0.);
1154 if (bestLaneOffset == 0 && leader.first != 0 && leader.first->isStopped()) {
1159 + leader.first->getVehicleType().getLengthWithGap());
1160 }
else if (bestLaneOffset == laneOffset && neighLead.first != 0 && neighLead.first->isStopped()) {
1163 + neighLead.first->getVehicleType().getLengthWithGap();
1178 double roundaboutDistanceAhead = 0;
1179 double roundaboutDistanceAheadNeigh = 0;
1180 int roundaboutEdgesAhead = 0;
1181 int roundaboutEdgesAheadNeigh = 0;
1183 getRoundaboutAheadInfo(
this, curr, neigh, roundaboutDistanceAhead, roundaboutDistanceAheadNeigh, roundaboutEdgesAhead, roundaboutEdgesAheadNeigh);
1187 neighDist +=
roundaboutDistBonus(roundaboutDistanceAheadNeigh, roundaboutEdgesAheadNeigh);
1189 #ifdef DEBUG_WANTS_CHANGE 1191 if (roundaboutEdgesAhead > 0) {
1192 std::cout <<
" roundaboutEdgesAhead=" << roundaboutEdgesAhead <<
" roundaboutEdgesAheadNeigh=" << roundaboutEdgesAheadNeigh <<
"\n";
1200 const double maxJam =
MAX2(preb[currIdx + prebOffset].occupation, preb[currIdx].occupation);
1201 const double neighLeftPlace =
MAX2((
double) 0, neighDist - posOnLane - maxJam);
1204 double thisLaneVSafe = vMax;
1209 #ifdef DEBUG_WANTS_CHANGE 1214 <<
" laDist=" << laDist
1215 <<
" currentDist=" << currentDist
1216 <<
" usableDist=" << usableDist
1217 <<
" bestLaneOffset=" << bestLaneOffset
1219 <<
" best.length=" << best.
length 1220 <<
" maxJam=" << maxJam
1221 <<
" neighLeftPlace=" << neighLeftPlace
1226 bool changeLeftToAvoidOvertakeRight =
false;
1233 if (neighLead.first != 0 && checkOverTakeRight && !right) {
1240 double vSafe =
MAX2(
1247 thisLaneVSafe =
MIN2(thisLaneVSafe, vSafe);
1250 const double deltaGapFuture = deltaV * 8;
1253 if (vSafeFuture < vSafe) {
1254 const double relativeGain = deltaV /
MAX2(vMax,
1257 changeLeftToAvoidOvertakeRight =
true;
1259 #ifdef DEBUG_WANTS_CHANGE 1262 <<
" avoid overtaking on the right nv=" << nv->
getID()
1263 <<
" deltaV=" << deltaV
1266 <<
" plannedSpeed=" <<
myVSafes.back()
1280 #ifdef DEBUG_WANTS_CHANGE 1282 std::cout <<
" veh=" <<
myVehicle.
getID() <<
" could not change back and forth in time (1) neighLeftPlace=" << neighLeftPlace <<
"\n";
1286 }
else if (bestLaneOffset == 0 && (neighLeftPlace * 2. < laDist)) {
1291 #ifdef DEBUG_WANTS_CHANGE 1293 std::cout <<
" veh=" <<
myVehicle.
getID() <<
" could not change back and forth in time (2) neighLeftPlace=" << neighLeftPlace <<
"\n";
1297 }
else if (bestLaneOffset == 0
1298 && (leader.first == 0 || !leader.first->isStopped())
1300 && roundaboutEdgesAhead == 0
1306 #ifdef DEBUG_WANTS_CHANGE 1308 std::cout <<
" veh=" <<
myVehicle.
getID() <<
" does not want to leave the bestLane (neighDist=" << neighDist <<
")\n";
1315 #ifdef DEBUG_WANTS_CHANGE 1321 if ((ret & lcaCounter) != 0) {
1325 #ifdef DEBUG_WANTS_CHANGE 1327 std::cout <<
" retAfterInfluence=" << ret <<
"\n";
1338 if (changeToBest &&
abs(bestLaneOffset) > 1) {
1341 #ifdef DEBUG_WANTS_CHANGE 1343 std::cout <<
" reserving space for unseen blockers myLeadingBlockerLength=" <<
myLeadingBlockerLength <<
"\n";
1351 if (*firstBlocked != neighLead.first) {
1355 const double remainingSeconds = ((ret &
LCA_TRACI) == 0 ?
1359 const double plannedSpeed =
informLeader(msgPass, blocked, myLca, neighLead, remainingSeconds);
1364 informFollower(msgPass, blocked, myLca, neighFollow, remainingSeconds, plannedSpeed);
1367 #ifdef DEBUG_WANTS_CHANGE 1372 <<
" remainingSeconds=" << remainingSeconds
1373 <<
" plannedSpeed=" << plannedSpeed
1381 const double inconvenience =
MIN2((
double)1.0, (laneOffset < 0
1388 if (roundaboutEdgesAhead > 1) {
1390 #ifdef DEBUG_WANTS_CHANGE 1394 <<
" roundaboutEdgesAhead=" << roundaboutEdgesAhead
1424 #ifdef DEBUG_WANTS_CHANGE 1426 std::cout <<
" veh=" <<
myVehicle.
getID() <<
" does not want to get stranded on the on-ramp of a highway\n";
1446 && (!speedGainInconvenient)
1451 #ifdef DEBUG_WANTS_CHANGE 1455 <<
" wantsChangeToHelp=" << (right ?
"right" :
"left")
1486 const bool acceleratingLeader = (neighLead.first != 0 && neighLead.first->getAcceleration() > 0)
1487 || (leader.first != 0 && leader.first->getAcceleration() > 0);
1489 if (acceleratingLeader) {
1495 if (neighLead.first == 0) {
1499 &
myVehicle, correctedSpeed, neighLead.second, neighLead.first->
getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel()));
1501 if (leader.first == 0) {
1505 &
myVehicle, correctedSpeed, leader.second, leader.first->
getSpeed(), leader.first->getCarFollowModel().getMaxDecel()));
1508 if (neighLead.first == 0) {
1512 neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel(),
true));
1514 if (leader.first == 0) {
1518 leader.first->getSpeed(), leader.first->getCarFollowModel().getMaxDecel(),
true));
1528 const double relativeGain = (neighLaneVSafe - thisLaneVSafe) /
MAX2(neighLaneVSafe,
1531 #ifdef DEBUG_WANTS_CHANGE 1535 <<
" currentDist=" << currentDist
1536 <<
" neighDist=" << neighDist
1537 <<
" thisVSafe=" << thisLaneVSafe
1538 <<
" neighVSafe=" << neighLaneVSafe
1539 <<
" relGain=" <<
toString(relativeGain, 8)
1546 if (thisLaneVSafe - 5 / 3.6 > neighLaneVSafe) {
1563 if (mySpeedGainProbability < 0 || relativeGain > 0) {
1572 double fullSpeedDrivingSeconds =
MIN2(acceptanceTime, fullSpeedGap / vMax);
1573 if (neighLead.first != 0 && neighLead.first->getSpeed() < vMax) {
1574 fullSpeedGap =
MAX2(0.,
MIN2(fullSpeedGap,
1576 vMax, neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel())));
1577 fullSpeedDrivingSeconds =
MIN2(fullSpeedDrivingSeconds, fullSpeedGap / (vMax - neighLead.first->getSpeed()));
1580 if (checkOverTakeRight && leader.first != 0
1581 && leader.first->getLane()->getVehicleMaxSpeed(leader.first) < vMax) {
1582 fullSpeedGap =
MIN2(fullSpeedGap, leader.second);
1583 fullSpeedDrivingSeconds =
MIN2(fullSpeedDrivingSeconds, fullSpeedGap / (vMax - leader.first->getSpeed()));
1584 const double relativeGain = (vMax - leader.first->getLane()->getVehicleMaxSpeed(leader.first)) /
MAX2(vMax,
1593 #ifdef DEBUG_WANTS_CHANGE 1598 <<
" neighDist=" << neighDist
1600 <<
" leaderSpeed=" << (neighLead.first == 0 ? -1 : neighLead.first->getSpeed())
1602 myVehicle.
getSpeed(), neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel()))
1603 <<
" acceptanceTime=" << acceptanceTime
1604 <<
" fullSpeedGap=" << fullSpeedGap
1605 <<
" fullSpeedDrivingSeconds=" << fullSpeedDrivingSeconds
1606 <<
" dProb=" << deltaProb
1619 #ifdef DEBUG_WANTS_CHANGE 1625 <<
" thisLaneVSafe=" << thisLaneVSafe
1626 <<
" neighLaneVSafe=" << neighLaneVSafe
1627 <<
" relativeGain=" << relativeGain
1628 <<
" blocked=" << blocked
1642 if (thisLaneVSafe > neighLaneVSafe) {
1647 }
else if (thisLaneVSafe == neighLaneVSafe) {
1665 #ifdef DEBUG_WANTS_CHANGE 1671 <<
" thisLaneVSafe=" << thisLaneVSafe
1672 <<
" neighLaneVSafe=" << neighLaneVSafe
1673 <<
" relativeGain=" << relativeGain
1674 <<
" blocked=" << blocked
1680 && (relativeGain >
NUMERICAL_EPS || changeLeftToAvoidOvertakeRight)
1690 && (right ? mySpeedGainProbability < 0 : mySpeedGainProbability > 0)) {
1697 #ifdef DEBUG_WANTS_CHANGE 1703 <<
" thisLaneVSafe=" << thisLaneVSafe
1704 <<
" neighLaneVSafe=" << neighLaneVSafe
1715 double& roundaboutDistanceAhead,
double& roundaboutDistanceAheadNeigh,
int& roundaboutEdgesAhead,
int& roundaboutEdgesAheadNeigh) {
1727 roundaboutDistanceAheadNeigh = 0;
1728 double neighPosition = pos;
1738 if (*i != 0 && *i != veh.
getLane()) {
1743 assert(nextLane != 0);
1752 #ifdef DEBUG_WANTS_CHANGE 1754 std::cout <<
"roundaboutDistanceAhead = " << roundaboutDistanceAhead
1755 <<
" roundaboutDistanceAheadNeigh = " << roundaboutDistanceAheadNeigh
1762 roundaboutEdgesAhead = 0;
1764 const MSLane* lane = *it;
1766 roundaboutEdgesAhead += 1;
1767 }
else if (roundaboutEdgesAhead > 0) {
1772 roundaboutEdgesAheadNeigh = 0;
1774 if ((*it) != 0 && (*it)->getEdge().isRoundabout()) {
1775 roundaboutEdgesAheadNeigh += 1;
1776 }
else if (roundaboutEdgesAheadNeigh > 0) {
1793 if (roundaboutEdgesAhead > 1) {
1816 for (std::vector<MSLane*>::const_iterator i = continuationLanes.begin(); i != continuationLanes.end(); i++) {
1817 assert((*i) == 0 || !(*i)->getEdge().isInternal());
1821 bool encounteredRoundabout =
false;
1822 double roundaboutDistanceAhead = 0.;
1825 std::vector<MSLane*>::const_iterator j = continuationLanes.begin();
1826 while (j != continuationLanes.end() && *j == 0) {
1831 if (j == continuationLanes.end()) {
1833 assert(initialLane == 0);
1835 }
else if (initialLane == 0) {
1840 }
else if (!initialLane->
isInternal() && initialLane != *j) {
1847 assert(position >= 0. && position <= initialLane->getLength());
1849 assert(initialLane == *j);
1850 roundaboutDistanceAhead += initialLane->
getLength() - position;
1851 if (j + 1 == continuationLanes.end() || *(j + 1) == 0 || !(*(j + 1))->getEdge().isRoundabout()) {
1855 const MSLane* nextLane = *(j + 1);
1863 roundaboutDistanceAhead += initialLane->
getLength() - position;
1865 roundaboutDistanceAhead += initialLane->
getLinkCont()[0]->getInternalLengthsAfter();
1870 for (std::vector<MSLane*>::const_iterator it = j; it != continuationLanes.end(); ++it) {
1871 const MSLane* lane = *it;
1874 encounteredRoundabout =
true;
1876 roundaboutDistanceAhead += lane->
getLength();
1881 if (it + 1 != continuationLanes.end() && *(it + 1) != 0 && (*(it + 1))->getEdge().isRoundabout()) {
1886 roundaboutDistanceAhead += linkLength;
1888 }
else if (encounteredRoundabout) {
1893 return roundaboutDistanceAhead;
1901 if ((*blocked) != 0) {
1903 #ifdef DEBUG_SLOW_DOWN 1927 (*blocked)->getCarFollowModel().getMaxDecel()));
1930 #ifdef DEBUG_SLOW_DOWN 1934 <<
" slowing down for" 1936 <<
" helpSpeed=" <<
myVSafes.back()
1956 #ifdef DEBUG_SAVE_BLOCKER_LENGTH 1972 #ifdef DEBUG_SAVE_BLOCKER_LENGTH 1984 #ifdef DEBUG_SAVE_BLOCKER_LENGTH 1990 <<
" potential=" << potential
2003 #ifdef DEBUG_WANTS_CHANGE 2005 std::cout <<
SIMTIME <<
" adapt to pedestrians on lane=" << lane->
getID() <<
"\n";
2011 if (leader.first != 0) {
2013 v =
MIN2(v, stopSpeed);
2014 #ifdef DEBUG_WANTS_CHANGE 2016 std::cout <<
SIMTIME <<
" pedLeader=" << leader.first->getID() <<
" dist=" << leader.second <<
" v=" << v <<
"\n";
bool debugVehicle() const
whether the current vehicles shall be debugged
double myLeadingBlockerLength
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.
double getMinGap() const
Get the free space in front of vehicles of this class.
void saveBlockerLength(MSVehicle *blocker, int lcaCounter)
save space for vehicles which need to counter-lane-change
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
MSLCM_LC2013(MSVehicle &v)
The action is due to the default of keeping right "Rechtsfahrgebot".
virtual double getSpeedAfterMaxDecel(double v) const
Returns the velocity after maximum deceleration.
The action is done to help someone else.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
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)
#define LOOK_FORWARD_RIGHT
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive...
int gPrecision
the precision for floating point outputs
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)
double myKeepRightProbability
#define KEEP_RIGHT_ACCEPTANCE
The car-following model abstraction.
double maximumSafeStopSpeed(double gap, double currentSpeed, bool onInsertion=false, double headway=-1) const
Returns the maximum next velocity for stopping within gap.
void * informNeighFollower(void *info, MSVehicle *sender)
Informs the follower on the desired lane.
#define MAX_ONRAMP_LENGTH
bool isAccelLane() const
return whether this lane is an acceleration lane
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)
helper function for doing the actual work
double getLength() const
Returns the lane's length.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double _patchSpeed(const double min, const double wanted, const double max, const MSCFModel &cfModel)
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
double getPositionOnLane() const
Get the vehicle's position along the lane.
std::pair< double, int > Info
information regarding save velocity (unused) and state flags of the ego vehicle
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
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)
bool currentDistDisallows(double dist, int laneOffset, double lookForwardDist)
const double myChangeProbThresholdRight
#define ROUNDABOUT_DIST_FACTOR
MSAbstractLaneChangeModel & getLaneChangeModel()
static double distanceAlongNextRoundabout(double position, const MSLane *initialLane, const std::vector< MSLane * > &continuationLanes)
compute the distance on the next upcoming roundabout along a given sequence of lanes.
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Needs to stay on the current lane.
double getImpatience() const
Returns this vehicles impatience.
const LaneChangeModel myModel
the type of this model
#define ROUNDABOUT_DIST_BONUS
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
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.
static double overtakeDistance(const MSVehicle *follower, const MSVehicle *leader, const double gap, double followerSpeed=INVALID_SPEED, double leaderSpeed=INVALID_SPEED)
MSLane * lane
The described lane.
A lane change model developed by D. Krajzewicz, J. Erdmann et al. between 2004 and 2013...
bool cancelRequest(int state)
whether the influencer cancels the given request
double mySpeedGainProbability
a value for tracking the probability that a change to the offset with the same sign is beneficial ...
void informFollower(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, int dir, const std::pair< MSVehicle *, double > &neighFollow, double remainingSeconds, double plannedSpeed)
decide whether we will try cut in before the follower or allow to be overtaken
blocked in all directions
double roundaboutDistBonus(double roundaboutDistAhead, int roundaboutEdgesAhead) const
Computes the artificial bonus distance for roundabout lanes this additional distance reduces the sens...
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
The action is urgent (to be defined by lc-model)
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key ...
static MSPModel * getModel()
const double myChangeProbThresholdLeft
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
#define CUT_IN_LEFT_SPEED_THRESHOLD
bool currentDistAllows(double dist, int laneOffset, double lookForwardDist)
#define LOOK_AHEAD_SPEED_MEMORY
const double myExperimentalParam1
bool isStopped() const
Returns whether the vehicle is at a stop.
int slowDownForBlocked(MSVehicle **blocked, int state)
compute useful slowdowns for blocked vehicles
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...
bool isRoundabout() const
#define RELGAIN_NORMALIZATION_MIN_SPEED
The action is needed to follow the route (navigational lc)
A structure representing the best lanes for continuing the current route starting at 'lane'...
virtual PersonDist nextBlocking(const MSLane *lane, double minPos, double minRight, double maxLeft, double stopTime=0)
returns the next pedestrian beyond minPos that is laterally between minRight and maxLeft or 0 ...
double getRightSideOnLane() const
Get the vehicle's lateral position on the lane:
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
int myOwnState
The current state of the vehicle.
bool isInternal() const
return whether this edge is an internal edge
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
std::vector< double > myVSafes
static double gapExtrapolation(const double duration, const double currentGap, double v1, double v2, double a1=0, double a2=0, const double maxV1=std::numeric_limits< double >::max(), const double maxV2=std::numeric_limits< double >::max())
return the resulting gap if, starting with gap currentGap, two vehicles continue with constant accele...
std::pair< const MSPerson *, double > PersonDist
double getMaxSpeedOnLane() const
Returns the maximal speed for the vehicle on its current lane (including speed factor and deviation...
double getLength() const
Get vehicle's length [m].
MSVehicle & myVehicle
The vehicle this lane-changer belongs to.
void * informNeighLeader(void *info, MSVehicle *sender)
Informs the leader on the desired lane.
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
Influencer & getInfluencer()
Returns the velocity/lane influencer.
LaneChangeAction
The state of a vehicle's lane-change behavior.
static void getRoundaboutAheadInfo(const MSLCM_LC2013 *lcm, const MSVehicle::LaneQ &curr, const MSVehicle::LaneQ &neigh, double &roundaboutDistanceAhead, double &roundaboutDistanceAheadNeigh, int &roundaboutEdgesAhead, int &roundaboutEdgesAheadNeigh)
computes the distance and number of edges in the next upcoming roundabout along the lane continuation...
void adaptSpeedToPedestrians(const MSLane *lane, double &v)
react to pedestrians on the given lane
double occupation
The overall vehicle sum on consecutive lanes which can be passed without a lane change.
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this laneChangeModel. Throw exception for unsupported key ...
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...
std::vector< MSLane * > bestContinuations
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
static double _2double(const E *const data)
converts a char-type array into the double value described by it
double getInternalLengthsAfter() const
Returns the cumulative length of all internal lanes after this link.
double myCooperativeParam
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
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 void prepareStep()
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
virtual void saveBlockerLength(double length)
reserve space at the end of the lane to avoid dead locks
#define LOOK_FORWARD_LEFT
The action is due to a TraCI request.
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
static bool gSemiImplicitEulerUpdate
bool amBlockingFollowerPlusNB()
#define ROUNDABOUT_DIST_TRESH
double informLeader(MSAbstractLaneChangeModel::MSLCMessager &msgPass, int blocked, int dir, const std::pair< MSVehicle *, double > &neighLead, double remainingSeconds)
double changeRequestRemainingSeconds(const SUMOTime currentTime) const
Return the remaining number of seconds of the current laneTimeLine assuming one exists.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
#define LOOK_AHEAD_MIN_SPEED
#define LCA_RIGHT_IMPATIENCE
MSLane * getLane() const
Returns the lane the vehicle is on.
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
public emergency vehicles
void * inform(void *info, MSVehicle *sender)
double maximumSafeFollowSpeed(double gap, double egoSpeed, double predSpeed, double predMaxDecel, bool onInsertion=false) const
Returns the maximum safe velocity for following the given leader.
Representation of a lane in the micro simulation.
const MSCFModel & myCarFollowModel
The vehicle's car following model.
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i...
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.
double getSpeed() const
Returns the vehicle's current speed.