Make retry exports optional and report benchmark placement and selection

This commit is contained in:
Jan Petykiewicz 2026-12-02 00:55:43 -08:00
commit f6e7bac4c5

View file

@ -61,6 +61,7 @@ class RunSample:
bundle_rejection: str | None = None
bundle_duration_s: float | None = None
selected_stage: int = 0
selected_attempt: int | None = None
capacity_limit: CapacityLimit | None = None
planner_rejections: tuple[str, ...] = ()
port_conflicts: tuple[tuple[str, str], ...] = ()
@ -116,7 +117,17 @@ def _order_trials(problem: RoutingProblem, options: RoutingOptions, strategy: st
def _measure(case: BenchmarkCase, options: RoutingOptions, strategy: str) -> RunSample:
board = box(*case.problem.bounds)
attempt_options: list[RoutingOptions] = []
run_route = partial(_route, run_router=partial(_dispatch_route, attempt_callback=attempt_options.append))
selected_attempt: int | None = None
def select_attempt(index: int) -> None:
nonlocal selected_attempt
selected_attempt = index
dispatch = partial(
_dispatch_route, attempt_callback=attempt_options.append,
selected_attempt_callback=select_attempt if strategy in ("guide", "seed") else None,
)
run_route = partial(_route, run_router=dispatch)
run_worker = partial(route_once, attempt_callback=attempt_options.append)
def measure_direct(problem: RoutingProblem, policy: str) -> tuple[RoutingRunResult, list[Trial]]:
@ -203,6 +214,7 @@ def _measure(case: BenchmarkCase, options: RoutingOptions, strategy: str) -> Run
bundle_rejection=bundle_rejection,
bundle_duration_s=bundle_duration,
selected_stage=next(i for i, trial in enumerate(trials) if trial is best),
selected_attempt=selected_attempt,
)