Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions include/nigiri/routing/raptor/raptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,15 @@ struct raptor {

auto const target = to_idx(fp.target());

// EARLY PRUNING (Vias == 0 only): fps are sorted ascending by
// duration, so fp_target_time is monotone in fp.duration(). Once a
// footpath can no longer beat the per-round destination bound, every
// later (longer) footpath fails too — break out after this fp. The
// decision reuses the fp_target_time already computed in the inner
// loop, so it costs at most one extra comparison and never the
// redundant adjusted_transfer_time() of the previous approach.
auto ep_prune = false;

for (auto v = 0U; v != Vias + 1; ++v) {
auto const tmp_time = tmp_[i][v];
if (tmp_time == kInvalid) {
Expand Down Expand Up @@ -618,6 +627,13 @@ struct raptor {
update_time_at_dest(k, fp_target_time);
}
} else {
// If this footpath cannot beat the destination bound, no longer
// footpath can either (Vias == 0: fps sorted by duration).
if constexpr (Vias == 0) {
if (!is_better(fp_target_time, time_at_dest_[k])) {
ep_prune = true;
}
}
trace(
"┊ ├k={} NO FP UPDATE: {} [best={}] --{}--> {} "
"[best={}, time_at_dest={}]\n",
Expand All @@ -627,6 +643,10 @@ struct raptor {
to_unix(time_at_dest_[k]));
}
}

if (ep_prune) {
break;
}
}
});
}
Expand Down
Loading