Fix fabrication verification and routing diagnostics follow-up

This commit is contained in:
Jan Petykiewicz 2026-11-29 00:09:54 -08:00
commit cea23ef1b4

View file

@ -1,4 +1,7 @@
from inire import NetSpec, ObjectiveWeights, Port, RoutingOptions, RoutingProblem, SearchOptions, TopologyOptions, route
from dataclasses import replace
from inire import NetSpec, ObjectiveWeights, Port, RefinementOptions, RoutingOptions, RoutingProblem, SearchOptions, TopologyOptions, route
from inire.layout import route_profiles, verify_export_grid
from inire.utils.visualization import plot_routing_results
@ -8,30 +11,28 @@ def main() -> None:
bounds = (0, -50, 100, 50)
options = RoutingOptions(
search=SearchOptions(bend_radii=(10.0,)),
# Isolate the lattice detour and use the fixed net only for clearance checks.
# Isolate the lattice detour.
objective=ObjectiveWeights(danger_weight=0.0),
topology=TopologyOptions(mode="off"),
)
print("Routing initial net...")
problem_a = RoutingProblem(
bounds=bounds,
nets=(NetSpec("netA", Port(10, 0, 0), Port(90, 0, 0)),),
)
results_a = route(problem_a, options=options).results_by_net
fixed = results_a["netA"]
fixed_net = NetSpec("netA", Port(10, 0, 0), Port(90, 0, 0))
detour_net = NetSpec("netB", Port(50, -20, 90), Port(50, 20, 90))
problem = RoutingProblem(bounds, (fixed_net, detour_net))
fixed = route(replace(problem, nets=(fixed_net,)), options=options).results_by_net["netA"]
assert fixed.is_valid
print("Routing detour net around locked path...")
problem_b = RoutingProblem(
bounds=bounds,
nets=(NetSpec("netB", Port(50, -20, 90), Port(50, 20, 90)),),
static_obstacles=fixed.locked_geometry,
replay = replace(
options, search=replace(options.search, node_limit=0), refinement=RefinementOptions(enabled=False),
)
results_b = route(problem_b, options=options).results_by_net
assert results_b["netB"].is_valid
problem = replace(problem, initial_paths={"netA": fixed.as_seed()})
results = route_profiles(problem, [(("netA",), replay), (("netB",), options)])
export = verify_export_grid(problem, results, grid=1)
if not export.is_valid:
raise ValueError(export.reports_by_net)
results = {**results_a, **results_b}
fig, _ax = plot_routing_results(results, [], bounds)
fig.savefig("examples/03_locked_paths.png")
print("Saved plot to examples/03_locked_paths.png")