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; } } }