Refine routing geometry checks and streamline documentation
Report coincident terminals and unusable seeds per net, update custom bend handling and verification, and cover the revised behavior with regression tests. Shorten the user and developer guides around reader tasks and keep the illustrated routing walkthrough and reference links easy to find.
This commit is contained in:
parent
8b32d68496
commit
eac083a37d
1 changed files with 1034 additions and 594 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Complex-routing example 1
|
||||
|
||||
Follow the outer return, `net_08`, from the input ports through the bundle plan and its final eastbound turn. Run the fixed-heading example from the repository root to render the complete layout. [Example gallery](../examples/advanced.md#complex-routing-example-1)
|
||||
Follow the outer return, `net_08`, from the input ports to its final eastbound arrival. Run from the repository root.
|
||||
|
||||
```sh
|
||||
python examples/advanced_layouts.py \
|
||||
|
|
@ -8,51 +8,62 @@ python examples/advanced_layouts.py \
|
|||
--output-dir /tmp/inire-complex-routing-example-1
|
||||
```
|
||||
|
||||
Origin. The problem uses board 1 from Terminal-Bench pull request 345. [Pinned layout specification](https://raw.githubusercontent.com/harbor-framework/terminal-bench/249d125b59c0a5352d9e132195cfead6d81446be/tasks/photonic-waveguide-routing/environment/layout_spec.json)
|
||||
Origin. [Board 1 from Terminal-Bench pull request 345](https://raw.githubusercontent.com/harbor-framework/terminal-bench/249d125b59c0a5352d9e132195cfead6d81446be/tasks/photonic-waveguide-routing/environment/layout_spec.json).
|
||||
|
||||
## 1. Load the board and set the routing target
|
||||
|
||||
`build_problem()` reads the example entry into a `RoutingProblem` and `RoutingOptions`. The board is 2,500 by 1,000 units with seven rectangular keepouts and nine nets. The guides are 2 units wide, the clearance is 6, and both kinds of bends use radius 50. The fixed-heading case starts with no seeds and requires each net to launch and arrive heading east. [Example inputs](../examples/advanced-layouts.json) · [Problem builder](../examples/advanced_layouts.py#L34)
|
||||
|
||||
`route()` dispatches to automatic routing. The router checks whether any aligned terminal pairs are too close and whether a vertical cut has fewer tracks than nets that need to cross it. The board passes both checks, so automatic asks the constructive planners to verify all nine nets. [Automatic entry point](../inire/router/_automatic.py#L641) · [Capacity checks](../inire/router/_capacity.py#L28)
|
||||
The 2,500 by 1,000 board has seven keepouts and nine nets. Width is 2, clearance is 6, and both bend radii are 50. All ports require eastbound travel. Automatic starts with a target of nine verified nets after checking port conflicts and track capacity.
|
||||
|
||||

|
||||
|
||||
Open circles mark source ports and filled squares mark targets. The purple cut crosses the first pair of keepouts. The side panel shows the raw open intervals and the track centers that fit after allowing for guide width and clearance. This cut can carry 24 tracks for nine nets.
|
||||
Open circles mark sources and filled squares mark targets. The inset shows 24 tracks fitting through the purple cut after allowing for width and clearance.
|
||||
|
||||
- [Board inputs](../examples/advanced-layouts.json)
|
||||
- [Problem builder](../examples/advanced_layouts.py#L37)
|
||||
- [Capacity calculation](../inire/router/_capacity.py#L29)
|
||||
|
||||
## 2. Assign lanes and compile path seeds
|
||||
|
||||
The bundle planner groups the obstacles into two barriers with openings and three obstacles between them. It sorts the launches by height and separates the short connection `net_03`, the lower and upper groups, and the outer return `net_08`. The planner budgets 7 units from a keepout edge to a guide centerline and uses a 9-unit pitch between neighboring lanes. It reserves the bottommost lane for the return and has room for one more lane beneath the tower. [Layout recognition](../inire/router/_bundle.py#L46) · [Lane assignment](../inire/router/_bundle.py#L114)
|
||||
|
||||
For `net_08`, the initial plan drops from `(12, 450)` to the bottom lane at `y = 1`, crosses east, climbs on the right, and heads west to `(1112, 991)`. The planner compiles the waypoints into straight, 90-degree bend, and S-bend seeds as appropriate. A Manhattan corner becomes a quarter turn with room for its tangencies. A diagonal step in a bundle waypoint list represents an S-bend with an exact grid span. [Bundle seed construction](../inire/router/_bundle.py#L213) · [Waypoint compiler](../inire/router/_waypoints.py#L33)
|
||||
The bundle planner groups nets by their passages and spaces the lanes at a pitch of 9. The first `net_08` plan takes the bottom lane at `y = 1`, rises on the right, and approaches its target heading west.
|
||||
|
||||

|
||||
|
||||
The dots mark waypoints in the proposed seeds. The lower inset shows the two continuous lanes below the tower. The other lower routes rise above that obstacle.
|
||||
The dots mark waypoints. In the lower inset, only `net_08` and `net_00` fit below the tower. The planner compiles straight runs, right-angle corners, and diagonals into straight, quarter-turn, and S-bend seeds.
|
||||
|
||||
- [Lane assignment](../inire/router/_bundle.py#L114)
|
||||
- [Waypoint compiler](../inire/router/_waypoints.py#L33)
|
||||
|
||||
## 3. Fit the required eastbound arrival
|
||||
|
||||
Automatic routing compares the bundle's inferred headings with the input. Only `net_08` differs. Its initial bundle arrives from the east heading west. The turnaround planner adjusts the upper shelf route `net_07` and brings `net_08` back below it. Near the target, `net_08` rises west of `x = 1112` and takes a final right turn to arrive heading east. The planner recompiles the two changed seeds and submits the full set for verification. [Constructive planner dispatch](../inire/router/_automatic.py#L228) · [Turnaround candidates](../inire/router/_perimeter.py#L103)
|
||||
The turnaround planner shifts the upper shelf route `net_07` and brings `net_08` beneath it. The return rises west of its target and takes a final right turn. The planner recompiles both changed seeds.
|
||||
|
||||

|
||||
|
||||
The arrow above each red target square shows the arrival heading.
|
||||
Compare the heading arrows above the red target squares.
|
||||
|
||||
- [Turnaround candidates](../inire/router/_perimeter.py#L103)
|
||||
|
||||
## 4. Verify the seeds and refine the layout
|
||||
|
||||
The first `bundle-turnaround` candidate verifies all nine nets. Automatic routing runs a worker in mode `off` for one verification pass with a zero-node search limit and refinement disabled. The worker materializes each seed into physical polygons, installs the paths, and rechecks the installed layout for port joins, board containment, and collisions. The full coverage lets automatic routing skip its search trials. [Seeded worker setup](../inire/router/_automatic.py#L173) · [Seed installation](../inire/router/_router.py#L877) · [Physical verification](../inire/geometry/collision.py#L708)
|
||||
A worker in mode `off` replays the `bundle-turnaround` seeds with a zero-node budget. It checks the resulting polygons against the board, keepouts, and other routes. All nine verify, so automatic skips search.
|
||||
|
||||

|
||||
|
||||
The upper panel reconstructs the first four installed paths from the worker's verified seeds. The lower panel shows the full set checked together.
|
||||
The upper panel shows the first four paths in installation order. The lower panel shows all nine checked together.
|
||||
|
||||
Automatic then replays the verified seeds in a worker with refinement enabled. The refiner tries replacing sections with at least four 90-degree bends and verifies the resulting layout. In this run, refinement changes `net_05` and `net_07` and keeps all nine nets verified. The refined layout wins on the configured objective, which includes component penalties as well as length. [Refinement handoff](../inire/router/_automatic.py#L610) · [Trial comparison](../inire/router/_routing_policy.py#L45)
|
||||
Automatic replays the seeds again with refinement enabled. The refiner replaces sections of `net_05` and `net_07`, preserving all nine verified nets and lowering the configured objective.
|
||||
|
||||

|
||||
|
||||
Compare the solid and dashed approaches of `net_07` near the top edge.
|
||||
|
||||
- [Seeded worker](../inire/router/_automatic.py#L173)
|
||||
- [Physical verification](../inire/geometry/collision.py#L687)
|
||||
- [Refinement handoff](../inire/router/_automatic.py#L610)
|
||||
|
||||
## 5. Inspect the result
|
||||
|
||||
The example counts `RoutingResult.is_valid` and plots each path from its physical polygons. To see the router's decisions, run the same board with the benchmark CLI and inspect the selected stage and its zero A* node count. The JSON records both stages under `runs[0].samples[0].stages`. [Plotting code](../examples/advanced_layouts.py#L71)
|
||||
Find the two stages under `runs[0].samples[0].stages` in the benchmark JSON. Both report zero A* expansions.
|
||||
|
||||
```sh
|
||||
python -m scripts.compare_topological_routing \
|
||||
|
|
@ -65,11 +76,14 @@ python -m scripts.compare_topological_routing \
|
|||
| 0 | `bundle-turnaround` | Verify the compiled seeds | 9 |
|
||||
| 1, selected | `bundle-turnaround` | Refine and verify the layout | 9 |
|
||||
|
||||
To see how heading inference changes the route, rerun the gallery command with `--case complex-routing-example-1-point-terminals`. Automatic accepts the westbound arrival for `net_08`, verifies the original `bundle` plan, and then refines it. Both stages again verify nine nets with zero A* expansions. [Point-terminal figure](../examples/advanced.md#point-terminals) · [Waypoint export command](benchmark-fixtures.md#complex-routing-example-1)
|
||||
The point-terminal variant accepts a westbound arrival for `net_08`, so the original bundle needs no turnaround. Rerun the gallery command with `--case complex-routing-example-1-point-terminals` to see the result.
|
||||
|
||||
- [Both layouts in the gallery](../examples/advanced.md#complex-routing-example-1)
|
||||
- [Waypoint export](benchmark-fixtures.md#complex-routing-example-1)
|
||||
|
||||
## Compare all routing modes
|
||||
|
||||
These runs use the same nine-net board with a 100-node limit per search, one congestion iteration, warm start disabled, and refinement disabled. The table compares a run with triangulation available against a run with that capability disabled. Each mode keeps the input headings except `bundle`, which uses `infer_terminal_headings=True` so `net_08` can arrive westbound. Explicit `bundle` with the original fixed eastbound headings raises a heading mismatch for that net.
|
||||
Each run uses 100 nodes per search and one congestion iteration, with warm start and refinement disabled. Set `infer_terminal_headings=True` for `bundle` so `net_08` can arrive westbound. Fixed eastbound headings raise a mismatch in that mode.
|
||||
|
||||
| Mode | With triangulation available | Without triangulation |
|
||||
| --- | --- | --- |
|
||||
|
|
@ -83,24 +97,28 @@ These runs use the same nine-net board with a 100-node limit per search, one con
|
|||
|
||||
### Triangulation support
|
||||
|
||||
Corridor planning uses Shapely's constrained Delaunay triangulation to keep triangle edges inside free space and respect keepout boundaries. It requires **Shapely 2.1 or later and GEOS 3.10 or later**. On supported platforms a Shapely wheel bundles GEOS. In a pip environment, use `python -m pip install --upgrade "shapely>=2.1"`. A source build needs a compatible system GEOS. [Shapely triangulation reference](https://shapely.readthedocs.io/en/2.1.2/reference/shapely.constrained_delaunay_triangles.html) · [Shapely installation guide](https://shapely.readthedocs.io/en/2.1.2/installation.html)
|
||||
|
||||
Check the versions in the environment that runs Inire.
|
||||
An active corridor search needs Shapely 2.1+ with GEOS 3.10+. Check the versions in the environment that runs Inire.
|
||||
|
||||
```sh
|
||||
python -c 'import shapely; print(shapely.__version__, shapely.geos_version_string)'
|
||||
```
|
||||
|
||||
Inire supports Shapely 2.0.7 for lattice routing and constructive plans. With a compatible backend, automatic already uses triangulation whenever it needs corridor search. Here the ordered bundle and turnaround cover all nine nets, so automatic can move directly to verification. Explicit `guide` and `seed` also verify supplied paths without a mesh when `node_limit=0`.
|
||||
Automatic builds a mesh when it reaches corridor search on a compatible backend. Here the turnaround plan finishes first. Shapely 2.0.7 supports lattice and constructive routing. Guide and seed can also replay supplied paths without a mesh at `node_limit=0`.
|
||||
|
||||
- [Shapely installation](https://shapely.readthedocs.io/en/2.1.2/installation.html)
|
||||
- [Constrained triangulation API](https://shapely.readthedocs.io/en/2.1.2/reference/shapely.constrained_delaunay_triangles.html)
|
||||
|
||||
## Compare a guide-mode search
|
||||
|
||||
The successful bundle run above reaches verification before the corridor search. To see that search's working model, the figure generator runs `net_08` by itself in guide mode on the same board. The left panel shows the actual triangulation, corridor cells in green, and the guide through them as a dashed line. The right panel zooms in on the expanded positions and physical partial path returned when A* reaches its 12-node budget. [Corridor planning](topological-routing.md#corridor-planning-and-realization)
|
||||
To see the corridor model on the same board, run `net_08` on its own in guide mode.
|
||||
|
||||

|
||||
|
||||
Regenerate the stage figures from the planners, routing results, and expanded nodes. [Figure source](../scripts/render_complex_routing_example.py)
|
||||
Left, the mesh, green corridor cells, and dashed guide. Right, purple expanded positions and the red partial path at the 12-node limit.
|
||||
|
||||
```sh
|
||||
python -m scripts.render_complex_routing_example --output-dir /tmp/inire-complex-routing-example-1
|
||||
```
|
||||
|
||||
- [Corridor planning](topological-routing.md#corridor-planning-and-realization)
|
||||
- [Figure generator](../scripts/render_complex_routing_example.py)
|
||||
|
|
|
|||
Loading…
Reference in a new issue