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
145 const std::vector<MSVehicle::LaneQ>& preb = vehicle->
getBestLanes();
148 ((std::vector<MSVehicle::LaneQ>&) preb)[i].occupation =
myChanger[i].dens + preb[i].nextOccupation;
162 bool changingAllowed1 = (state1 &
LCA_BLOCKED) == 0;
164 if ((state1 &
LCA_RIGHT) != 0 && changingAllowed1) {
169 (
myCandi - 1)->hoppedVeh = vehicle;
170 (
myCandi - 1)->lane->myTmpVehicles.push_front(vehicle);
172 myCandi->lane->leftByLaneChange(vehicle);
174 (
myCandi - 1)->lane->enteredByLaneChange(vehicle);
177 (
myCandi - 1)->dens += (
myCandi - 1)->hoppedVeh->getVehicleType().getLengthWithGap();
180 if ((state1 & LCA_RIGHT) != 0 && (state1 & LCA_URGENT) != 0) {
181 (
myCandi - 1)->lastBlocked = vehicle;
192 state2 =
change2left(leader, lLead, lFollow, preb);
196 bool changingAllowed2 = (state2 &
LCA_BLOCKED) == 0;
199 if ((state2 &
LCA_LEFT) != 0 && changingAllowed2) {
207 myCandi->lane->leftByLaneChange(vehicle);
209 (
myCandi + 1)->lane->enteredByLaneChange(vehicle);
212 (
myCandi + 1)->dens += (
myCandi + 1)->hoppedVeh->getVehicleType().getLengthWithGap();
215 if ((state2 & LCA_LEFT) != 0 && (state2 & LCA_URGENT) != 0) {
216 (
myCandi + 1)->lastBlocked = vehicle;
240 if (target->hoppedVeh != 0) {
241 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
260 MSLane::VehCont::iterator i = find(target->lane->myTmpVehicles.begin(), target->lane->myTmpVehicles.end(), prohibitor);
261 if (i != target->lane->myTmpVehicles.end()) {
263 assert(bla == prohibitor);
264 target->lane->myTmpVehicles.erase(i);
266 target->hoppedVeh = vehicle;
267 target->lane->myTmpVehicles.push_front(vehicle);
268 myCandi->hoppedVeh = prohibitor;
269 myCandi->lane->myTmpVehicles.push_front(prohibitor);
304 std::pair<MSVehicle* const, SUMOReal>
309 MSLane* targetLane = target->lane;
315 MSLinkCont::const_iterator link = targetLane->
succLinkSec(*
veh(
myCandi), 1, *targetLane, bestLaneConts);
317 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
319 MSLane* nextLane = (*link)->getLane();
321 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
325 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
331 return std::pair<MSVehicle* const, SUMOReal>(leader,
MAX2((
SUMOReal) 0, gap));
335 return std::pair<MSVehicle* const, SUMOReal>(leader,
MAX2((
SUMOReal) 0, gap));
340 std::pair<MSVehicle* const, SUMOReal>
345 if (target->hoppedVeh != 0) {
346 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
348 neighLead = target->hoppedVeh;
351 if (neighLead == 0) {
352 MSLane* targetLane = target->lane;
361 return std::pair<MSVehicle* const, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
364 return target->lane->getLeaderOnConsecutive(dist, seen, speed, *
veh(
myCandi), bestLaneConts);
372 std::pair<MSVehicle* const, SUMOReal>
376 if (target->hoppedVeh != 0) {
377 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
379 neighFollow = target->hoppedVeh;
382 if (neighFollow == 0) {
383 SUMOReal speed = target->lane->getSpeedLimit();
394 return std::pair<MSVehicle* const, SUMOReal>(neighFollow, candi->
getPositionOnLane() - candi->
getVehicleType().
getLength() - neighFollow->getPositionOnLane() - neighFollow->getVehicleType().getMinGap());
408 if (!vehHasChanged) {
439 ce->lane->swapAfterLaneChange(t);
458 assert(
veh(ce) != 0);
459 assert(
veh(max) != 0);
460 if (
veh(max)->getPositionOnLane() <
veh(ce)->getPositionOnLane()) {
465 assert(
veh(max) != 0);
472 const std::pair<MSVehicle* const, SUMOReal>& rLead,
473 const std::pair<MSVehicle* const, SUMOReal>& rFollow,
474 const std::vector<MSVehicle::LaneQ>& preb)
const {
482 if (rFollow.first != 0 && rFollow.second < 0) {
485 if (rLead.first != 0 && rLead.second < 0) {
489 if (rFollow.first != 0) {
497 if (rLead.first != 0) {
506 msg, blocked, leader, rLead, rFollow, *(
myCandi - 1)->lane, preb, &(
myCandi->lastBlocked));
512 const std::pair<MSVehicle* const, SUMOReal>& rLead,
513 const std::pair<MSVehicle* const, SUMOReal>& rFollow,
514 const std::vector<MSVehicle::LaneQ>& preb)
const {
522 if (rFollow.first != 0 && rFollow.second < 0) {
525 if (rLead.first != 0 && rLead.second < 0) {
529 if (rFollow.first != 0) {
536 if (rLead.first != 0) {
544 msg, blocked, leader, rLead, rFollow, *(
myCandi + 1)->lane, preb, &(
myCandi->lastBlocked));