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
140 const std::vector<MSVehicle::LaneQ> &preb = vehicle->
getBestLanes();
143 ((std::vector<MSVehicle::LaneQ>&) preb)[i].occupation =
myChanger[i].dens + preb[i].nextOccupation;
157 bool changingAllowed1 = (state1 &
LCA_BLOCKED) == 0;
159 if ((state1 &
LCA_RIGHT) != 0 && changingAllowed1) {
164 (
myCandi - 1)->hoppedVeh = vehicle;
165 (
myCandi - 1)->lane->myTmpVehicles.push_front(vehicle);
167 myCandi->lane->leftByLaneChange(vehicle);
169 (
myCandi - 1)->lane->enteredByLaneChange(vehicle);
172 (
myCandi - 1)->dens += (
myCandi - 1)->hoppedVeh->getVehicleType().getLengthWithGap();
175 if ((state1 & LCA_RIGHT) != 0 && (state1 & LCA_URGENT) != 0) {
176 (
myCandi - 1)->lastBlocked = vehicle;
187 state2 =
change2left(leader, lLead, lFollow, preb);
191 bool changingAllowed2 = (state2 &
LCA_BLOCKED) == 0;
194 if ((state2 &
LCA_LEFT) != 0 && changingAllowed2) {
202 myCandi->lane->leftByLaneChange(vehicle);
204 (
myCandi + 1)->lane->enteredByLaneChange(vehicle);
207 (
myCandi + 1)->dens += (
myCandi + 1)->hoppedVeh->getVehicleType().getLengthWithGap();
210 if ((state2 & LCA_LEFT) != 0 && (state2 & LCA_URGENT) != 0) {
211 (
myCandi + 1)->lastBlocked = vehicle;
238 if (target->hoppedVeh != 0) {
239 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
258 MSLane::VehCont::iterator i = find(target->lane->myTmpVehicles.begin(), target->lane->myTmpVehicles.end(), prohibitor);
259 if (i != target->lane->myTmpVehicles.end()) {
261 assert(bla == prohibitor);
262 target->lane->myTmpVehicles.erase(i);
264 target->hoppedVeh = vehicle;
265 target->lane->myTmpVehicles.push_front(vehicle);
266 myCandi->hoppedVeh = prohibitor;
267 myCandi->lane->myTmpVehicles.push_front(prohibitor);
302 std::pair<MSVehicle* const, SUMOReal>
307 MSLane* targetLane = target->lane;
313 MSLinkCont::const_iterator link = targetLane->
succLinkSec(*
veh(
myCandi), 1, *targetLane, bestLaneConts);
315 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
317 MSLane* nextLane = (*link)->getLane();
319 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
323 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
329 return std::pair<MSVehicle * const, SUMOReal>(leader,
MAX2((
SUMOReal) 0, gap));
333 return std::pair<MSVehicle * const, SUMOReal>(leader,
MAX2((
SUMOReal) 0, gap));
338 std::pair<MSVehicle* const, SUMOReal>
343 if (target->hoppedVeh != 0) {
344 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
346 neighLead = target->hoppedVeh;
349 if (neighLead == 0) {
350 MSLane* targetLane = target->lane;
360 return std::pair<MSVehicle * const, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
362 return target->lane->getLeaderOnConsecutive(dist, seen, speed, *
veh(
myCandi), bestLaneConts);
370 std::pair<MSVehicle* const, SUMOReal>
374 if (target->hoppedVeh != 0) {
375 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
377 neighFollow = target->hoppedVeh;
380 if (neighFollow == 0) {
381 SUMOReal speed = target->lane->getMaxSpeed();
392 return std::pair<MSVehicle * const, SUMOReal>(neighFollow, candi->
getPositionOnLane() - candi->
getVehicleType().
getLength() - neighFollow->getPositionOnLane() - neighFollow->getVehicleType().getMinGap());
406 if (!vehHasChanged) {
437 ce->lane->swapAfterLaneChange(t);
456 assert(
veh(ce) != 0);
457 assert(
veh(max) != 0);
458 if (
veh(max)->getPositionOnLane() <
veh(ce)->getPositionOnLane()) {
463 assert(
veh(max) != 0);
470 const std::pair<MSVehicle* const, SUMOReal> &rLead,
471 const std::pair<MSVehicle* const, SUMOReal> &rFollow,
472 const std::vector<MSVehicle::LaneQ> &preb)
const {
480 if (rFollow.first != 0 && rFollow.second < 0) {
483 if (rLead.first != 0 && rLead.second < 0) {
487 if (rFollow.first != 0) {
495 if (rLead.first != 0) {
504 msg, blocked, leader, rLead, rFollow, *(
myCandi - 1)->lane, preb, &(
myCandi->lastBlocked));
510 const std::pair<MSVehicle* const, SUMOReal> &rLead,
511 const std::pair<MSVehicle* const, SUMOReal> &rFollow,
512 const std::vector<MSVehicle::LaneQ> &preb)
const {
520 if (rFollow.first != 0 && rFollow.second < 0) {
523 if (rLead.first != 0 && rLead.second < 0) {
527 if (rFollow.first != 0) {
534 if (rLead.first != 0) {
542 msg, blocked, leader, rLead, rFollow, *(
myCandi + 1)->lane, preb, &(
myCandi->lastBlocked));