Make routing documentation task-oriented
This commit is contained in:
parent
2b02c6eae9
commit
24559bb6aa
1 changed files with 142 additions and 140 deletions
|
|
@ -1,41 +1,42 @@
|
|||
# Router architecture
|
||||
|
||||
The supported entry point is [`inire.route`](../DOCS.md). Automatic mode selects among planner candidates and search attempts. Explicit modes run one worker through [`route_once`](../inire/router/_stack.py). Each worker builds its own collision world, obstacle-proximity map, cost evaluator, A* context, and negotiated-congestion driver.
|
||||
Use this guide when changing how Inire chooses a route, spends search time, or accepts a path. The public `route()` entry point runs one worker for an explicit mode. Automatic mode can run several workers and choose among their results. Each worker has its own collision world and search state. That boundary matters when changing a retry because the new worker sees only the obstacles, locks, and seed hints that the caller passes to it. [Public API](../DOCS.md) · [Worker setup](../inire/router/_stack.py)
|
||||
|
||||
## Automatic routing
|
||||
|
||||
[`_automatic.py`](../inire/router/_automatic.py) controls stage order. [`_routing_policy.py`](../inire/router/_routing_policy.py) owns lock ordering, residual problems, and trial eligibility.
|
||||
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)
|
||||
|
||||
1. **Bound coverage.** Count disjoint conflicting fixed-port pairs and test applicable vertical cuts. A cut estimates how many tracks fit through the available openings. The smaller bound limits the number of nets the run is trying to verify. Compatible unseeded point-terminal inputs may use inferred headings.
|
||||
2. **Try constructive layouts.** Ordered bundles, bundle turnarounds, compact port jogs, column schedules, and local S-bends can produce paths before search. Column scheduling assigns ordered tracks to openings and checks adjacent transitions with the actual widths. Selective cost scoring tries weighted transitions when the span pass finds a layout with fragmented short shifts. A constructed layout goes through the ordinary seed materializer and verifier.
|
||||
3. **Probe, then widen.** Short shifts in both axes may get a guide pass first. Column jogs can assign lanes and stagger 90-degree turns before the probe. The near-port probe uses up to 100 nodes per search and **two congestion iterations** with the standard arc proxy, respecting smaller caller limits. Alternate proxies retain the configured iteration budget. Direct passes reserve safe straight links, check whether the remaining ports are connected, and can change the lock order. A narrow unlocked probe can test whether a straight reservation blocks a nearby exit. A one-net residual can try a four-turn dogleg and two-net boards can try paired perimeter routes. The wider lookahead uses the smaller of 500 nodes and the caller's ceiling, with the configured iteration limit. Live callbacks and shuffled ordering affect the placement of some early stages.
|
||||
4. **Recover unresolved nets.** Freeze verified incumbents as static geometry when the remaining ports stay connected. If hard locks disconnect the residual, pass the incumbents as movable seeds. For some unresolved shared portals, retry with different joint lane assignments. Complete locked candidates and improved joint retries get a whole-layout check. If needed, try whole-layout seed and lattice search, followed by a lattice retry at the caller's ceiling.
|
||||
5. **Select and refine.** More verified net IDs wins. Lower cost breaks ties between candidates with identical verified IDs. Locally checked paths remain ineligible until their required layout check passes. If enabled, refine the selected layout and accept a replacement that preserves the verified ID set and improves the score.
|
||||
The `stress-retry-straight-decoy` fixture shows why a valid link can be a poor lock. A straight trunk divides the board and blocks perpendicular nets. The probe can keep the branches and lower rail. A four-turn dogleg then completes the trunk around them without a wider search. If you change lock ordering or acceptance, check that all four nets still verify together. [Fixture](../inire/tests/stress_routing_benchmarks.py) · [Regression test](../inire/tests/test_routing_benchmarks.py)
|
||||
|
||||
Automatic uses the lattice worker directly for custom physical or polygonal proxy bends and when constrained triangulation is unavailable. [Topology planning](topological-routing.md) describes corridor ranking and seed realization.
|
||||
Automatic mode dispatches directly to lattice search for custom physical or polygonal proxy bends and when constrained triangulation is unavailable. Include those layouts when changing a fallback or geometry option. [Benchmark groups](topological-routing.md#benchmark-corpus)
|
||||
|
||||
## Detailed search and congestion
|
||||
|
||||
The search key is an integer `(x, y, heading)` port. [Move generation](../inire/router/_astar_moves.py) proposes variable-length straights, 90-degree bends, and S-bends. Ray casts, visible corners, and corridor waypoints supply additional straight endpoints. [Admission](../inire/router/_astar_admission.py) checks state dominance, cost bounds, and collisions before enqueuing a move. [The search loop](../inire/router/_search.py) ranks candidates by accumulated cost plus a weighted heuristic. When an attempt runs out of budget, it can return the partial path with the best remaining heuristic.
|
||||
A search state describes a snapped position and heading. Having the right coordinates alone leaves the terminal orientation unresolved. Straight, 90-degree bend, and S-bend moves compete in weighted A*. Ray casts, visible corners, and corridor waypoints suggest where a straight could end. This is why a move-generation change can fix a partial path even at the same node budget. Admission checks collision, cost, and state dominance before enqueuing candidates. [Move generation](../inire/router/_astar_moves.py) · [Admission](../inire/router/_astar_admission.py) · [Search](../inire/router/_search.py)
|
||||
|
||||
[`PathFinder`](../inire/router/_router.py) materializes caller seeds, plans corridors when requested, and can bootstrap with greedy warm starts. During routing it removes a net's old geometry, searches with the current collision state, and installs the new result. The first pass can use a cheaper bend proxy. Later iterations raise the congestion penalty to give routes an incentive to separate.
|
||||
The congestion driver removes a net's old path, installs its replacement, and then routes other nets around or across it according to the active overlap penalty. Later iterations raise that penalty to encourage separation. A route that reached its target early in the iteration can collide with a net installed later. Verify the installed paths together before reviewing conflicts or reporting progress. The best iteration is ranked by completed nets, then conflict edges and dynamic collisions. Restore that snapshot before local repair. [Routing loop](../inire/router/_router.py) · [Congestion policy](../inire/router/_congestion_policy.py)
|
||||
|
||||
At each iteration boundary, the driver rechecks reached-target paths against the installed geometry. It saves the layout with the most completed nets, then the fewest conflict edges and dynamic collisions. [Congestion policy](../inire/router/_congestion_policy.py) chooses which nets to reroute and stops on completed or stalled layouts. Late iterations with a small all-reached conflict graph can reroute just the conflicting set and carry forward expensive incumbents. After restoring the best snapshot, [pair-local search](../inire/router/_pair_local.py) tries both orders for an eligible final conflict pair with the other nets frozen. The driver verifies the proposed replacement in the live world and restores the incumbents if it fails.
|
||||
If the remaining conflicts involve a small set of nets, another global iteration can spend most of its budget revisiting the same geometry. Late iterations can reroute the conflicting subset and keep expensive incumbents. Pair-local repair can then try two orderings with the rest of the geometry held fixed. Verify a proposed pair again in the live world before accepting it. When comparing the iteration loop, include the final result and the handoff to local repair. [Pair-local search](../inire/router/_pair_local.py) · [Read an iteration trace](routing-diagnostics.md#traces)
|
||||
|
||||
## Geometry, verification, and refinement
|
||||
## Geometry and refinement
|
||||
|
||||
The [collision world](../inire/geometry/collision.py) manages raw, clearance-adjusted, and width-specific static geometry. Dynamic paths use a grid and net envelopes to narrow candidate sets before exact polygon checks. [Static](../inire/geometry/static_obstacle_index.py) and [dynamic](../inire/geometry/dynamic_path_index.py) indices own their geometry and caches. The [danger map](../inire/router/danger_map.py) samples obstacle boundaries in a KD-tree. The [visibility planner](../inire/router/visibility.py) builds a lazy static corner index for tangent guidance and a separate graph for exact-corner queries.
|
||||
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)
|
||||
|
||||
Search may use proxy geometry. Verification uses physical components, checks static and dynamic clearance and self-collisions, and adds board containment to automatic trial verification. A mitred static buffer can overestimate clearance near corners. Physical distance resolves those candidates. Locked geometry exposes the unbuffered polygons so the receiving problem can apply its own clearance.
|
||||
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)
|
||||
|
||||
[`PathRefiner`](../inire/router/refiner.py) proposes shorter or cheaper replacements in windows of the selected path. With a finite window limit above one it tries bend-ended windows first, longest within each group. The one-window and unlimited modes use longest-first ordering. It scores candidate moves before building polygons. For a verified incumbent it checks the changed window against the board's collision world and the unchanged route. Final verification accounts for the installed result.
|
||||
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)
|
||||
|
||||
## Implementation map
|
||||
## Validate a change
|
||||
|
||||
| Responsibility | Source |
|
||||
| Change | What to demonstrate |
|
||||
| --- | --- |
|
||||
| Public inputs, outputs, and seed types | [Model](../inire/model.py), [results](../inire/results.py), [seeds](../inire/seeds.py) |
|
||||
| Planner implementations | [Bundles](../inire/router/_bundle.py), [columns](../inire/router/_columns.py), [compact links](../inire/router/_compact.py), [perimeter detours](../inire/router/_perimeter.py) |
|
||||
| Bounds and corridor allocation | [Capacity](../inire/router/_capacity.py), [topology](../inire/router/_topology.py) |
|
||||
| Physical paths and scoring | [Components](../inire/geometry/components.py), [seed materialization](../inire/router/_seed_materialization.py), [cost](../inire/router/cost.py) |
|
||||
| Diagnostics formatting | [Trace formatters](../inire/router/_route_traces.py), [benchmark tools](routing-diagnostics.md) |
|
||||
| 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](topological-routing.md#reproduce-a-comparison) for policy comparisons and [exact parity](routing-diagnostics.md#reproduce-and-compare) for behavior-preserving changes.
|
||||
|
|
|
|||
Loading…
Reference in a new issue