Build traces on demand and share routing fixture setup

This commit is contained in:
Jan Petykiewicz 2026-11-26 23:00:23 -08:00
commit 6608e18ef5

View file

@ -40,8 +40,7 @@ from inire.router._routing_policy import (
from inire.router._seed_materialization import materialize_path_seed
from inire.router._stack import route_once
from inire.router._topology import plan_corridors
from inire.router.cost import CostEvaluator, weighted_path_length
from inire.router.danger_map import DangerMap
from inire.router.cost import build_native_cost_evaluator, weighted_path_length
from inire.seeds import SBendSeed
if TYPE_CHECKING:
@ -54,6 +53,7 @@ if TYPE_CHECKING:
from inire.results import RouteMetrics, RoutingOperation, RoutingResult, RoutingRunResult
from inire.router._routing_policy import Trial
from inire.router._topology import Corridor
from inire.router.cost import CostEvaluator
from inire.seeds import PathSeed
@ -148,19 +148,7 @@ class _AutomaticRun:
if self.length_weights is not None:
return weighted_path_length(result.path, self.length_weights)
if self.evaluator is None:
objective = self.options.objective
danger = None
if objective.danger_weight and self.problem.static_obstacles:
danger = DangerMap(bounds=self.problem.bounds)
danger.precompute(list(self.problem.static_obstacles))
self.evaluator = CostEvaluator(
RoutingWorld(clearance=self.problem.clearance),
danger,
unit_length_cost=objective.unit_length_cost,
bend_penalty=objective.bend_penalty,
sbend_penalty=objective.sbend_penalty,
danger_weight=objective.danger_weight,
)
self.evaluator = build_native_cost_evaluator(self.problem, self.options.objective)
return self.evaluator.path_cost(result.path[0].start_port, result.path)
def _trial(self, run: RoutingRunResult, stage: RoutingStage) -> Trial: