48 #ifdef CHECK_MEMORY_LEAKS
50 #endif // CHECK_MEMORY_LEAKS
53 #ifdef DEBUG_VEHICLE_GUI_SELECTION
64 : myAllowsSwap(allowSwap) {
65 assert(lanes->size() > 1);
69 for (std::vector<MSLane*>::iterator lane = lanes->begin(); lane != lanes->end(); ++lane) {
74 ce.
veh = (*lane)->myVehicles.rbegin();
95 bool haveChanged =
change();
109 ce->firstBlocked = 0;
113 if (vehicles.empty()) {
114 ce->veh = vehicles.rend();
118 ce->veh = vehicles.rbegin();
119 if (vehicles.size() == 1) {
123 ce->follow = *(vehicles.rbegin() + 1);
139 #ifdef DEBUG_VEHICLE_GUI_SELECTION
158 const std::vector<MSVehicle::LaneQ>& preb = vehicle->
getBestLanes();
164 bool changingAllowed1 = (state1 &
LCA_BLOCKED) == 0;
166 if ((state1 &
LCA_RIGHT) != 0 && changingAllowed1) {
170 if ((state1 & LCA_RIGHT) != 0 && (state1 &
LCA_URGENT) != 0) {
171 (
myCandi - 1)->lastBlocked = vehicle;
172 if ((
myCandi - 1)->firstBlocked == 0) {
173 (
myCandi - 1)->firstBlocked = vehicle;
184 bool changingAllowed2 = (state2 &
LCA_BLOCKED) == 0;
186 if ((state2 &
LCA_LEFT) != 0 && changingAllowed2) {
190 if ((state2 & LCA_LEFT) != 0 && (state2 &
LCA_URGENT) != 0) {
191 (
myCandi + 1)->lastBlocked = vehicle;
192 if ((
myCandi + 1)->firstBlocked == 0) {
193 (
myCandi + 1)->firstBlocked = vehicle;
218 if (target->hoppedVeh != 0) {
219 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
238 MSLane::VehCont::iterator i = find(target->lane->myTmpVehicles.begin(), target->lane->myTmpVehicles.end(), prohibitor);
239 if (i != target->lane->myTmpVehicles.end()) {
240 assert(*i == prohibitor);
241 target->lane->myTmpVehicles.erase(i);
243 target->hoppedVeh = vehicle;
244 target->lane->myTmpVehicles.insert(target->lane->myTmpVehicles.begin(), vehicle);
245 myCandi->hoppedVeh = prohibitor;
246 myCandi->lane->myTmpVehicles.insert(
myCandi->lane->myTmpVehicles.begin(), prohibitor);
287 to->hoppedVeh = vehicle;
290 to->lane->myTmpVehicles.insert(to->lane->myTmpVehicles.begin(), vehicle);
293 from->lane->myTmpVehicles.insert(from->lane->myTmpVehicles.begin(), vehicle);
296 to->dens += to->hoppedVeh->getVehicleType().getLengthWithGap();
300 std::pair<MSVehicle* const, SUMOReal>
305 MSLane* targetLane = target->lane;
313 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
315 MSLane* nextLane = (*link)->getLane();
317 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
321 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
327 return std::pair<MSVehicle* const, SUMOReal>(leader,
MAX2((
SUMOReal) 0, gap));
331 return std::pair<MSVehicle* const, SUMOReal>(leader,
MAX2((
SUMOReal) 0, gap));
336 std::pair<MSVehicle* const, SUMOReal>
341 if (target->hoppedVeh != 0) {
342 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
344 neighLead = target->hoppedVeh;
347 if (neighLead == 0) {
348 MSLane* targetLane = target->lane;
357 return std::pair<MSVehicle* const, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
360 return target->lane->getLeaderOnConsecutive(dist, seen, speed, *
veh(
myCandi), bestLaneConts);
368 std::pair<MSVehicle* const, SUMOReal>
372 if (target->hoppedVeh != 0) {
373 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
375 neighFollow = target->hoppedVeh;
378 if (neighFollow == 0) {
379 SUMOReal speed = target->lane->getSpeedLimit();
389 return std::pair<MSVehicle* const, SUMOReal>(neighFollow, candi->
getPositionOnLane() - candi->
getVehicleType().
getLength() - neighFollow->getPositionOnLane() - neighFollow->getVehicleType().getMinGap());
403 if (!vehHasChanged) {
434 ce->lane->swapAfterLaneChange(t);
453 assert(
veh(ce) != 0);
454 assert(
veh(max) != 0);
455 if (
veh(max)->getPositionOnLane() <
veh(ce)->getPositionOnLane()) {
460 assert(
veh(max) != 0);
467 const std::pair<MSVehicle* const, SUMOReal>& leader,
468 const std::vector<MSVehicle::LaneQ>& preb)
const {
477 if (neighFollow.first != 0 && neighFollow.second < 0) {
480 if (neighLead.first != 0 && neighLead.second < 0) {
484 if (neighFollow.first != 0) {
487 blocked |= blockedByFollower;
492 if (neighLead.first != 0) {
495 blocked |= blockedByLeader;
501 laneOffset, msg, blocked, leader, neighLead, neighFollow, *(target->lane), preb, &(
myCandi->lastBlocked), &(
myCandi->firstBlocked));