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;
235 if (target->hoppedVeh != 0) {
236 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
255 MSLane::VehCont::iterator i = find(target->lane->myTmpVehicles.begin(), target->lane->myTmpVehicles.end(), prohibitor);
256 if (i != target->lane->myTmpVehicles.end()) {
258 assert(bla == prohibitor);
259 target->lane->myTmpVehicles.erase(i);
261 target->hoppedVeh = vehicle;
262 target->lane->myTmpVehicles.push_front(vehicle);
263 myCandi->hoppedVeh = prohibitor;
264 myCandi->lane->myTmpVehicles.push_front(prohibitor);
299 std::pair<MSVehicle* const, SUMOReal>
304 MSLane* targetLane = target->lane;
310 MSLinkCont::const_iterator link = targetLane->
succLinkSec(*
veh(
myCandi), 1, *targetLane, bestLaneConts);
312 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
314 MSLane* nextLane = (*link)->getLane();
316 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
320 return std::pair<MSVehicle*, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
326 return std::pair<MSVehicle* const, SUMOReal>(leader,
MAX2((
SUMOReal) 0, gap));
330 return std::pair<MSVehicle* const, SUMOReal>(leader,
MAX2((
SUMOReal) 0, gap));
335 std::pair<MSVehicle* const, SUMOReal>
340 if (target->hoppedVeh != 0) {
341 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
343 neighLead = target->hoppedVeh;
346 if (neighLead == 0) {
347 MSLane* targetLane = target->lane;
357 return std::pair<MSVehicle* const, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
359 return target->lane->getLeaderOnConsecutive(dist, seen, speed, *
veh(
myCandi), bestLaneConts);
367 std::pair<MSVehicle* const, SUMOReal>
371 if (target->hoppedVeh != 0) {
372 SUMOReal hoppedPos = target->hoppedVeh->getPositionOnLane();
374 neighFollow = target->hoppedVeh;
377 if (neighFollow == 0) {
378 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>& rLead,
468 const std::pair<MSVehicle* const, SUMOReal>& rFollow,
469 const std::vector<MSVehicle::LaneQ>& preb)
const {
477 if (rFollow.first != 0 && rFollow.second < 0) {
480 if (rLead.first != 0 && rLead.second < 0) {
484 if (rFollow.first != 0) {
492 if (rLead.first != 0) {
501 msg, blocked, leader, rLead, rFollow, *(
myCandi - 1)->lane, preb, &(
myCandi->lastBlocked));
507 const std::pair<MSVehicle* const, SUMOReal>& rLead,
508 const std::pair<MSVehicle* const, SUMOReal>& rFollow,
509 const std::vector<MSVehicle::LaneQ>& preb)
const {
517 if (rFollow.first != 0 && rFollow.second < 0) {
520 if (rLead.first != 0 && rLead.second < 0) {
524 if (rFollow.first != 0) {
531 if (rLead.first != 0) {
539 msg, blocked, leader, rLead, rFollow, *(
myCandi + 1)->lane, preb, &(
myCandi->lastBlocked));