47 #ifdef CHECK_MEMORY_LEAKS
49 #endif // CHECK_MEMORY_LEAKS
52 #ifdef DEBUG_VEHICLE_GUI_SELECTION
63 : myAllowsSwap(allowSwap) {
64 assert(lanes->size() > 1);
68 for (std::vector<MSLane*>::iterator lane = lanes->begin(); lane != lanes->end(); ++lane) {
73 ce.
veh = (*lane)->myVehicles.rbegin();
94 bool haveChanged =
change();
108 ce->firstBlocked = 0;
112 if (vehicles.empty()) {
113 ce->veh = vehicles.rend();
117 ce->veh = vehicles.rbegin();
118 if (vehicles.size() == 1) {
122 ce->follow = *(vehicles.rbegin() + 1);
138 #ifdef DEBUG_VEHICLE_GUI_SELECTION
153 const std::vector<MSVehicle::LaneQ>& preb = vehicle->
getBestLanes();
156 ((std::vector<MSVehicle::LaneQ>&) preb)[i].occupation =
myChanger[i].dens + preb[i].nextOccupation;
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()) {
241 assert(bla == prohibitor);
242 target->lane->myTmpVehicles.erase(i);
244 target->hoppedVeh = vehicle;
245 target->lane->myTmpVehicles.insert(target->lane->myTmpVehicles.begin(), vehicle);
246 myCandi->hoppedVeh = prohibitor;
247 myCandi->lane->myTmpVehicles.insert(
myCandi->lane->myTmpVehicles.begin(), prohibitor);
288 to->hoppedVeh = vehicle;
291 to->lane->myTmpVehicles.insert(to->lane->myTmpVehicles.begin(), vehicle);
294 from->lane->myTmpVehicles.insert(from->lane->myTmpVehicles.begin(), vehicle);
297 to->dens += to->hoppedVeh->getVehicleType().getLengthWithGap();
301 std::pair<MSVehicle* const, SUMOReal>
306 MSLane* targetLane = target->lane;
312 MSLinkCont::const_iterator link = targetLane->
succLinkSec(*
veh(
myCandi), 1, *targetLane, bestLaneConts);
314 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
316 MSLane* nextLane = (*link)->getLane();
318 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
322 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
328 return std::pair<MSVehicle* const, SUMOReal>(leader,
MAX2((
SUMOReal) 0, gap));
332 return std::pair<MSVehicle* const, SUMOReal>(leader,
MAX2((
SUMOReal) 0, gap));
337 std::pair<MSVehicle* const, SUMOReal>
342 if (target->hoppedVeh != 0) {
343 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
345 neighLead = target->hoppedVeh;
348 if (neighLead == 0) {
349 MSLane* targetLane = target->lane;
358 return std::pair<MSVehicle* const, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
361 return target->lane->getLeaderOnConsecutive(dist, seen, speed, *
veh(
myCandi), bestLaneConts);
369 std::pair<MSVehicle* const, SUMOReal>
373 if (target->hoppedVeh != 0) {
374 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
376 neighFollow = target->hoppedVeh;
379 if (neighFollow == 0) {
380 SUMOReal speed = target->lane->getSpeedLimit();
391 return std::pair<MSVehicle* const, SUMOReal>(neighFollow, candi->
getPositionOnLane() - candi->
getVehicleType().
getLength() - neighFollow->getPositionOnLane() - neighFollow->getVehicleType().getMinGap());
405 if (!vehHasChanged) {
436 ce->lane->swapAfterLaneChange(t);
455 assert(
veh(ce) != 0);
456 assert(
veh(max) != 0);
457 if (
veh(max)->getPositionOnLane() <
veh(ce)->getPositionOnLane()) {
462 assert(
veh(max) != 0);
469 const std::pair<MSVehicle* const, SUMOReal>& leader,
470 const std::vector<MSVehicle::LaneQ>& preb)
const {
481 if (neighFollow.first != 0 && neighFollow.second < 0) {
484 if (neighLead.first != 0 && neighLead.second < 0) {
488 if (neighFollow.first != 0) {
496 if (neighLead.first != 0) {
505 laneOffset, msg, blocked, leader, neighLead, neighFollow, *(target->lane), preb, &(
myCandi->lastBlocked), &(
myCandi->firstBlocked));