TrajectoryCellStatistics
TrajectoryCellStatistics(group_by: list[str] | None, utilities: TrajectoryUtilitiesConfiguration | None) -> NonePer-cell exploration and outcome bookkeeping shared by trajectory selection and utilities.
Owns every "one entry per cell" structure the store maintains: visit/reach/successor counts (plain per-cell counters) and the competence, cost-aware, and successor-route-value tables (EMA/min/max aggregated TrajectoryGraphValueTables, built from the configured utilities).
Initialize per-cell statistics, building the tables the configured utilities need.
Parameters:
group_by(list[str] | None) – Cell-key fields, orNoneto key by every recorded value.utilities(TrajectoryUtilitiesConfiguration | None) – The trajectory utilities configuration, used to decide which of the competence/cost-aware/successor-route-value tables to build.
Methods
cell_key
cell_key(values: dict[str, int]) -> TrajectoryKeyBuild the cell key for a set of recorded values.
Parameters:
values(dict[str, int]) – The recorded values (for example a segment's start or end values).
Returns:
TrajectoryKey– The cell key, restricted togroup_byfields when configured.
cell_successor_counts
cell_successor_counts() -> dict[TrajectoryKey, dict[TrajectoryKey, int]]Return per-cell distinct successor counts keyed by cell.
cell_successor_counts_view
cell_successor_counts_view() -> dict[TrajectoryKey, dict[TrajectoryKey, int]]cell_visit_counts
cell_visit_counts() -> dict[TrajectoryKey, int]cell_visit_counts_view
cell_visit_counts_view() -> dict[TrajectoryKey, int]competence_tables_view
competence_tables_view() -> dict[str, TrajectoryGraphValueTable]Return the live per-utility competence tables; callers must not mutate them.
load_state_dict
load_state_dict(state: dict[str, Any]) -> Nonemidpoint_reach_counts
midpoint_reach_counts() -> dict[TrajectoryKey, dict[TrajectoryKey, int]]Return per-start downstream reach counts keyed by midpoint cell.
midpoint_reach_counts_view
midpoint_reach_counts_view() -> dict[TrajectoryKey, dict[TrajectoryKey, int]]record_cell_transitions
record_cell_transitions(cell_values: list[dict[str, int]]) -> NoneRecord the distinct immediate successor cells observed along one episode's cell sequence.
Each cell -> next cell transition (self-transitions ignored) is counted at most once per episode, so a cell's distinct-successor count measures how many different outgoing branches the policy has ever taken from it -- the signal branch-novelty exploration uses to find the un-taken branch at a high-traffic cell.
Parameters:
cell_values(list[dict[str, int]]) – The episode's cells in visit order (for example segment start then end values).
record_cell_visit
record_cell_visit(values: dict[str, int]) -> Nonerecord_midpoint_reach
record_midpoint_reach(start_values: dict[str, int], downstream_values: list[dict[str, int]]) -> NoneRecord which downstream cells were reached from one midpoint-start cell.
Each downstream cell is counted at most once per episode so repeated revisits within the same suffix do not exaggerate one start cell's local reachability.
Parameters:
start_values(dict[str, int]) – The midpoint-start cell values.downstream_values(list[dict[str, int]]) – The downstream segment end values reached during the episode.
record_route_cost
record_route_cost(utility_key: str, cell_values: list[dict[str, int]], cost: float) -> NoneRecord one winning route's cost against every cell on it, for a cost-aware utility.
The table aggregates with min, so each cell remembers the cheapest winning route that has passed through it; a later, shorter winning route lowers the recorded cost and the cell's cost-aware exploration score falls automatically.
Parameters:
utility_key(str) – The cost-aware utility this cost feeds.cell_values(list[dict[str, int]]) – The winning route's cells (deduplicated internally).cost(float) – The route's cost (higher = costlier, for example air consumed or route length).
record_start_outcome
record_start_outcome(utility_key: str, start_values: dict[str, int], success: bool) -> NoneRecord one completed episode's success outcome under its start cell.
Parameters:
utility_key(str) – The competence utility this outcome feeds.start_values(dict[str, int]) – The episode's start cell values.success(bool) – Whether the episode counted as a success for this utility.
record_successor_route_value
record_successor_route_value(start_values: dict[str, int], value: float) -> NoneRecord the route value one episode's first hop reached from a start cell.
Parameters:
start_values(dict[str, int]) – The episode's start cell values.value(float) – The route value of the first hop's destination cell.
route_cost_tables_view
route_cost_tables_view() -> dict[str, TrajectoryGraphValueTable]start_cell_success_rate
start_cell_success_rate(utility_key: str, start_values: dict[str, int]) -> float | NoneGet one competence utility's success rate for a start cell.
Parameters:
utility_key(str) – The competence utility.start_values(dict[str, int]) – The start cell values.
Returns:
float | None– The EMA success rate, orNonewhen the cell has no outcomes yet.
state_dict
state_dict() -> dict[str, Any]successor_route_value
successor_route_value(start_values: dict[str, int]) -> float | NoneGet the best one-hop successor route value seen from a start cell.
Parameters:
start_values(dict[str, int]) – The start cell values.
Returns:
float | None– The max first-hop route value, orNonewhen no hop has been recorded.