Add and measure a 57-board routing benchmark corpus
This commit is contained in:
parent
be3222e5ae
commit
2f2add98ec
1 changed files with 5892 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from functools import partial
|
||||
from time import perf_counter
|
||||
from collections.abc import Callable
|
||||
|
||||
|
|
@ -17,6 +18,7 @@ from inire import (
|
|||
RoutingResult,
|
||||
RoutingRunResult,
|
||||
SearchOptions,
|
||||
route,
|
||||
)
|
||||
from inire.geometry.collision import RoutingWorld
|
||||
from inire.geometry.primitives import Port
|
||||
|
|
@ -25,6 +27,8 @@ from inire.router._astar_types import AStarContext, AStarMetrics
|
|||
from inire.router._router import PathFinder
|
||||
from inire.router.cost import CostEvaluator
|
||||
from inire.router.danger_map import DangerMap
|
||||
from inire.tests.routing_benchmarks import BENCHMARK_CASES, EXTERNAL_BENCHMARK_CASES, FALLBACK_BENCHMARK_CASES, BenchmarkCase
|
||||
from inire.tests.terminal_bench_scenario import terminal_bench_options, terminal_bench_problem
|
||||
|
||||
_SEARCH_FIELDS = set(SearchOptions.__dataclass_fields__)
|
||||
_CONGESTION_FIELDS = set(CongestionOptions.__dataclass_fields__)
|
||||
|
|
@ -644,6 +648,19 @@ def run_example_09() -> ScenarioOutcome:
|
|||
return snapshot_example_09().as_outcome()
|
||||
|
||||
|
||||
def snapshot_terminal_bench_pr345() -> ScenarioSnapshot:
|
||||
problem = terminal_bench_problem()
|
||||
start = perf_counter()
|
||||
run = route(problem, options=terminal_bench_options())
|
||||
return _make_snapshot("terminal_bench_pr345", run.results_by_net, perf_counter() - start, run.metrics)
|
||||
|
||||
|
||||
def _snapshot_routing_benchmark(case: BenchmarkCase) -> ScenarioSnapshot:
|
||||
start = perf_counter()
|
||||
run = route(case.problem, options=case.options)
|
||||
return _make_snapshot(f"routing_benchmark_{case.name.replace('-', '_')}", run.results_by_net, perf_counter() - start, run.metrics)
|
||||
|
||||
|
||||
SCENARIOS: tuple[tuple[str, ScenarioRun], ...] = (
|
||||
("example_01_simple_route", run_example_01),
|
||||
("example_02_congestion_resolution", run_example_02),
|
||||
|
|
@ -671,6 +688,12 @@ SCENARIO_SNAPSHOTS: tuple[tuple[str, ScenarioSnapshotRun], ...] = (
|
|||
PERFORMANCE_SCENARIO_SNAPSHOTS: tuple[tuple[str, ScenarioSnapshotRun], ...] = (
|
||||
("example_07_large_scale_routing_no_warm_start", snapshot_example_07_no_warm_start),
|
||||
("example_07_large_scale_routing_no_warm_start_seed43", snapshot_example_07_no_warm_start_seed43),
|
||||
("terminal_bench_pr345", snapshot_terminal_bench_pr345),
|
||||
*(
|
||||
(f"routing_benchmark_{case.name.replace('-', '_')}", partial(_snapshot_routing_benchmark, case))
|
||||
for case in (*BENCHMARK_CASES, *FALLBACK_BENCHMARK_CASES, *EXTERNAL_BENCHMARK_CASES)
|
||||
if case.name != "terminal-bench"
|
||||
),
|
||||
)
|
||||
|
||||
TRACE_SCENARIO_RUNS: tuple[tuple[str, TraceScenarioRun], ...] = (
|
||||
|
|
|
|||
Loading…
Reference in a new issue