39 #define LOOK_FORWARD_SPEED_DIVIDER 14.
41 #define LOOK_FORWARD_FAR 15.
42 #define LOOK_FORWARD_NEAR 5.
47 #define JAM_FACTOR2 1.
55 myChangeProbability(0),
56 myLeadingBlockerLength(0), myLeftSpace(0) {}
66 const std::pair<MSVehicle*, double>& leader,
67 const std::pair<MSVehicle*, double>& neighLead,
68 const std::pair<MSVehicle*, double>& neighFollow,
70 const std::vector<MSVehicle::LaneQ>& preb,
74 return (laneOffset == -1 ?
75 wantsChangeToRight(msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked)
76 :
wantsChangeToLeft(msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked));
84 const std::pair<MSVehicle*, double>& leader,
85 const std::pair<MSVehicle*, double>& neighLead,
86 const std::pair<MSVehicle*, double>& neighFollow,
88 const std::vector<MSVehicle::LaneQ>& preb,
93 int bestLaneOffset = 0;
94 double currentDist = 0;
96 double neighExtDist = 0;
97 double currExtDist = 0;
104 for (
int p = 0; p < (int) preb.size(); ++p) {
105 if (preb[p].lane == prebLane && p > 0) {
108 currentDist = curr.
length;
110 neighDist = preb[p - 1].length;
111 neighExtDist = preb[p - 1].lane->getLength();
112 best = preb[p + bestLaneOffset];
121 if (leader.first != 0
138 if ((*lastBlocked) !=
nullptr) {
148 (*lastBlocked) =
nullptr;
174 if (neighLead.second > 0 && neighLead.second > leader.second) {
180 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_LEFT) != 0) {
198 double maxJam =
MAX2(preb[currIdx - 1].occupation, preb[currIdx].occupation);
211 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < rv)) {
227 (
currentDistAllows(neighDist, bestLaneOffset, rv) || neighDist >= currentDist)) {
247 if (neighLead.first == 0) {
253 if (leader.first == 0) {
262 if (thisLaneVSafe - neighLaneVSafe > 5. / 3.6) {
274 vmax -= (double)(5. / 2.6);
275 if (neighLaneVSafe >= vmax) {
291 const std::pair<MSVehicle*, double>& leader,
292 const std::pair<MSVehicle*, double>& neighLead,
293 const std::pair<MSVehicle*, double>& neighFollow,
295 const std::vector<MSVehicle::LaneQ>& preb,
300 int bestLaneOffset = 0;
301 double currentDist = 0;
302 double neighDist = 0;
303 double neighExtDist = 0;
304 double currExtDist = 0;
311 for (
int p = 0; p < (int) preb.size(); ++p) {
312 if (preb[p].lane == prebLane) {
315 currentDist = curr.
length;
317 neighDist = preb[p + 1].length;
318 neighExtDist = preb[p + 1].lane->getLength();
319 best = preb[p + bestLaneOffset];
328 if (leader.first != 0
345 if ((*lastBlocked) !=
nullptr) {
355 (*lastBlocked) =
nullptr;
381 if (neighLead.second > 0 && neighLead.second > leader.second) {
387 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_RIGHT) != 0) {
405 double maxJam =
MAX2(preb[currIdx + 1].occupation, preb[currIdx].occupation);
418 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < lv)) {
443 (
currentDistAllows(neighDist, bestLaneOffset, lv) || neighDist >= currentDist)) {
461 if (neighLead.first == 0) {
467 if (leader.first == 0) {
475 if (thisLaneVSafe > neighLaneVSafe) {
498 double MAGIC_offset = 1.;
508 return MAX2(min, safe);
520 double nVSafe = wanted;
522 for (std::vector<double>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
524 if (v >= min && v <= max) {
525 nVSafe =
MIN2(v, nVSafe);
540 return (min + wanted) / (double) 2.0;
543 return (max + wanted) / (double) 2.0;
545 return (min + wanted) / (double) 2.0;
556 return (min + wanted) / (double) 2.0;
569 return (max + wanted) / (double) 2.0;
575 return (min + wanted) / (double) 2.0;
606 const std::pair<MSVehicle*, double>& neighLead,
607 const std::pair<MSVehicle*, double>& neighFollow) {
609 assert(neighFollow.first != 0);
624 if (neighLead.first != 0 && neighLead.second > 0) {