inire/docs/architecture.md

6.7 KiB

Router architecture

An explicit routing mode runs one worker. Automatic routing can run several and compare their results. Each worker receives its own obstacles, locks, and seed hints. To trace how a worker gets its inputs and options, start at route_once().

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.

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. 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. The resulting upper bound can justify stopping with fewer routes than requested.
  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. A refined candidate must preserve the verified net set.

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. Both attempts respect smaller caller limits. Follow those budget decisions in the automatic routing sequence.

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.
  3. If you change lock ordering or acceptance, rerun the case and check that all four nets still verify together. For the command and profile choices, see Run a benchmark.

Detailed search and congestion

  • 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. To understand which endpoints a net can reach within the same node budget, start with move generation.

  • 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 investigate which nets reroute next, read the congestion policy.

  • 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.

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.

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 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.

Validate a change

If you change What to check Where to start
Stage order or budgets Which stage wins and whether work reappears in a later attempt. Include tight passages and preplaced crossings. Automatic routing
Locks or candidate acceptance The verified IDs and their paths after the complete layout is checked. Direct trials and selection
Corridor or seed allocation Coverage through shared openings and search work when a corridor reaches the wrong lane or leaves too little turn room. Corridor planning and realization
Collision or caching Clearance and boundary decisions for both physical and proxy shapes. Compare candidate counts and exact checks along with time. Collision world
Pair-local repair Coverage and conflict edges before repair, plus the final installed geometry. Pair-local search
Cost or refinement Per-net costs on equal verified ID sets and validity after the final check. Path refinement

Use benchmark profiles for policy comparisons and exact parity for behavior-preserving changes.