Skip to content

BestRouteArchive ​

python
BestRouteArchive(repository: TrajectoryRepository, capacity: int) -> None

Bounded, leak-free holder of the highest-priority full routes.

A side structure separate from the per-cell retention buckets. It holds its own whole-path repository reference to each admitted route, so a best route's bytes survive even after every per-cell bucket entry referencing it has been evicted by ordinary route_quality churn. Capacity bounds extra memory: admitting a better route when full evicts and releases the worst, so the archive pins at most capacity shared routes and nothing is held indefinitely. The retention hot path is untouched, so common start cells never throttle the archive.

Invariant (regression-locked by test_best_route_archived_and_bc_clones_slice): a recorded route whose priority beats the worst archived route is retained and remains materialisable until a higher-priority route displaces it, regardless of bucket churn. A win — a huge value in the route-level priority score — therefore reaches and stays in the archive without any is_win flag.

Initialize the archive.

Parameters:

  • repository (TrajectoryRepository) – The repository whose routes are retained/released.
  • capacity (int) – The maximum number of routes to keep; <= 0 disables the archive.

Source

Properties ​

capacity ​

python
capacity: int

Get the maximum number of routes the archive retains.

Source

count ​

python
count: int

Get the number of routes currently archived.

Source

max_priority ​

python
max_priority: float | None

Get the highest archived priority, or None when the archive is empty.

Source

Methods ​

admit ​

python
admit(trajectory_id: int, priority: float, group: Any = 0) -> None

Offer one freshly recorded route to the archive.

Parameters:

  • trajectory_id (int) – The route's trajectory id.
  • priority (float) – The route-level priority score.
  • group (Any) – The route's archive group (for example cavern); each group keeps its own top-capacity.

Source

clear ​

python
clear() -> None

Release every retained route reference and empty the archive.

Source

priorities ​

python
priorities() -> dict[int, float]

Return each archived route's priority keyed by trajectory id.

Source

rebuild_from_repository ​

python
rebuild_from_repository(group_of: Callable[[int], Any] | None = None) -> None

Rebuild the archive as the top-capacity routes by stored priority, per group.

Parameters:

  • group_of (Callable[[int], Any] | None) – Maps a trajectory id to its archive group; None puts every route in one group (the original global top-capacity behaviour).

Source

route_ids ​

python
route_ids() -> list[int]

Return the trajectory ids of every archived route.

Source