example fixes and improvements

This commit is contained in:
Jan Petykiewicz 2026-03-30 23:40:29 -07:00
commit e2c91076f7
18 changed files with 336 additions and 144 deletions

View file

@ -1,4 +1,7 @@
from inire import NetSpec, ObjectiveWeights, Port, RoutingOptions, RoutingProblem, SearchOptions, route
from inire import NetSpec, Port, RoutingOptions, RoutingProblem, SearchOptions
from inire.router._astar_types import AStarContext
from inire.router._router import PathFinder
from inire.router._stack import build_routing_stack
from inire.utils.visualization import plot_routing_results
@ -6,31 +9,31 @@ def main() -> None:
print("Running Example 03: Locked Paths...")
bounds = (0, -50, 100, 50)
options = RoutingOptions(
search=SearchOptions(bend_radii=(10.0,)),
objective=ObjectiveWeights(
bend_penalty=250.0,
sbend_penalty=500.0,
),
)
print("Routing initial net...")
results_a = route(
RoutingProblem(
stack = build_routing_stack(
problem=RoutingProblem(
bounds=bounds,
nets=(NetSpec("netA", Port(10, 0, 0), Port(90, 0, 0), width=2.0),),
),
options=options,
).results_by_net
options=RoutingOptions(search=SearchOptions(bend_radii=(10.0,))),
)
engine = stack.world
evaluator = stack.evaluator
results_a = stack.finder.route_all()
print("Routing detour net around locked path...")
results_b = route(
RoutingProblem(
bounds=bounds,
nets=(NetSpec("netB", Port(50, -20, 90), Port(50, 20, 90), width=2.0),),
static_obstacles=results_a["netA"].locked_geometry,
for polygon in results_a["netA"].locked_geometry:
engine.add_static_obstacle(polygon)
results_b = PathFinder(
AStarContext(
evaluator,
RoutingProblem(
bounds=bounds,
nets=(NetSpec("netB", Port(50, -20, 90), Port(50, 20, 90), width=2.0),),
),
RoutingOptions(search=SearchOptions(bend_radii=(10.0,))),
),
options=options,
).results_by_net
).route_all()
results = {**results_a, **results_b}
fig, ax = plot_routing_results(results, [], bounds)