From 23a2265a018ca2cae58b2244b8a613dd4f394987 Mon Sep 17 00:00:00 2001 From: Lukas Connolly Date: Tue, 5 Nov 2024 22:54:04 +0100 Subject: [PATCH] REFACTOR: 145 - Remove duplicate bestTime variable in reconstructParetoOptimalSolutions. --- .../naviqore/raptor/router/LabelPostprocessor.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/ch/naviqore/raptor/router/LabelPostprocessor.java b/src/main/java/ch/naviqore/raptor/router/LabelPostprocessor.java index 4f17d71..ecc5fff 100644 --- a/src/main/java/ch/naviqore/raptor/router/LabelPostprocessor.java +++ b/src/main/java/ch/naviqore/raptor/router/LabelPostprocessor.java @@ -70,16 +70,12 @@ List reconstructParetoOptimalSolutions(List best Map targetStops, LocalDate referenceDate) { final List connections = new ArrayList<>(); - // this additional tracking variable is needed to filter out non pareto optimal connections from range raptor, - // as the pareto optimal solution for a later departure might have actually been fastest with more rounds where - // the final best solution has fewer rounds and is faster - int overallBestTime = timeType == TimeType.DEPARTURE ? INFINITY : -INFINITY; + int bestTime = timeType == TimeType.DEPARTURE ? INFINITY : -INFINITY; // iterate over all rounds for (QueryState.Label[] labels : bestLabelsPerRound) { QueryState.Label label = null; - int bestTime = timeType == TimeType.DEPARTURE ? INFINITY : -INFINITY; for (Map.Entry entry : targetStops.entrySet()) { int targetStopIdx = entry.getKey(); @@ -91,17 +87,15 @@ List reconstructParetoOptimalSolutions(List best if (timeType == TimeType.DEPARTURE) { int actualArrivalTime = currentLabel.targetTime() + targetStopWalkingTime; - if (actualArrivalTime < bestTime && actualArrivalTime < overallBestTime) { + if (actualArrivalTime < bestTime) { label = currentLabel; bestTime = actualArrivalTime; - overallBestTime = actualArrivalTime; } } else { int actualDepartureTime = currentLabel.targetTime() - targetStopWalkingTime; - if (actualDepartureTime > bestTime && actualDepartureTime > overallBestTime) { + if (actualDepartureTime > bestTime) { label = currentLabel; bestTime = actualDepartureTime; - overallBestTime = actualDepartureTime; } } }