46 #ifdef CHECK_MEMORY_LEAKS
48 #endif // CHECK_MEMORY_LEAKS
51 #ifdef DEBUG_VEHICLE_GUI_SELECTION
62 : myAllowsSwap(allowSwap) {
63 assert(lanes->size() > 1);
67 for (std::vector<MSLane*>::iterator lane = lanes->begin(); lane != lanes->end(); ++lane) {
72 ce.
veh = (*lane)->myVehicles.rbegin();
92 bool haveChanged =
change();
109 if (vehicles.empty()) {
110 ce->veh = vehicles.rend();
114 ce->veh = vehicles.rbegin();
115 if (vehicles.size() == 1) {
119 ce->follow = *(vehicles.rbegin() + 1);
135 #ifdef DEBUG_VEHICLE_GUI_SELECTION
150 const std::vector<MSVehicle::LaneQ>& preb = vehicle->
getBestLanes();
153 ((std::vector<MSVehicle::LaneQ>&) preb)[i].occupation =
myChanger[i].dens + preb[i].nextOccupation;
167 bool changingAllowed1 = (state1 &
LCA_BLOCKED) == 0;
169 if ((state1 &
LCA_RIGHT) != 0 && changingAllowed1) {
177 if ((state1 & LCA_RIGHT) != 0 && (state1 & LCA_URGENT) != 0) {
178 (
myCandi - 1)->lastBlocked = vehicle;
189 state2 =
change2left(leader, lLead, lFollow, preb);
193 bool changingAllowed2 = (state2 &
LCA_BLOCKED) == 0;
196 if ((state2 &
LCA_LEFT) != 0 && changingAllowed2) {
204 if ((state2 & LCA_LEFT) != 0 && (state2 & LCA_URGENT) != 0) {
205 (
myCandi + 1)->lastBlocked = vehicle;
229 if (target->hoppedVeh != 0) {
230 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
249 MSLane::VehCont::iterator i = find(target->lane->myTmpVehicles.begin(), target->lane->myTmpVehicles.end(), prohibitor);
250 if (i != target->lane->myTmpVehicles.end()) {
252 assert(bla == prohibitor);
253 target->lane->myTmpVehicles.erase(i);
255 target->hoppedVeh = vehicle;
256 target->lane->myTmpVehicles.insert(target->lane->myTmpVehicles.begin(), vehicle);
257 myCandi->hoppedVeh = prohibitor;
258 myCandi->lane->myTmpVehicles.insert(
myCandi->lane->myTmpVehicles.begin(), prohibitor);
299 to->hoppedVeh = vehicle;
302 to->lane->myTmpVehicles.insert(to->lane->myTmpVehicles.begin(), vehicle);
305 from->lane->myTmpVehicles.insert(from->lane->myTmpVehicles.begin(), vehicle);
308 to->dens += to->hoppedVeh->getVehicleType().getLengthWithGap();
312 std::pair<MSVehicle* const, SUMOReal>
317 MSLane* targetLane = target->lane;
323 MSLinkCont::const_iterator link = targetLane->
succLinkSec(*
veh(
myCandi), 1, *targetLane, bestLaneConts);
325 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
327 MSLane* nextLane = (*link)->getLane();
329 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
333 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
339 return std::pair<MSVehicle* const, SUMOReal>(leader,
MAX2((
SUMOReal) 0, gap));
343 return std::pair<MSVehicle* const, SUMOReal>(leader,
MAX2((
SUMOReal) 0, gap));
348 std::pair<MSVehicle* const, SUMOReal>
353 if (target->hoppedVeh != 0) {
354 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
356 neighLead = target->hoppedVeh;
359 if (neighLead == 0) {
360 MSLane* targetLane = target->lane;
369 return std::pair<MSVehicle* const, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
372 return target->lane->getLeaderOnConsecutive(dist, seen, speed, *
veh(
myCandi), bestLaneConts);
380 std::pair<MSVehicle* const, SUMOReal>
384 if (target->hoppedVeh != 0) {
385 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
387 neighFollow = target->hoppedVeh;
390 if (neighFollow == 0) {
391 SUMOReal speed = target->lane->getSpeedLimit();
402 return std::pair<MSVehicle* const, SUMOReal>(neighFollow, candi->
getPositionOnLane() - candi->
getVehicleType().
getLength() - neighFollow->getPositionOnLane() - neighFollow->getVehicleType().getMinGap());
416 if (!vehHasChanged) {
447 ce->lane->swapAfterLaneChange(t);
466 assert(
veh(ce) != 0);
467 assert(
veh(max) != 0);
468 if (
veh(max)->getPositionOnLane() <
veh(ce)->getPositionOnLane()) {
473 assert(
veh(max) != 0);
480 const std::pair<MSVehicle* const, SUMOReal>& rLead,
481 const std::pair<MSVehicle* const, SUMOReal>& rFollow,
482 const std::vector<MSVehicle::LaneQ>& preb)
const {
490 if (rFollow.first != 0 && rFollow.second < 0) {
493 if (rLead.first != 0 && rLead.second < 0) {
497 if (rFollow.first != 0) {
505 if (rLead.first != 0) {
514 msg, blocked, leader, rLead, rFollow, *(
myCandi - 1)->lane, preb, &(
myCandi->lastBlocked));
520 const std::pair<MSVehicle* const, SUMOReal>& rLead,
521 const std::pair<MSVehicle* const, SUMOReal>& rFollow,
522 const std::vector<MSVehicle::LaneQ>& preb)
const {
530 if (rFollow.first != 0 && rFollow.second < 0) {
533 if (rLead.first != 0 && rLead.second < 0) {
537 if (rFollow.first != 0) {
544 if (rLead.first != 0) {
552 msg, blocked, leader, rLead, rFollow, *(
myCandi + 1)->lane, preb, &(
myCandi->lastBlocked));