Make routing documentation task-oriented
This commit is contained in:
parent
2b02c6eae9
commit
24559bb6aa
1 changed files with 142 additions and 140 deletions
53
DOCS.md
53
DOCS.md
|
|
@ -4,17 +4,19 @@ Start with `route(problem)`. It uses automatic routing with the default options.
|
|||
|
||||
## Describe a layout
|
||||
|
||||
Use `RoutingProblem` to describe a single routing layer. Use the same unit for bounds, coordinates, widths, spacing, and radii. Ports snap to the integer grid. Their headings are degrees counterclockwise from east and must be multiples of 90 after rounding. A target heading gives the direction of travel at arrival.
|
||||
Use `RoutingProblem` to describe a single routing layer. Use the same unit for bounds, coordinates, widths, spacing, and radii. Choose the unit before converting device ports so integer snapping preserves narrow gaps. Headings are degrees counterclockwise from east and must be multiples of 90 after rounding. If your device library describes port headings pointing out of a device, reverse that heading for a target so it follows the waveguide into the device.
|
||||
|
||||
| Input | Meaning |
|
||||
| --- | --- |
|
||||
| `bounds` | Board outline as `(xmin, ymin, xmax, ymax)`. |
|
||||
| `nets` | `NetSpec(net_id, start, target, width=2.0)` objects with unique IDs and `Port(x, y, r)` terminals. Defaults to an empty tuple. |
|
||||
| `static_obstacles` | Shapely polygons for keepouts. Defaults to an empty tuple. For a preplaced crossing, provide access to its ports and route each external leg as a net. |
|
||||
| `static_obstacles` | Shapely polygons for keepouts. Defaults to an empty tuple. |
|
||||
| `initial_paths` | Mapping from net IDs to `PathSeed` objects. Defaults to an empty mapping. |
|
||||
| `clearance` | Required spacing between physical shapes. Defaults to `2.0`. |
|
||||
| `safety_zone_radius` | Tolerance for very small obstacle intersections at ports during search. Defaults to `0.0021`. |
|
||||
|
||||
For a preplaced crossing, route the connections to and from its four ports. Keep the internal crossing geometry in the device and leave access openings in its keepout. This lets the router verify clearance around the placed cell while treating each external leg as a separate connection. [Crossing benchmark fixtures](docs/topological-routing.md#benchmark-corpus)
|
||||
|
||||
### Incremental routing with locked geometry
|
||||
|
||||
Reuse the physical polygons of valid routes as static obstacles in the next run. The next run applies its own clearance to those polygons.
|
||||
|
|
@ -35,11 +37,18 @@ second = route(replace(next_problem, static_obstacles=next_problem.static_obstac
|
|||
|
||||
### Initial paths with PathSeed
|
||||
|
||||
Use `result.as_seed()` to replay a path for the same net, or construct a `PathSeed` from `StraightSeed`, `Bend90Seed`, and `SBendSeed` segments. The router materializes seeds from each net's start port with the current geometry settings. It can use partial seeds as hints and reroute nets as needed. Use static obstacles when a route must remain fixed. [Locked paths example](examples/03_locked_paths.py)
|
||||
Use `result.as_seed()` when you want a subsequent run to start from an existing route and still be free to move it. You can also build a `PathSeed` from `StraightSeed`, `Bend90Seed`, and `SBendSeed` segments to suggest an approach. Seeds start at the net's current start port and use the current width and geometry settings. For a route that must remain fixed, use its physical polygons as obstacles. [Locked paths example](examples/03_locked_paths.py)
|
||||
|
||||
## Read the result
|
||||
|
||||
`route(problem, options=..., iteration_callback=...)` returns a `RoutingRunResult`. Read `results_by_net[net_id]` and check `is_valid` before exporting a path. The `outcome` is `completed`, `colliding`, `partial`, or `unroutable`. A path can reach the requested port and still fail clearance or board containment. The per-net `report` gives physical length and collision counts.
|
||||
`route(problem, options=..., iteration_callback=...)` returns a `RoutingRunResult`. Check `results_by_net[net_id].is_valid` before exporting any path. With explicit `off`, `guide`, or `seed` mode, also check the physical polygons against the board if your export requires containment. Automatic mode includes that check in its candidate verification.
|
||||
|
||||
| Outcome | What to inspect |
|
||||
| --- | --- |
|
||||
| `completed` | Use `report.total_length` to compare physical length. Use `locked_geometry` for the physical polygons or `as_seed()` for the move sequence. |
|
||||
| `colliding` | The path reached its target. Check `report` for static, dynamic, or self-collisions, or a failed automatic board containment check. |
|
||||
| `partial` | Inspect where the returned path ends. An awkward launch or arrival can leave too little room to turn, even when the ports look close in plan view. |
|
||||
| `unroutable` | There is no returned path. Check the start heading and access to the first straight or bend. The outcome alone does not establish that the net is impossible. |
|
||||
|
||||
A live callback receives `(iteration_index, results_by_net)` after each completed congestion iteration. In automatic mode, indices increase across attempts and each callback sees the nets in that attempt. Callback counts and net sets depend on which attempts run. Use the returned result for final verified routes. [Diagnostics and metrics](docs/routing-diagnostics.md)
|
||||
|
||||
|
|
@ -49,32 +58,40 @@ Set `RoutingOptions(topology=TopologyOptions(mode=...))` when you need a particu
|
|||
|
||||
| Mode | When to use it |
|
||||
| --- | --- |
|
||||
| `"automatic"` | The default. Chooses from constructive planners and detailed search stages based on the layout. |
|
||||
| `"off"` | Run the lattice router directly. Useful for custom bends and controlled comparisons. |
|
||||
| `"guide"` | Add corridor waypoints and a soft guidance cost to lattice search. |
|
||||
| `"seed"` | Try to realize and verify corridor paths before the detailed router completes the layout. |
|
||||
| `"bundle"` | Construct tracks for supported ordered rectangular bundles. Unsupported layouts or failed verification raise `ValueError`. |
|
||||
| `"automatic"` | Start here for general routing. Inire tries different strategies and keeps the best verified coverage it finds. |
|
||||
| `"off"` | Isolate detailed lattice search when testing custom bend geometry or comparing the effect of corridor planning. |
|
||||
| `"guide"` | Try this when obstacles suggest a useful detour and the search needs freedom to leave it to make a turn. |
|
||||
| `"seed"` | Try this when finding a usable route around the obstacles is the main difficulty and a verified starting route could help. |
|
||||
| `"bundle"` | Use for supported ordered rectangular bundles, such as the Terminal-Bench point-terminal example. Unsupported layouts and invalid schedules raise `ValueError`. |
|
||||
|
||||
`guide` and `seed` require constrained triangulation from Shapely 2.1 with GEOS 3.10 or newer. Caller-supplied seeds take precedence. Nets without corridors can still use lattice search. In bundle mode, use a circular bend radius enabled for both bends and S-bends. Enable heading inference only when the supplied terminals are points with flexible headings. [Topology algorithms and bundle example](docs/topological-routing.md)
|
||||
|
||||
### Automatic routing
|
||||
|
||||
Automatic routing verifies planner candidates and keeps the best coverage it finds. The near-port probe uses at most 100 nodes per search and two congestion iterations with the standard arc proxy, subject to any smaller caller limits. Alternate proxies use the configured iteration budget. The wider initial pass can use up to 500 nodes per search and the configured iteration limit. When coverage remains below the routing bound, a lattice fallback can use the configured search ceiling. Automatic uses lattice directly for custom bend geometry or when constrained triangulation is unavailable.
|
||||
The first search stages use smaller budgets. If they leave nets unresolved, a later lattice search can use your configured ceiling. Lowering that ceiling limits each search, and can prevent a difficult net from completing. Automatic uses lattice directly for custom bend geometry or when constrained triangulation is unavailable. [Automatic stage order and budgets](docs/architecture.md#automatic-routing)
|
||||
|
||||
`run.automatic` reports `verified_net_ids`, the selected planner, its stages, and the upper bound `max_routed`. A cut with finite capacity or conflicting fixed ports can make that bound smaller than the requested net count. Detailed traces describe the selected attempt. Counters and stage timings include work done in other attempts. [Automatic stage order](docs/architecture.md#automatic-routing) · [Report fields](docs/routing-diagnostics.md#automatic-reports)
|
||||
Compare `len(run.automatic.verified_net_ids)` with `max_routed`. If the verified count already reaches a bound below the requested count, examine `capacity_limit` or `port_conflicts` to find the geometric constraint. More search cannot add a route past that bound. A verified count below the bound leaves room to investigate the search or geometry. [Read a routing report](docs/routing-diagnostics.md#automatic-reports)
|
||||
|
||||
## Tune a run
|
||||
|
||||
Start with the process constraints in `SearchOptions` and the layout's clearance. If routing stops early, inspect the returned net outcomes and the automatic routing bound before increasing budgets. Set `SearchOptions(node_limit=500)` to cap each search at 500 expansions. The entire run may do several searches per net. If refinement dominates runtime, try `RefinementOptions(max_windows_per_net=1)`. Compare verified net IDs and paths as well as time.
|
||||
Set the layout clearance and allowed radii from your process constraints first. Then change one setting at a time on the same layout and check the affected nets as well as the elapsed time.
|
||||
|
||||
| If you see | Try |
|
||||
| --- | --- |
|
||||
| The router reaches a reported capacity bound | Move the conflicting ports or make more room in the bottleneck. For a mixed-width passage, check the room at the approach and through the turns. |
|
||||
| A net remains partial below the bound despite plausible turn room | Try a larger `search.node_limit` and check whether that net completes. The limit applies per search. One run may search for the same net several times. |
|
||||
| Several nets reach their targets and collide with one another | Compare a different `congestion.net_order` or raise `max_iterations` so the router can look for separate paths. Static obstacle collisions call for a geometry check first. |
|
||||
| All nets route but refinement takes most of the time | Try `refinement.max_windows_per_net=1` and compare the resulting paths. |
|
||||
| All nets route but carry too many small bends | Try a higher `objective.bend_penalty`. Compare bend counts and physical lengths to see whether straighter routes need longer detours. |
|
||||
|
||||
To try the shorter refinement pass, derive the new settings from the `options` you already use for the layout.
|
||||
|
||||
```python
|
||||
from inire import RefinementOptions, RoutingOptions, SearchOptions, route
|
||||
from dataclasses import replace
|
||||
from inire import route
|
||||
|
||||
options = RoutingOptions(
|
||||
search=SearchOptions(node_limit=500, bend_radii=(50,), sbend_radii=(25,)),
|
||||
refinement=RefinementOptions(max_windows_per_net=1),
|
||||
)
|
||||
run = route(problem, options=options)
|
||||
faster_refinement = replace(options, refinement=replace(options.refinement, max_windows_per_net=1))
|
||||
run = route(problem, options=faster_refinement)
|
||||
```
|
||||
|
||||
### SearchOptions
|
||||
|
|
|
|||
Loading…
Reference in a new issue