rework structure of everything
This commit is contained in:
parent
dcc4d6436c
commit
941d3e01df
64 changed files with 3819 additions and 3559 deletions
|
|
@ -1,42 +1,37 @@
|
|||
from inire.geometry.collision import CollisionEngine
|
||||
from inire.geometry.primitives import Port
|
||||
from inire.router.astar import AStarContext, AStarMetrics
|
||||
from inire.router.cost import CostEvaluator
|
||||
from inire.router.danger_map import DangerMap
|
||||
from inire.router.pathfinder import PathFinder
|
||||
from inire import NetSpec, ObjectiveWeights, Port, RoutingOptions, RoutingProblem, SearchOptions, route
|
||||
from inire.utils.visualization import plot_routing_results
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print("Running Example 03: Locked Paths...")
|
||||
print("Running Example 03: Locked Routes...")
|
||||
|
||||
# 1. Setup Environment
|
||||
bounds = (0, -50, 100, 50)
|
||||
engine = CollisionEngine(clearance=2.0)
|
||||
danger_map = DangerMap(bounds=bounds)
|
||||
danger_map.precompute([])
|
||||
|
||||
evaluator = CostEvaluator(engine, danger_map, bend_penalty=250.0, sbend_penalty=500.0)
|
||||
context = AStarContext(evaluator, bend_radii=[10.0])
|
||||
metrics = AStarMetrics()
|
||||
pf = PathFinder(context, metrics)
|
||||
|
||||
# 2. Route Net A and 'Lock' it
|
||||
# Net A is a straight path blocking the direct route for Net B
|
||||
options = RoutingOptions(
|
||||
search=SearchOptions(bend_radii=(10.0,)),
|
||||
objective=ObjectiveWeights(
|
||||
bend_penalty=250.0,
|
||||
sbend_penalty=500.0,
|
||||
),
|
||||
)
|
||||
print("Routing initial net...")
|
||||
netlist_a = {"netA": (Port(10, 0, 0), Port(90, 0, 0))}
|
||||
results_a = pf.route_all(netlist_a, {"netA": 2.0})
|
||||
|
||||
# Locking prevents Net A from being removed or rerouted during NC iterations
|
||||
engine.lock_net("netA")
|
||||
print("Initial net locked as static obstacle.")
|
||||
results_a = route(
|
||||
RoutingProblem(
|
||||
bounds=bounds,
|
||||
nets=(NetSpec("netA", Port(10, 0, 0), Port(90, 0, 0), width=2.0),),
|
||||
),
|
||||
options=options,
|
||||
).results_by_net
|
||||
|
||||
# 3. Route Net B (forced to detour)
|
||||
print("Routing detour net around locked path...")
|
||||
netlist_b = {"netB": (Port(50, -20, 90), Port(50, 20, 90))}
|
||||
results_b = pf.route_all(netlist_b, {"netB": 2.0})
|
||||
results_b = route(
|
||||
RoutingProblem(
|
||||
bounds=bounds,
|
||||
nets=(NetSpec("netB", Port(50, -20, 90), Port(50, 20, 90), width=2.0),),
|
||||
locked_routes={"netA": results_a["netA"].as_locked_route()},
|
||||
),
|
||||
options=options,
|
||||
).results_by_net
|
||||
|
||||
# 4. Visualize
|
||||
results = {**results_a, **results_b}
|
||||
fig, ax = plot_routing_results(results, [], bounds)
|
||||
fig.savefig("examples/03_locked_paths.png")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue