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

@ -6,16 +6,17 @@ from typing import TYPE_CHECKING
import numpy as np
from inire.constants import TOLERANCE_LINEAR
from inire.geometry.collision import RoutingWorld
from inire.model import ObjectiveWeights
from inire.router.danger_map import DangerMap
if TYPE_CHECKING:
from collections.abc import Iterable, Mapping, Sequence
from typing import Protocol
from inire.geometry.collision import RoutingWorld
from inire.geometry.components import MoveKind
from inire.geometry.primitives import Port
from inire.router.danger_map import DangerMap
from inire.model import RoutingProblem
class ScoreableMove(Protocol):
@property
@ -219,3 +220,19 @@ class CostEvaluator:
)
current_port = component.end_port
return total
def build_native_cost_evaluator(problem: RoutingProblem, objective: ObjectiveWeights) -> CostEvaluator:
"""Score candidate paths using the original layout's obstacles and objective."""
danger = None
if objective.danger_weight and problem.static_obstacles:
danger = DangerMap(bounds=problem.bounds)
danger.precompute(list(problem.static_obstacles))
return CostEvaluator(
RoutingWorld(clearance=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,
)