example fixes and improvements
This commit is contained in:
parent
e11132b51d
commit
e2c91076f7
18 changed files with 336 additions and 144 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from shapely.geometry import Polygon
|
||||
|
||||
from inire import CongestionOptions, NetSpec, ObjectiveWeights, RoutingOptions, RoutingProblem, RoutingResult, SearchOptions, route
|
||||
from inire.geometry.components import BendCollisionModel, BendPhysicalGeometry
|
||||
from inire.geometry.primitives import Port
|
||||
from inire.utils.visualization import plot_routing_results
|
||||
|
||||
|
|
@ -8,10 +9,12 @@ from inire.utils.visualization import plot_routing_results
|
|||
def _route_scenario(
|
||||
bounds: tuple[float, float, float, float],
|
||||
obstacles: list[Polygon],
|
||||
bend_collision_type: str,
|
||||
netlist: dict[str, tuple[Port, Port]],
|
||||
widths: dict[str, float],
|
||||
*,
|
||||
bend_collision_type: BendCollisionModel = "arc",
|
||||
bend_proxy_geometry: BendCollisionModel | None = None,
|
||||
bend_physical_geometry: BendPhysicalGeometry | None = None,
|
||||
bend_clip_margin: float | None = None,
|
||||
) -> dict[str, RoutingResult]:
|
||||
problem = RoutingProblem(
|
||||
|
|
@ -23,6 +26,8 @@ def _route_scenario(
|
|||
search=SearchOptions(
|
||||
bend_radii=(10.0,),
|
||||
bend_collision_type=bend_collision_type,
|
||||
bend_proxy_geometry=bend_proxy_geometry,
|
||||
bend_physical_geometry=bend_physical_geometry,
|
||||
bend_clip_margin=bend_clip_margin,
|
||||
),
|
||||
objective=ObjectiveWeights(
|
||||
|
|
@ -40,29 +45,30 @@ def main() -> None:
|
|||
bounds = (-20, -20, 170, 170)
|
||||
obs_arc = Polygon([(40, 110), (60, 110), (60, 130), (40, 130)])
|
||||
obs_bbox = Polygon([(40, 60), (60, 60), (60, 80), (40, 80)])
|
||||
obs_clipped = Polygon([(40, 10), (60, 10), (60, 30), (40, 30)])
|
||||
obs_custom = Polygon([(40, 10), (60, 10), (60, 30), (40, 30)])
|
||||
custom_bend = Polygon([(0, -11), (11, -11), (11, 0), (9, 0), (9, -9), (0, -9)])
|
||||
|
||||
obstacles = [obs_arc, obs_bbox, obs_clipped]
|
||||
obstacles = [obs_arc, obs_bbox, obs_custom]
|
||||
netlist_arc = {"arc_model": (Port(10, 120, 0), Port(90, 140, 90))}
|
||||
netlist_bbox = {"bbox_model": (Port(10, 70, 0), Port(90, 90, 90))}
|
||||
netlist_clipped = {"clipped_model": (Port(10, 20, 0), Port(90, 40, 90))}
|
||||
netlist_custom = {"custom_geometry": (Port(10, 20, 0), Port(90, 40, 90))}
|
||||
|
||||
print("Routing Scenario 1 (Arc)...")
|
||||
res_arc = _route_scenario(bounds, obstacles, "arc", netlist_arc, {"arc_model": 2.0})
|
||||
res_arc = _route_scenario(bounds, obstacles, netlist_arc, {"arc_model": 2.0}, bend_collision_type="arc")
|
||||
print("Routing Scenario 2 (BBox)...")
|
||||
res_bbox = _route_scenario(bounds, obstacles, "bbox", netlist_bbox, {"bbox_model": 2.0})
|
||||
print("Routing Scenario 3 (Clipped BBox)...")
|
||||
res_clipped = _route_scenario(
|
||||
res_bbox = _route_scenario(bounds, obstacles, netlist_bbox, {"bbox_model": 2.0}, bend_collision_type="bbox")
|
||||
print("Routing Scenario 3 (Custom Manhattan Geometry With Matching Proxy)...")
|
||||
res_custom = _route_scenario(
|
||||
bounds,
|
||||
obstacles,
|
||||
"clipped_bbox",
|
||||
netlist_clipped,
|
||||
{"clipped_model": 2.0},
|
||||
bend_clip_margin=1.0,
|
||||
netlist_custom,
|
||||
{"custom_geometry": 2.0},
|
||||
bend_physical_geometry=custom_bend,
|
||||
bend_proxy_geometry=custom_bend,
|
||||
)
|
||||
|
||||
all_results = {**res_arc, **res_bbox, **res_clipped}
|
||||
all_netlists = {**netlist_arc, **netlist_bbox, **netlist_clipped}
|
||||
all_results = {**res_arc, **res_bbox, **res_custom}
|
||||
all_netlists = {**netlist_arc, **netlist_bbox, **netlist_custom}
|
||||
|
||||
fig, _ax = plot_routing_results(all_results, obstacles, bounds, netlist=all_netlists)
|
||||
fig.savefig("examples/06_bend_collision_models.png")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue