Clarify routing documentation and refresh example figures

This commit is contained in:
Jan Petykiewicz 2026-11-27 11:59:22 -08:00
commit ab97281df3

View file

@ -1,25 +1,25 @@
# Router architecture
An explicit routing mode runs one worker. Automatic routing can run several and compare their results. To follow how the worker gets its obstacles, locks, and seed hints, start at [`route_once()`](../inire/router/_stack.py#L71).
An explicit routing mode runs one worker with that mode's settings. Automatic routing can run several workers with different obstacles, locks, or starting paths, then select a result. To see what a single worker receives and returns, start at [`route_once()`](../inire/router/_stack.py#L71).
## Automatic routing
![Automatic routing sets a bound, then constructs, probes, widens, and recovers while below it. Verified candidates feed selection. The chosen layout can be refined before it is returned.](figures/automatic-stages.png)
![Automatic routing sets a target for the number of verified nets and tries several ways to reach it. The router selects and optionally refines its best layout before returning a result for each net.](figures/automatic-stages.png)
Follow the left column down while the run is below its coverage target. Move right to selection when a verified candidate reaches that target or the attempts run out. Custom physical bends, polygonal proxies, and layouts routed without constrained triangulation take a lattice-only path.
Follow the left column down while the number of verified nets is below the target. The router selects a layout when an attempt reaches that target or the attempts run out. It uses lattice search directly for custom physical bends, polygonal proxies, or a run without constrained triangulation.
1. **Set the coverage target.** Each disjoint pair of incompatible fixed ports rules out one route. At supported rectangular cuts, compute how many paths of the narrowest width can fit through the openings. To change which cuts can establish an upper bound, start with [`cut_capacity()`](../inire/router/_capacity.py#L27).
1. **Set the coverage target.** A pair of nets with fixed ports that are too close can supply at most one route. Count such pairs using each net at most once. For rectangular keepouts, also bound the number of paths that can cross a vertical cut by packing tracks at the narrowest requested width. To see how the openings are counted, start with [`cut_capacity()`](../inire/router/_capacity.py#L27).
2. **Try constructive planners.** Bundles assign ordered tracks through barriers. Column schedules place turns between openings. Compact planners fit short connections between constrained ports. Each produces seeds whose physical geometry the worker checks.
3. **Start with a small search budget.** Lock verified straight links and search for the remaining nets. A different lock order or a small unlocked probe can free room for a turn. Promising guide and column attempts can run first.
4. **Decide what to keep fixed.** If the remaining ports are connected, route around the locked geometry. If the locks disconnect them, pass the incumbents as movable seeds. A joint retry can assign different lanes through a shared portal. If recovery stalls, seed and lattice attempts can search the whole layout, with a final lattice retry up to the caller's ceiling.
5. **Select a verified layout.** Prefer greater coverage and compare cost on identical verified net sets. A complete locked layout or an improving joint retry must pass its whole-layout check before selection. To see how a refined candidate must preserve the verified net set, follow [the refinement handoff](../inire/router/_automatic.py#L581).
4. **Decide what to keep fixed.** If the remaining ports are connected, route around the locked geometry. If the locks disconnect them, pass the previously verified paths as seeds that can move. A joint retry can assign different lanes through a shared opening. If recovery stalls, seed and lattice attempts can search the whole layout. The final lattice retry can use the caller's full node limit.
5. **Select a verified layout.** Prefer more verified nets and compare cost when the verified net IDs match. A completed `incumbent-residual` trial or an improving `joint-portal-lanes` trial must pass another check with the original keepouts before it can win. Refinement can replace the selected layout only if it preserves the verified net IDs. See [the refinement handoff](../inire/router/_automatic.py#L581).
The near-port attempt uses up to 100 nodes per search and two congestion iterations with the arc proxy. Alternate proxies use the configured iteration limit because a later shallow iteration can find a cheaper path. Wider lookahead uses up to 500 nodes per search and the configured iteration limit. Follow the caps and early exits in [the initial search trials](../inire/router/_automatic.py#L480).
### Example of a poor lock
1. A straight trunk in `stress-retry-straight-decoy` fits on its own. Once locked, it divides the board and blocks two perpendicular nets.
2. The probe can keep the branches and lower rail. A four-turn dogleg completes the trunk around them before wider search.
1. The straight trunk in `stress-retry-straight-decoy` fits on its own. Fixing it in place would block both vertical routes.
2. The early search can keep the vertical routes and the lower rail. A four-turn detour connects the trunk before the router tries a larger search budget. See where it bends in the [layout and route figure](../examples/advanced.md#trunk-that-detours-around-branches).
3. If you change lock ordering or acceptance, run the [single-case benchmark command](benchmarks.md#run-a-benchmark) with `--case stress-retry-straight-decoy`. Check that all four nets still verify and compare which stage finishes the trunk.
## Detailed search and congestion
@ -28,15 +28,17 @@ The near-port attempt uses up to 100 nodes per search and two congestion iterati
- **Recheck the installed set.** The driver raises the overlap penalty when successive routes collide. After an iteration it verifies the installed paths, since a later route can collide with one completed earlier. It ranks snapshots by completed nets, then by conflicts and dynamic collisions. To see when it reroutes just the conflicting nets, read [`next_reroute_net_ids()`](../inire/router/_congestion_policy.py#L93).
- **Repair a small conflict set.** The driver restores its best iteration and verifies it once for diagnostics and target selection. Pair-local search keeps the geometry outside an eligible pair fixed and can try either routing order. The driver checks replacements in the live world. To compare the restored set with the repaired paths, [follow a late conflict](routing-diagnostics.md#follow-a-late-conflict-into-pair-local-repair).
- **Repair a small conflict set.** The driver returns to the best iteration and can reuse its verification when those paths are still installed and restored-stage traces are disabled. If the conflicts form separate pairs, the router can try repairing up to two of them. It holds the other paths fixed, tries both routing orders as needed, and checks proposed replacements against the installed layout. For a worked trace, [follow a late conflict](routing-diagnostics.md#follow-a-late-conflict-into-pair-local-repair).
## Geometry and refinement
Search proxies help reject candidates cheaply. Final verification checks physical clearance, self-collisions, and automatic board containment. A mitred buffer can flag a candidate near a corner even when physical distance meets clearance. The exact distance check resolves those cases. To test changes to the broad phase, use the boundary-touching and custom-shape cases in the [collision tests](../inire/tests/test_collision.py).
Search proxies approximate the shape of a move for collision checks. Verification uses physical polygons for static keepout checks and self-collisions. For conflicts between nets, it compares the checked path's clearance-expanded physical polygons with the other routes' installed, clearance-expanded proxies. Automatic and bundle modes also check that the physical polygons fit within the board.
At a keepout corner, a mitred clearance buffer can reach farther than the specified clearance. Verification checks the actual distance before counting these hits as collisions. For an example with a corner close to the required clearance, see the [mitred-corner test](../inire/tests/test_collision.py#L146).
When expansion counts are similar but routing time rises, inspect ray casts for repeated visibility queries and exact pair checks for an overly broad dynamic lookup. The [metrics guide](routing-diagnostics.md#route-metrics) maps those questions to counters.
Refinement scores replacement windows before constructing their polygons. Finite budgets above one window prioritize bend-ended windows to give expensive turns an early chance to be replaced. One-window and unlimited runs try the longest windows first. Local checks rely on the rest of the route and the other installed paths being valid. Final verification checks the installed result.
Refinement tries replacing sections of routes with at least four 90-degree bends. It scores proposed detours before constructing their polygons. With a finite budget above one, it tries sections with bends at both ends first. With a budget of one or no window limit, it starts with the longest section by component count. It can check just the replacement when the original route is valid against the installed geometry. Final verification checks the entire updated route.
## Validate a change