38 #define LOOK_FORWARD_SPEED_DIVIDER 14.
40 #define LOOK_FORWARD_FAR 15.
41 #define LOOK_FORWARD_NEAR 5.
46 #define JAM_FACTOR2 1.
54 myChangeProbability(0),
55 myLeadingBlockerLength(0), myLeftSpace(0) {}
65 const std::pair<MSVehicle*, double>& leader,
66 const std::pair<MSVehicle*, double>& neighLead,
67 const std::pair<MSVehicle*, double>& neighFollow,
69 const std::vector<MSVehicle::LaneQ>& preb,
73 return (laneOffset == -1 ?
74 wantsChangeToRight(msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked)
75 :
wantsChangeToLeft(msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked));
83 const std::pair<MSVehicle*, double>& leader,
84 const std::pair<MSVehicle*, double>& neighLead,
85 const std::pair<MSVehicle*, double>& neighFollow,
87 const std::vector<MSVehicle::LaneQ>& preb,
92 int bestLaneOffset = 0;
93 double currentDist = 0;
95 double neighExtDist = 0;
96 double currExtDist = 0;
103 for (
int p = 0; p < (int) preb.size(); ++p) {
104 if (preb[p].lane == prebLane && p > 0) {
107 currentDist = curr.
length;
109 neighDist = preb[p - 1].length;
110 neighExtDist = preb[p - 1].lane->getLength();
111 best = preb[p + bestLaneOffset];
120 if (leader.first != 0
137 if ((*lastBlocked) !=
nullptr) {
147 (*lastBlocked) =
nullptr;
173 if (neighLead.second > 0 && neighLead.second > leader.second) {
179 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_LEFT) != 0) {
197 double maxJam =
MAX2(preb[currIdx - 1].occupation, preb[currIdx].occupation);
210 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < rv)) {
226 (
currentDistAllows(neighDist, bestLaneOffset, rv) || neighDist >= currentDist)) {
246 if (neighLead.first == 0) {
252 if (leader.first == 0) {
261 if (thisLaneVSafe - neighLaneVSafe > 5. / 3.6) {
273 vmax -= (double)(5. / 2.6);
274 if (neighLaneVSafe >= vmax) {
290 const std::pair<MSVehicle*, double>& leader,
291 const std::pair<MSVehicle*, double>& neighLead,
292 const std::pair<MSVehicle*, double>& neighFollow,
294 const std::vector<MSVehicle::LaneQ>& preb,
299 int bestLaneOffset = 0;
300 double currentDist = 0;
301 double neighDist = 0;
302 double neighExtDist = 0;
303 double currExtDist = 0;
310 for (
int p = 0; p < (int) preb.size(); ++p) {
311 if (preb[p].lane == prebLane) {
314 currentDist = curr.
length;
316 neighDist = preb[p + 1].length;
317 neighExtDist = preb[p + 1].lane->getLength();
318 best = preb[p + bestLaneOffset];
327 if (leader.first != 0
344 if ((*lastBlocked) !=
nullptr) {
354 (*lastBlocked) =
nullptr;
380 if (neighLead.second > 0 && neighLead.second > leader.second) {
386 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_RIGHT) != 0) {
404 double maxJam =
MAX2(preb[currIdx + 1].occupation, preb[currIdx].occupation);
417 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < lv)) {
442 (
currentDistAllows(neighDist, bestLaneOffset, lv) || neighDist >= currentDist)) {
460 if (neighLead.first == 0) {
466 if (leader.first == 0) {
474 if (thisLaneVSafe > neighLaneVSafe) {
497 double MAGIC_offset = 1.;
507 return MAX2(min, safe);
519 double nVSafe = wanted;
521 for (std::vector<double>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
523 if (v >= min && v <= max) {
524 nVSafe =
MIN2(v, nVSafe);
539 return (min + wanted) / (double) 2.0;
542 return (max + wanted) / (double) 2.0;
544 return (min + wanted) / (double) 2.0;
555 return (min + wanted) / (double) 2.0;
568 return (max + wanted) / (double) 2.0;
574 return (min + wanted) / (double) 2.0;
605 const std::pair<MSVehicle*, double>& neighLead,
606 const std::pair<MSVehicle*, double>& neighFollow) {
608 assert(neighFollow.first != 0);
624 if (neighLead.first != 0 && neighLead.second > 0) {