42 #ifdef CHECK_MEMORY_LEAKS
44 #endif // CHECK_MEMORY_LEAKS
47 #ifdef DEBUG_VEHICLE_GUI_SELECTION
59 #define LOOK_FORWARD_SPEED_DIVIDER (SUMOReal)14.
61 #define LOOK_FORWARD_RIGHT (SUMOReal)10.
62 #define LOOK_FORWARD_LEFT (SUMOReal)20.
64 #define JAM_FACTOR (SUMOReal)1.
66 #define LCA_RIGHT_IMPATIENCE (SUMOReal)-1.
68 #define LOOK_AHEAD_MIN_SPEED (SUMOReal)0.0
69 #define LOOK_AHEAD_SPEED_MEMORY (SUMOReal)0.9
70 #define LOOK_AHEAD_SPEED_DECREMENT 6.
72 #define HELP_DECEL_FACTOR (SUMOReal)1.0
74 #define HELP_OVERTAKE (SUMOReal)(10.0 / 3.6)
75 #define MIN_FALLBEHIND (SUMOReal)(14.0 / 3.6)
77 #define KEEP_RIGHT_HEADWAY (SUMOReal)2.0
79 #define URGENCY (SUMOReal)2.0
81 #define ROUNDABOUT_DIST_BONUS (SUMOReal)80.0
89 mySpeedGainProbability(0),
90 myKeepRightProbability(0),
91 myLeadingBlockerLength(0),
106 const std::pair<MSVehicle*, SUMOReal>& leader,
107 const std::pair<MSVehicle*, SUMOReal>& neighLead,
108 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
110 const std::vector<MSVehicle::LaneQ>& preb,
113 const int result =
_wantsChange(laneOffset, msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked);
140 return MAX2(min, safe);
147 for (std::vector<SUMOReal>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
149 if (v >= min && v <= max) {
150 nVSafe =
MIN2(v, nVSafe);
165 return (max + wanted) / (
SUMOReal) 2.0;
169 return (min + wanted) / (
SUMOReal) 2.0;
172 return (max + wanted) / (
SUMOReal) 2.0;
180 return (max + wanted) / (
SUMOReal) 2.0;
207 const std::pair<MSVehicle*, SUMOReal>& neighLead,
211 for (std::vector<SUMOReal>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
214 plannedSpeed =
MIN2(plannedSpeed, v);
218 assert(neighLead.first != 0);
222 const SUMOReal overtakeDist = (neighLead.second
234 || dv * remainingSeconds < overtakeDist) {
257 }
else if (neighLead.first != 0) {
265 return MIN2(targetSpeed, plannedSpeed);
277 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
281 assert(neighFollow.first != 0);
287 if ((neededGap - neighFollow.second) / remainingSeconds < (plannedSpeed - nv->
getSpeed())) {
305 const SUMOReal dv = plannedSpeed - neighNewSpeed1s;
307 const SUMOReal decelGap = neighFollow.second + dv;
309 if (decelGap > 0 && decelGap >= secureGap) {
315 }
else if (dv > 0 && dv * remainingSeconds > (secureGap - decelGap +
POSITION_EPS)) {
332 const SUMOReal overtakeDist = (neighFollow.second
338 const SUMOReal needDV = overtakeDist / remainingSeconds;
382 const std::pair<MSVehicle*, SUMOReal>& leader,
383 const std::pair<MSVehicle*, SUMOReal>& neighLead,
384 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
386 const std::vector<MSVehicle::LaneQ>& preb,
389 assert(laneOffset == 1 || laneOffset == -1);
393 int bestLaneOffset = 0;
402 for (
int p = 0; p < (
int) preb.size(); ++p) {
403 if (preb[p].lane == prebLane && p + laneOffset >= 0) {
404 assert(p + laneOffset < (
int)preb.size());
406 neigh = preb[p + laneOffset];
407 currentDist = curr.
length;
409 bestLaneOffset = curr.bestLaneOffset;
410 if (bestLaneOffset == 0 && preb[p + laneOffset].bestLaneOffset == 0) {
411 bestLaneOffset = laneOffset;
413 best = preb[p + bestLaneOffset];
419 const bool right = (laneOffset == -1);
423 const bool changeToBest = (right && bestLaneOffset < 0) || (!right && bestLaneOffset > 0);
428 if (lastBlocked != firstBlocked) {
460 int roundaboutEdgesAhead = 0;
462 if ((*it) != 0 && (*it)->getEdge().isRoundabout()) {
463 roundaboutEdgesAhead += 1;
464 }
else if (roundaboutEdgesAhead > 0) {
469 int roundaboutEdgesAheadNeigh = 0;
471 if ((*it) != 0 && (*it)->getEdge().isRoundabout()) {
472 roundaboutEdgesAheadNeigh += 1;
473 }
else if (roundaboutEdgesAheadNeigh > 0) {
478 if (roundaboutEdgesAhead > 1) {
484 const SUMOReal maxJam =
MAX2(preb[currIdx + laneOffset].occupation, preb[currIdx].occupation);
512 }
else if (bestLaneOffset == 0 && (neighLeftPlace * 2. < laDist)) {
522 if ((ret & lcaCounter) != 0) {
534 if (changeToBest &&
abs(bestLaneOffset) > 1) {
542 if (*firstBlocked != neighLead.first) {
549 const SUMOReal plannedSpeed =
informLeader(msgPass, blocked, myLca, neighLead, remainingSeconds);
550 if (plannedSpeed >= 0) {
552 informFollower(msgPass, blocked, myLca, neighFollow, remainingSeconds, plannedSpeed);
558 if (roundaboutEdgesAhead > 1) {
606 if (neighLead.first == 0) {
611 &
myVehicle,
myVehicle.
getSpeed(), neighLead.second, neighLead.first->getSpeed(), neighLead.first->getCarFollowModel().getMaxDecel()));
613 if (leader.first == 0) {
625 if (thisLaneVSafe - neighLaneVSafe > 5. / 3.6) {
649 if (thisLaneVSafe > neighLaneVSafe) {
664 && (right ? mySpeedGainProbability < 0 : mySpeedGainProbability > 0)) {
686 if ((*blocked) != 0) {
698 (*blocked)->getCarFollowModel().getMaxDecel()));