Add conflict tracing and pair-local repair

This commit is contained in:
Jan Petykiewicz 2026-04-02 14:39:39 -07:00
commit 42e46c67e0

View file

@ -64,6 +64,7 @@ def _span_to_bounds(
class PathVerificationDetail:
report: RoutingReport
conflicting_net_ids: tuple[str, ...] = ()
component_conflicts: tuple[tuple[int, str, int], ...] = ()
@dataclass(frozen=True, slots=True)
@ -140,8 +141,19 @@ class RoutingWorld:
def _ensure_dynamic_grid(self) -> None:
self._dynamic_paths.ensure_grid()
def add_path(self, net_id: str, geometry: Sequence[Polygon], dilated_geometry: Sequence[Polygon]) -> None:
self._dynamic_paths.add_path(net_id, geometry, dilated_geometry=dilated_geometry)
def add_path(
self,
net_id: str,
geometry: Sequence[Polygon],
dilated_geometry: Sequence[Polygon],
component_indexes: Sequence[int] | None = None,
) -> None:
self._dynamic_paths.add_path(
net_id,
geometry,
dilated_geometry=dilated_geometry,
component_indexes=component_indexes,
)
def remove_path(self, net_id: str) -> None:
self._dynamic_paths.remove_path(net_id)
@ -651,7 +663,13 @@ class RoutingWorld:
frozen_net_ids=frozen_net_ids,
)
def verify_path_details(self, net_id: str, components: Sequence[ComponentResult]) -> PathVerificationDetail:
def verify_path_details(
self,
net_id: str,
components: Sequence[ComponentResult],
*,
capture_component_conflicts: bool = False,
) -> PathVerificationDetail:
if self.metrics is not None:
self.metrics.total_verify_path_report_calls += 1
static_collision_count = 0
@ -659,6 +677,7 @@ class RoutingWorld:
self_collision_count = 0
total_length = sum(component.length for component in components)
conflicting_net_ids: set[str] = set()
component_conflicts: set[tuple[int, str, int]] = set()
static_obstacles = self._static_obstacles
dynamic_paths = self._dynamic_paths
@ -682,7 +701,7 @@ class RoutingWorld:
static_collision_count += 1
if dynamic_paths.dilated:
for component in components:
for component_index, component in enumerate(components):
test_geometries = component.dilated_physical_geometry
component_hits = []
for new_geometry in test_geometries:
@ -695,6 +714,14 @@ class RoutingWorld:
tree_geometry = dynamic_paths.dilated[obj_id]
if _has_non_touching_overlap(new_geometry, tree_geometry):
component_hits.append(hit_net_id)
if capture_component_conflicts:
component_conflicts.add(
(
component_index,
hit_net_id,
dynamic_paths.component_indexes[obj_id],
)
)
break
if component_hits:
@ -715,6 +742,7 @@ class RoutingWorld:
total_length=total_length,
),
conflicting_net_ids=tuple(sorted(conflicting_net_ids)),
component_conflicts=tuple(sorted(component_conflicts)),
)
def verify_path_report(self, net_id: str, components: Sequence[ComponentResult]) -> RoutingReport: