Add and measure a 57-board routing benchmark corpus

This commit is contained in:
Jan Petykiewicz 2026-11-26 11:57:49 -08:00
commit 2f2add98ec

68
DOCS.md
View file

@ -24,6 +24,7 @@ This document describes the current public API for `inire`.
- `congestion`
- `refinement`
- `diagnostics`
- `topology`
Route a problem with:
@ -31,7 +32,7 @@ Route a problem with:
run = route(problem, options=options)
```
If you omit `options`, `route(problem)` uses `RoutingOptions()` defaults.
If you omit `options`, `route(problem)` uses `RoutingOptions()` with automatic routing enabled.
The package root is the stable API surface. Deep imports under `inire.router.*` and `inire.geometry.*` remain accessible for advanced use, but they are unstable semi-private interfaces and may change without notice.
@ -73,7 +74,7 @@ Use `RoutingProblem.initial_paths` to provide semantic per-net seeds. Seeds are
| Field | Default | Description |
| :-- | :-- | :-- |
| `node_limit` | `1_000_000` | Maximum number of states to explore per net. |
| `node_limit` | `1_000_000` | Maximum number of states to explore per search attempt. Automatic routing uses at most 500 states per attempt in its first pass. |
| `max_straight_length` | `2000.0` | Maximum length of a single straight segment. |
| `min_straight_length` | `5.0` | Minimum length of a single straight segment. |
| `greedy_h_weight` | `1.5` | Heuristic weight. `1.0` is optimal but slower. |
@ -120,6 +121,69 @@ Use `RoutingProblem.initial_paths` to provide semantic per-net seeds. Seeds are
| :-- | :-- | :-- |
| `enabled` | `True` | Enable post-route refinement. |
| `objective` | `None` | Optional override objective for refinement. `None` reuses the search objective. |
| `max_windows_per_net` | `24` | Maximum candidate windows attempted per net, shared across improvement rounds. Use `1` for a faster pass or `None` to remove the window limit. |
## Topological Routing
`RoutingOptions.topology` accepts a `TopologyOptions` value. The `mode` is the caller's routing choice. In automatic mode, inire selects a planner for the layout and can retry with another one. Seed mode generates verified initial paths before the current router completes and refines the layout.
```python
from inire import RoutingOptions, TopologyOptions, route
run = route(problem, options=RoutingOptions(topology=TopologyOptions(mode="seed")))
```
| Field | Default | Behavior |
| --- | --- | --- |
| `mode` | `"automatic"` | `"automatic"` selects planners and retries from the board geometry. `"off"` uses lattice-only routing. `"guide"` adds portal waypoints and a soft cost to lattice search. `"seed"` realizes candidate corridors and hands verified paths to the router as initial paths. `"bundle"` constructs ordered waveguide tracks for a supported rectangular layout. |
| `max_corridors` | `3` | Maximum number of candidate corridors per net. |
| `guide_strength` | `0.75` | Maximum extra cost per unit length during soft guidance. Zero retains the suggested moves. |
| `seed_node_limit` | `600` | Total seed-search expansions per net, capped by `SearchOptions.node_limit`. |
| `infer_terminal_headings` | `False` | Allow bundle heading inference for point terminals in bundle or automatic mode. Automatic mode uses the supplied headings whenever the problem includes initial paths. |
| `automatic_cost` | `"selective"` | Re-score column transitions when a verified span layout chains short S-bends. `"always"` requests a weighted pass whenever column planning is tried. `"never"` uses span scoring alone. |
| `automatic_length_weights` | `None` | Optional straight, 90-degree bend, and S-bend length multipliers for automatic candidate selection. By default candidates are compared using `RoutingOptions.objective`. Lattice search continues to use the search objective. |
Caller-supplied initial paths take precedence in guide and seed modes. A net with no corridor can use ordinary lattice search. The triangulation modes require Shapely 2.1 and GEOS 3.10 or newer.
`RoutingRunResult.topology` is populated when the stage is enabled. Its `corridor_counts` lists the nets with candidate corridors. Its `seeded_net_ids` and `seed_nodes_expanded` describe the constrained seed pass. See the [comparison and tuning notes](docs/topological-routing.md).
### Ordered bundles
Bundle mode takes an unseeded problem and constructs its schedule from the obstacle rectangles, terminal coordinates, waveguide width, clearance, and bend radius. It supports eastbound bundles with two paired barriers, three interior obstacles, a short net, and an outer return. Unsupported layouts and schedules that fail final geometric verification raise `ValueError`. Use a circular bend radius that is enabled for both 90-degree bends and S-bends.
```python
from inire import RefinementOptions, RoutingOptions, SearchOptions, TopologyOptions, route
options = RoutingOptions(
search=SearchOptions(bend_radii=(50,), sbend_radii=(50,)),
topology=TopologyOptions(mode="bundle", infer_terminal_headings=True),
refinement=RefinementOptions(enabled=False),
)
run = route(unseeded_problem, options=options)
```
For this mode, `run.topology.seeded_net_ids` records the routes generated by the bundle planner. Only enable heading inference for point terminals. [Terminal-Bench reproduction](docs/topological-routing.md#automatic-nine-net-terminal-bench-routing)
### Automatic routing
```python
run = route(problem)
report = run.automatic
```
Automatic routing verifies generated layouts with inire and uses guide, seed, and lattice retries where needed. The first pass uses at most 500 nodes per search attempt. If it falls short of the routing bound and the configured ceiling is higher, automatic tries the lattice router at that ceiling and retains the best verified coverage. Set `SearchOptions(node_limit=500)` for a hard 500-node limit per search attempt. Each routing attempt respects the configured congestion limit.
Automatic carries caller-supplied paths into the usual seed handling. For custom bend geometry or an installation without constrained triangulation, it uses the lattice router directly at the configured limit. The optional refinement pass runs on the selected layout when enabled. Set `TopologyOptions(mode="off")` to select lattice-only routing explicitly.
For unseeded layouts made up of more than two short, forward, same-heading shifts across both axes, automatic can run the full initial guide budget first. If that pass falls short, the near-port probe and other fallbacks remain available. The identical guide retry is skipped when the first pass ran without a timeout. Calls with an iteration callback, shuffled net ordering, or at most 100 nodes per search use the regular search order.
The report records the `selected_planner`, `verified_net_ids`, and the overall `max_routed` upper bound. Each stage includes the verified net IDs and any paths that went outside the board. A path whose physical geometry crosses the board boundary has `result.report.out_of_bounds=True`, which contributes one collision to the result. `result.reached_target` still records whether that path reached its target port.
`capacity_limit` and `port_conflicts` explain cuts and pairs of terminals that lower the bound. `cost_pass_performed` records whether the policy attempted weighted column scoring. Metrics count work across attempts. Detailed traces belong to the selected attempt, and a live iteration callback receives increasing indices across attempts with the nets in each attempt. [Expanded benchmark comparison](docs/topological-routing.md#public-api-budget-sweep)
Each routing stage records its `planner`, the `mode` used by its routing worker, its `operation`, and any retry or scoring `policy`. For example, a bundle turnaround can appear as planner `bundle-turnaround` with worker mode `off` and operation `verify`. A guide retry can appear as planner `portal-guide` with worker mode `guide`, operation `search`, and policy `direct-lookahead-retry`. `selected_planner` reports the planner that produced the selected layout, including when a refinement stage wins.
`run.automatic.timings` records exclusive wall time for `plan`, `verify`, `search`, and `refine`, including rejected candidates. Planning covers candidate generation and screening inside the planner. Search covers the routing worker, including corridor setup and its iteration loop. Verification covers candidate acceptance and final geometry checks. Nested timings exclude time already recorded under another operation. The report's `duration_s` also includes orchestration and other work between timed operations.
## 6. Diagnostics Options