Initial buildout
This commit is contained in:
parent
34615f3aac
commit
84b76d0f6a
1 changed files with 25658 additions and 25 deletions
72
examples/08_custom_bend_geometry.py
Normal file
72
examples/08_custom_bend_geometry.py
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
from shapely.geometry import Polygon, box
|
||||
|
||||
from inire import CongestionOptions, NetSpec, RoutingOptions, RoutingProblem, SearchOptions, route
|
||||
from inire.geometry.components import BendCollisionModel, BendPhysicalGeometry
|
||||
from inire.geometry.primitives import Port
|
||||
from inire.utils.visualization import plot_routing_results
|
||||
|
||||
|
||||
def _run_session(
|
||||
bounds: tuple[float, float, float, float],
|
||||
net_id: str,
|
||||
start: Port,
|
||||
target: Port,
|
||||
*,
|
||||
bend_collision_type: BendCollisionModel = "arc",
|
||||
bend_proxy_geometry: BendCollisionModel | None = None,
|
||||
bend_physical_geometry: BendPhysicalGeometry | None = None,
|
||||
) -> dict[str, object]:
|
||||
problem = RoutingProblem(
|
||||
bounds=bounds,
|
||||
nets=(NetSpec(net_id, start, target, width=2.0),),
|
||||
)
|
||||
options = RoutingOptions(
|
||||
search=SearchOptions(
|
||||
bend_radii=(10.0,),
|
||||
bend_collision_type=bend_collision_type,
|
||||
bend_proxy_geometry=bend_proxy_geometry,
|
||||
bend_physical_geometry=bend_physical_geometry,
|
||||
sbend_radii=(),
|
||||
),
|
||||
congestion=CongestionOptions(max_iterations=1, use_tiered_strategy=False),
|
||||
)
|
||||
return route(problem, options=options).results_by_net
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print("Running Example 08: Custom Bend Geometry...")
|
||||
|
||||
bounds = (0, 0, 150, 150)
|
||||
start = Port(20, 20, 0)
|
||||
target = Port(100, 100, 90)
|
||||
custom_physical = Polygon([(0, -11), (11, -11), (11, 0), (9, 0), (9, -9), (0, -9)])
|
||||
custom_proxy = box(0, -11, 11, 0)
|
||||
|
||||
print("Routing standard arc in its own session...")
|
||||
results_std = _run_session(bounds, "standard_arc", start, target)
|
||||
print("Routing custom geometry with a separate custom proxy in its own session...")
|
||||
results_custom = _run_session(
|
||||
bounds,
|
||||
"custom_geometry_and_proxy",
|
||||
start,
|
||||
target,
|
||||
bend_physical_geometry=custom_physical,
|
||||
bend_proxy_geometry=custom_proxy,
|
||||
)
|
||||
|
||||
all_results = {**results_std, **results_custom}
|
||||
fig, _ax = plot_routing_results(
|
||||
all_results,
|
||||
[],
|
||||
bounds,
|
||||
netlist={
|
||||
"standard_arc": (start, target),
|
||||
"custom_geometry_and_proxy": (start, target),
|
||||
},
|
||||
)
|
||||
fig.savefig("examples/08_custom_bend_geometry.png")
|
||||
print("Saved plot to examples/08_custom_bend_geometry.png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in a new issue