From 3799804cf34409ec27c514a3c104eb40c511e214 Mon Sep 17 00:00:00 2001 From: nkuehnel Date: Mon, 27 May 2024 18:00:44 +0200 Subject: [PATCH] address review comments --- .../DefaultInsertionCostCalculator.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/insertion/DefaultInsertionCostCalculator.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/insertion/DefaultInsertionCostCalculator.java index a44dc5d24ff..14ec7ceb3d0 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/insertion/DefaultInsertionCostCalculator.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/insertion/DefaultInsertionCostCalculator.java @@ -74,26 +74,31 @@ public double calculate(DrtRequest drtRequest, Insertion insertion, DetourTimeIn // all stops after the new (potential) pickup but before the new dropoff // are delayed by pickupDetourTimeLoss - double detour = detourTimeInfo.pickupDetourInfo.pickupTimeLoss; + double timeLoss = detourTimeInfo.pickupDetourInfo.pickupTimeLoss; if(vEntry.stops != null) { for (int s = insertion.pickup.index; s < vEntry.stops.size(); s++) { + if(timeLoss == 0) { + continue; + } Waypoint.Stop stop = vEntry.stops.get(s); // passengers are being dropped off == may be close to arrival if (!stop.task.getDropoffRequests().isEmpty()) { double nextArrival = stop.getArrivalTime(); double departureTime = insertion.vehicleEntry.start.getDepartureTime(); - //arrival is very soon - if (nextArrival - departureTime < constraintsSet.allowDetourBeforeArrivalThreshold && - detour > 0) { + if (nextArrival - departureTime < constraintsSet.allowDetourBeforeArrivalThreshold) { + //arrival is too soon to allow further diversion return INFEASIBLE_SOLUTION_COST; - } else { + } else if (nextArrival - departureTime >= constraintsSet.allowDetourBeforeArrivalThreshold) { // all following stops are above the threshold break; } } if (s == insertion.dropoff.index) { // all stops after the new (potential) dropoff are delayed by totalTimeLoss - detour = detourTimeInfo.getTotalTimeLoss(); + timeLoss = detourTimeInfo.getTotalTimeLoss(); + if(timeLoss == 0) { + break; + } } } }