misc cleanup and tuning

This commit is contained in:
Jan Petykiewicz 2026-03-07 19:31:51 -08:00
commit 07d079846b

View file

@ -46,14 +46,20 @@ class CostEvaluator:
start_port: Port | None = None,
) -> float:
"""Calculate the cost of a single move (Straight, Bend, SBend)."""
_ = net_width # Unused, kept for API compatibility
total_cost = 0.0
dilation = self.collision_engine.clearance / 2.0
# Strict collision check
for poly in geometry:
if self.collision_engine.is_collision(poly, net_width, start_port=start_port, end_port=end_port):
# Buffer once for both hard collision and congestion check
dilated_poly = poly.buffer(dilation)
if self.collision_engine.is_collision_prebuffered(dilated_poly, start_port=start_port, end_port=end_port):
return 1e9 # Massive cost for hard collisions
# Negotiated Congestion Cost
overlaps = self.collision_engine.count_congestion(poly, net_id)
overlaps = self.collision_engine.count_congestion_prebuffered(dilated_poly, net_id)
total_cost += overlaps * self.congestion_penalty
# Proximity cost from Danger Map