Skip to content

Commit

Permalink
FIX: 145 - Make getActualBestTime actually return actual best time.
Browse files Browse the repository at this point in the history
  • Loading branch information
clukas1 committed Nov 5, 2024
1 parent 1fe7f69 commit d3895b1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/java/ch/naviqore/raptor/router/QueryState.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,22 @@ int getComparableBestTime(int stopIdx) {
* different label types (transfer vs. route), as the same stop transfer time is not considered.
*/
int getActualBestTime(int stopIdx) {
for (int i = bestLabelsPerRound.size() - 1; i >= 0; i--) {
Label label = bestLabelsPerRound.get(i)[stopIdx];
int best_time = (timeType == TimeType.DEPARTURE) ? INFINITY : -INFINITY;

// because range raptor potentially fills target times in higher rounds which are not the best solutions, every
// round has to be looked at.
for (Label[] labels : bestLabelsPerRound) {
Label label = labels[stopIdx];
if (label != null) {
return label.targetTime;
if (timeType == TimeType.DEPARTURE) {
best_time = Math.min(best_time, label.targetTime);
} else {
best_time = Math.max(best_time, label.targetTime);
}
}
}

return (timeType == TimeType.DEPARTURE) ? INFINITY : -INFINITY;
return best_time;
}

/**
Expand Down

0 comments on commit d3895b1

Please sign in to comment.