41 #ifdef CHECK_MEMORY_LEAKS
43 #endif // CHECK_MEMORY_LEAKS
46 #ifdef DEBUG_VEHICLE_GUI_SELECTION
58 #define LOOK_FORWARD_SPEED_DIVIDER 14.
60 #define LOOK_FORWARD_FAR 15.
61 #define LOOK_FORWARD_NEAR 5.
66 #define JAM_FACTOR2 1.
74 myChangeProbability(0),
75 myLeadingBlockerLength(0), myLeftSpace(0) {}
85 const std::pair<MSVehicle*, SUMOReal>& leader,
86 const std::pair<MSVehicle*, SUMOReal>& neighLead,
87 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
89 const std::vector<MSVehicle::LaneQ>& preb,
93 return (laneOffset == -1 ?
94 wantsChangeToRight(msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked)
95 :
wantsChangeToLeft(msgPass, blocked, leader, neighLead, neighFollow, neighLane, preb, lastBlocked, firstBlocked));
103 const std::pair<MSVehicle*, SUMOReal>& leader,
104 const std::pair<MSVehicle*, SUMOReal>& neighLead,
105 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
107 const std::vector<MSVehicle::LaneQ>& preb,
111 #ifdef DEBUG_VEHICLE_GUI_SELECTION
117 int bestLaneOffset = 0;
128 for (
int p = 0; p < (
int) preb.size(); ++p) {
129 if (preb[p].lane == prebLane && p > 0) {
132 currentDist = curr.
length;
134 neighDist = preb[p - 1].length;
135 neighExtDist = preb[p - 1].lane->getLength();
136 best = preb[p + bestLaneOffset];
145 if (leader.first != 0
162 if ((*lastBlocked) != 0) {
198 if (neighLead.second > 0 && neighLead.second > leader.second) {
204 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_LEFT) != 0) {
222 SUMOReal maxJam =
MAX2(preb[currIdx - 1].occupation, preb[currIdx].occupation);
235 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < rv)) {
251 (
currentDistAllows(neighDist, bestLaneOffset, rv) || neighDist >= currentDist)) {
271 if (neighLead.first == 0) {
277 if (leader.first == 0) {
286 if (thisLaneVSafe - neighLaneVSafe > 5. / 3.6) {
299 if (neighLaneVSafe >= vmax) {
315 const std::pair<MSVehicle*, SUMOReal>& leader,
316 const std::pair<MSVehicle*, SUMOReal>& neighLead,
317 const std::pair<MSVehicle*, SUMOReal>& neighFollow,
319 const std::vector<MSVehicle::LaneQ>& preb,
323 #ifdef DEBUG_VEHICLE_GUI_SELECTION
329 int bestLaneOffset = 0;
340 for (
int p = 0; p < (
int) preb.size(); ++p) {
341 if (preb[p].lane == prebLane) {
344 currentDist = curr.
length;
346 neighDist = preb[p + 1].length;
347 neighExtDist = preb[p + 1].lane->getLength();
348 best = preb[p + bestLaneOffset];
357 if (leader.first != 0
374 if ((*lastBlocked) != 0) {
410 if (neighLead.second > 0 && neighLead.second > leader.second) {
416 if (neighLead.first != 0 && (neighLead.first->getLaneChangeModel().getOwnState()&
LCA_RIGHT) != 0) {
434 SUMOReal maxJam =
MAX2(preb[currIdx + 1].occupation, preb[currIdx].occupation);
447 if (currExtDist > neighExtDist && (neighLeftPlace * 2. < lv)) {
472 (
currentDistAllows(neighDist, bestLaneOffset, lv) || neighDist >= currentDist)) {
490 if (neighLead.first == 0) {
496 if (leader.first == 0) {
504 if (thisLaneVSafe > neighLaneVSafe) {
524 #ifdef DEBUG_VEHICLE_GUI_SELECTION
542 return MAX2(min, safe);
556 for (std::vector<SUMOReal>::const_iterator i =
myVSafes.begin(); i !=
myVSafes.end(); ++i) {
558 if (v >= min && v <= max) {
559 nVSafe =
MIN2(v, nVSafe);
574 return (min + wanted) / (
SUMOReal) 2.0;
577 return (max + wanted) / (
SUMOReal) 2.0;
579 return (min + wanted) / (
SUMOReal) 2.0;
590 return (min + wanted) / (
SUMOReal) 2.0;
603 return (max + wanted) / (
SUMOReal) 2.0;
609 return (min + wanted) / (
SUMOReal) 2.0;
641 const std::pair<MSVehicle*, SUMOReal>& neighLead,
642 const std::pair<MSVehicle*, SUMOReal>& neighFollow) {
644 assert(neighFollow.first != 0);
659 if (neighLead.first != 0 && neighLead.second > 0) {