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

64 lines
5.5 KiB
Markdown
Raw Normal View History

# Tune and troubleshoot a route
Start with `run.results_by_net[net_id].outcome`. It distinguishes a path that stopped short from one that reached its target and failed a geometry check.
## 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 and failed verification. Check `result.report` for keepout clearance, conflicts with another route, or self-overlap. In automatic mode, also check `report.out_of_bounds`. |
| `partial` | Read the position and heading of `result.path[-1].end_port`. Check room for the path to continue from that heading. If the next turn 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 the coverage bound in automatic mode.** Compare the verified count with `run.automatic.max_routed`. If the bound is below the requested total, `capacity_limit` can identify a cut with too few tracks and `port_conflicts` can identify pairs of nets whose ports are too close. If the count falls below the bound, check the approaches and search limits as well.
2. **Check the next approach.** Follow a partial route from its last heading toward the target heading. Check whether the allowed turns fit with the guide width and clearance. If the approach requires a turn larger than the available space, reposition the port or give the turn more room.
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`.** Run lattice search directly to measure what search can do without corridor suggestions.
- **`guide`.** Suggest a passage through free space. Search can leave it to make a turn.
- **`seed`.** Try to build a valid starting path inside the suggested passage before the detailed search.
- **`bundle`.** Route supported ordered rectangular bundles with an empty `initial_paths` mapping. Use circular physical bends. The smallest 90-degree bend radius must be a positive integer and must also appear in `sbend_radii`. Unsupported layouts and invalid schedules raise `ValueError`.
### Mode requirements
- In guide and seed modes, nets without a corridor can use ordinary lattice search. A caller-supplied seed takes precedence over a generated one. These modes require Shapely 2.1 or later with GEOS 3.10 or later for [constrained triangulation](https://shapely.readthedocs.io/en/2.1.2/reference/shapely.constrained_delaunay_triangles.html).
- Use `infer_terminal_headings` with automatic or bundle mode if your ports may change direction and the layout supports bundle planning. For the same board with fixed and flexible headings, see the [nine-net example](../../examples/advanced.md#nine-net-terminal-bench-board).
- Automatic mode starts with smaller budgets and can retry with your configured ceiling if coverage remains below the bound. It runs lattice search directly for custom physical bends or polygonal search proxies, 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 turns | Increase `bend_penalty` for 90-degree turns or `sbend_penalty` for S-bends. Compare the number of each type and the resulting path length. 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)
```