inire/docs/user/tune-and-troubleshoot.md

64 lines
4.9 KiB
Markdown
Raw Normal View History

# Tune and troubleshoot a route
Start with the net's outcome. It tells you whether to examine the port approach, an overlap, or the search budget.
## Read the result
| `result.outcome` | What to inspect |
| --- | --- |
| `completed` | The path reached its target and passed verification. Read its length in `report.total_length` and follow the [geometry export steps](route-a-layout.md#export-verified-geometry). |
| `colliding` | The path reached its target. Check the collision counts in `result.report` to see whether it overlaps a keepout, another route, or itself. For automatic routing, also check `report.out_of_bounds`. |
| `partial` | Locate `result.path[-1].end_port` on the board and check the next turn and radius. If that approach fits, compare search limits. |
| `unroutable` | The path is empty. Check the launch heading and room for the first straight or bend. |
Check `is_valid` before exporting. With explicit `off`, `guide`, or `seed` mode, also check that the physical polygons fit the board if your export requires containment. Automatic mode includes that check in candidate verification.
## Why a net stopped short
1. **Check whether automatic routing hit a bound.** Compare the verified count with `run.automatic.max_routed`. If the count reaches a bound below the requested total, use `capacity_limit` to locate the passage to widen or `port_conflicts` to find the ports to move.
2. **Check the next approach.** Follow a partial route from its endpoint toward the target. Check the width, clearance, allowed turns, and final heading against the physical layout. When none of the allowed bends fits, change the port approach or the available space.
3. **Compare two search limits.** If the geometry looks feasible, rerun with a larger `search.node_limit` and compare the path endpoint and verified count. The limit applies per search. One run can search the same net several times. Look up the default and related fields in [`SearchOptions`](api-reference.md#searchoptions).
![Two panels of the same obstacle layout. At a three-node search limit the dashed path stops before the obstacles. At 500 nodes the solid path curves around them and arrives at the target.](../figures/partial-and-complete.png)
At three nodes per search the dashed path ends before the first keepout. At 500 the solid path clears the obstacles and reaches the target with the required westbound heading. To reproduce the comparison, change `node_limit` from 3 to 500 in a copy of the [best-effort example](../../examples/09_unroutable_best_effort.py).
## Choose a routing mode
Set `TopologyOptions(mode=...)` and pass it as `topology` in `RoutingOptions`.
- **`automatic`.** Start here. Inire chooses from constructive planners and search stages and keeps the best verified coverage it finds.
- **`off`.** Isolate lattice search or work with custom physical bend geometry.
- **`guide`.** Use suggested corridors when a detour looks promising and the router needs freedom to leave the corridor to turn.
- **`seed`.** Try to realize a verified starting path inside a corridor before the detailed search.
- **`bundle`.** Route supported ordered rectangular bundles. Use a circular radius enabled for both bends and S-bends. Unsupported layouts and invalid schedules raise `ValueError`.
### Mode requirements
- Guide and seed modes require constrained triangulation from Shapely 2.1 with GEOS 3.10 or newer. Caller-supplied seeds take precedence, and nets without a corridor can use ordinary lattice search.
- Enable `infer_terminal_headings` for point terminals with flexible headings. Preserve fixed headings when a device requires a specific arrival direction.
- In automatic mode, smaller initial budgets make the first attempts cheaper. If coverage remains below the bound, a lattice fallback can use your configured ceiling. Automatic also uses lattice for custom bend geometry or when constrained triangulation is unavailable.
## Choose the next setting
| Observation | Next comparison |
| --- | --- |
| Multiple routes reach their ports and collide with one another | Change `net_order` or `max_iterations` one at a time. Compare which nets remain unresolved. See the accepted values in [`CongestionOptions`](api-reference.md#congestionoptions). |
| Valid routes use too many small bends | Increase `bend_penalty`. Compare bend counts and physical lengths to see whether a straighter path needs a longer detour. See [`ObjectiveWeights`](api-reference.md#objectiveweights). |
| Refinement dominates runtime | Try `max_windows_per_net=1`. Compare runtime, cost, and verified paths before adopting the smaller limit. See [`RefinementOptions`](api-reference.md#refinementoptions). |
For a shorter refinement pass, derive the new settings from the `options` already used for the layout.
```python
from dataclasses import replace
from inire import route
short_pass = replace(
options.refinement,
max_windows_per_net=1,
)
faster_refinement = replace(
options, refinement=short_pass,
)
run = route(problem, options=faster_refinement)
```