inire/docs/complex-routing-example-1.md
2026-12-02 20:35:06 -08:00

7 KiB

Complex-routing example 1

Follow the outer return, net_08, from the input ports to its final eastbound arrival. Run from the repository root.

python examples/advanced_layouts.py \
  --case complex-routing-example-1 \
  --output-dir /tmp/inire-complex-routing-example-1

Origin. Board 1 from Terminal-Bench pull request 345.

1. Load the board and set the routing target

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.

The nine input nets surround seven rectangular keepouts. A cut at x = 500 has openings at the bottom, center, and top of the board.

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.

2. Assign lanes and compile path seeds

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.

Colored waypoint lines separate the lower, upper, short, and return routes. A close-up shows net_08 at y = 1 and net_00 at y = 10 beneath the tower.

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.

3. Fit the required eastbound arrival

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.

Two views show the materialized shelf and return paths. In the initial plan net_08 arrives westbound. In the turnaround candidate it passes below the shelf, rises left of the target, and arrives eastbound.

Compare the heading arrows above the red target squares.

4. Verify the seeds and refine the layout

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 shows the physical paths of the first four nets in installation order. The lower panel shows all nine paths after verification.

The upper panel shows the first four paths in installation order. The lower panel shows all nine checked together.

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.

The refined net_07 stays near the top edge longer and descends close to its target. Its earlier approach is dashed, and the outer return remains visible below it.

Compare the solid and dashed approaches of net_07 near the top edge.

5. Inspect the result

Inspect run.automatic.stages and run.automatic.selected_stage after routing the fixed-heading board under the public defaults. Both stages report zero A* expansions.

Stage Planner Operation Verified nets
0 bundle-turnaround Verify the compiled seeds 9
1, selected bundle-turnaround Refine and verify the layout 9

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.

Compare all routing modes

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 Result
automatic 9/9 verified. The turnaround plan completes the layout without building a mesh.
off 0/9 verified at this budget. The worker runs lattice search directly.
guide 1/9 verified. The worker builds a mesh and suggests corridors to lattice search.
seed 1/9 verified. The worker builds a mesh and searches for starting paths inside the corridors before its routing iteration.
bundle 9/9 verified. The worker builds and verifies ordered tracks directly from the board geometry.

Five panels show route outcomes at the same search budget. Automatic and bundle verify all nine nets. Off, guide, and seed leave partial paths.

Triangulation support

Inire requires Shapely 2.1 or newer with GEOS 3.10 or newer. Check the versions in the environment that runs Inire.

python -c 'import shapely; print(shapely.__version__, shapely.geos_version_string)'

Automatic builds a mesh when it reaches corridor search. Here the turnaround plan finishes first. Guide and seed also replay supplied paths without a mesh at node_limit=0.

To see the corridor model on the same board, run net_08 on its own in guide mode.

A triangle mesh and highlighted cells guide the isolated net toward its target. A zoom near the source shows purple expanded positions and a red partial path ending before the target.

Left, the mesh, green corridor cells, and dashed guide. Right, purple expanded positions and the red partial path at the 12-node limit.

python -m scripts.render_documentation_figures --output-dir /tmp/inire-complex-routing-example-1

Implementation

Stage Inputs and code
Board and routing target Board inputs, problem builder, capacity calculation
Lanes and seeds Lane assignment, waypoint compiler
Eastbound arrival Turnaround candidates
Verification and refinement Seeded worker, physical verification, refinement handoff
Figures and mode comparison Figure generator