inire/docs/architecture.md

48 lines
7.5 KiB
Markdown
Raw Normal View History

# Router architecture
2026-03-31 17:26:00 -07:00
Start with the stage that chooses the route, then inspect the worker that produced it. The public `route()` entry point runs one worker for an explicit mode. Automatic mode can run several. Each worker sees the obstacles, locks, and seed hints passed to it. [Public API](user/api-reference.md) · [Worker setup](../inire/router/_stack.py)
2026-03-31 17:26:00 -07:00
## Automatic routing
2026-03-31 17:26:00 -07:00
![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)
The diagram shows the usual sequence for arc bends. A verified layout can reach the routing target early. When attempts run out, selection keeps the best verified coverage found. Custom physical bends, polygonal proxies, or missing constrained triangulation take a lattice-only path.
1. **Establish a stopping target.** Each disjoint pair of incompatible fixed ports rules out one route. For supported rectangular cuts, the capacity check uses the narrowest guide to bound how many paths fit through each opening. Reaching one of these bounds can justify stopping with partial coverage. Keep those bounds separate from estimates such as corridor occupancy or a failed attempt. [Capacity checks](../inire/router/_capacity.py)
2. **Exploit layout structure before search.** Bundles place ordered tracks through barriers. Column schedules assign tracks to openings and stagger turns between them. Compact planners fit local connections between constrained ports. A schedule supplies seeds to the ordinary verifier. This lets the planner make cheap geometric proposals while the verifier checks the resulting physical paths. [Bundles](../inire/router/_bundle.py) · [Columns](../inire/router/_columns.py) · [Compact planners](../inire/router/_compact.py)
3. **Probe cheaply before spending the wider budget.** Direct trials can lock verified straight links and search for the remaining nets. A change in lock order or a small unlocked probe can free a nearby turn. The near-port stage uses up to 100 nodes per search and two congestion iterations for the arc proxy. Alternate proxies use the configured iteration limit because another shallow iteration can find a path the wider retry misses or finds at higher cost. The wider lookahead uses up to 500 nodes and the configured iteration limit. Both respect smaller caller limits. Guide and column attempts can precede the probe when the geometry makes them promising. [Stage order](../inire/router/_automatic.py) · [Direct trials](../inire/router/_routing_policy.py)
4. **Choose what to keep fixed.** If the remaining ports are still connected with verified paths locked, route the unresolved nets around those paths. If locks disconnect the residual, use movable seed hints so the next search can move an incumbent. A residual with several nets sharing a portal can benefit from a different lane assignment. When those attempts stall, seed and lattice workers can search the whole layout. A final lattice retry can use the caller's ceiling. [Residual routing](../inire/router/_automatic.py) · [Corridors and lanes](topological-routing.md#corridor-planning-and-realization)
5. **Accept a checked layout.** Compare verified coverage first. Cost breaks ties between candidates with identical verified IDs. A complete locked layout or an improving joint retry must pass its required whole-layout check before selection. Refinement is also a candidate replacement and must preserve the verified ID set. [Trial selection](../inire/router/_routing_policy.py)
2026-03-31 17:26:00 -07:00
### Example of a poor lock
2026-03-31 17:26:00 -07:00
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.
3. If you change lock ordering or acceptance, check that all four nets still verify together. [Fixture](../inire/tests/stress_routing_benchmarks.py) · [Choose a benchmark](benchmarks.md#choose-a-case)
2026-03-31 17:26:00 -07:00
## Detailed search and congestion
2026-03-31 17:26:00 -07:00
- **Build and admit moves.** Weighted A* searches snapped positions and headings. Rays, visible corners, and corridor waypoints propose straight endpoints. Admission checks clearance, cost, and state dominance. A move-generation change can help a net reach its target at the same node budget. [Moves](../inire/router/_astar_moves.py) · [Admission](../inire/router/_astar_admission.py) · [Search](../inire/router/_search.py)
2026-03-31 17:26:00 -07:00
- **Recheck the installed set.** The congestion driver replaces paths in routing order and raises the overlap penalty between unresolved iterations. A later route can collide with one completed earlier, so the driver verifies the installed set. It ranks snapshots by completed nets, then by conflicts and dynamic collisions. [Routing loop](../inire/router/_router.py) · [Congestion policy](../inire/router/_congestion_policy.py)
2026-03-31 17:26:00 -07:00
- **Repair a small conflict set.** Late iterations can focus on conflicting nets. The driver restores its best iteration before attempting pair-local repair. It keeps the geometry outside an eligible pair fixed, can try either routing order, and checks the proposed replacement in the live world. [Pair-local search](../inire/router/_pair_local.py) · [Read an iteration trace](routing-diagnostics.md#traces)
2026-03-31 17:26:00 -07:00
## Geometry and refinement
Search proxies help reject candidates cheaply. Final verification checks physical clearance, self-collisions, and automatic board containment. A mitred obstacle buffer can flag a candidate near a corner even when the physical distance meets clearance. The exact distance check resolves those cases. When changing a broad phase, keep boundary-touching and custom-shape fixtures alongside ordinary rectangle cases. [Collision world](../inire/geometry/collision.py) · [Collision tests](../inire/tests/test_collision.py)
2026-03-31 17:26:00 -07:00
Use timings to decide which geometry work to inspect. Ray counts can point to repeated visibility queries. Congestion candidate counts and exact pair checks can reveal an overly broad dynamic lookup. Compare checks at similar expansion counts before changing the index. [Geometry workload diagnostics](routing-diagnostics.md#route-metrics)
2026-03-31 17:26:00 -07:00
Refinement looks for cheaper replacements in windows of a completed path. With a finite budget above one window, it prioritizes bend-ended windows so it can try removing expensive turns early. One-window and unlimited runs use longest-first ordering. Candidate scoring precedes polygon construction. A local replacement check relies on the unchanged route and other paths still being valid in the current world. The final check covers the installed result. [Refiner](../inire/router/refiner.py)
2026-03-31 17:26:00 -07:00
## Validate a change
| Change | What to demonstrate |
| --- | --- |
| Stage order, locks, or budgets | Which attempt wins, which net IDs and paths it keeps, and whether skipped work reappears in a later attempt. Include tight passages and preplaced crossings. |
| Collision or cache behavior | Identical clearance and boundary decisions for physical and proxy shapes. Compare candidate counts and exact checks along with time. |
| Congestion, seeds, or pair-local repair | Coverage and conflict evolution at iteration boundaries, plus the final installed geometry after repair. |
| Cost or refinement | Equal verified ID sets before comparing per-net lengths or costs. Check that the improvement survives whole-layout verification. |
Use [benchmark profiles](benchmarks.md#choose-a-profile) for policy comparisons and [exact parity](routing-diagnostics.md#reproduce-and-compare) for behavior-preserving changes.