Tie routing documentation to user and developer workflows
This commit is contained in:
parent
2d77877fff
commit
2c7a7ea90a
3 changed files with 309 additions and 148 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Public API reference
|
||||
|
||||
Import the types on this page from `inire`. The [layout guide](route-a-layout.md) shows how to assemble a problem and the [tuning guide](tune-and-troubleshoot.md) explains which settings to try.
|
||||
Import these types from `inire`. To see how the inputs fit together in a runnable design, start with the [layout guide](route-a-layout.md#define-the-inputs).
|
||||
|
||||
## Route a problem
|
||||
|
||||
|
|
@ -12,18 +12,23 @@ Omitting `options` uses `RoutingOptions()`. To observe live congestion iteration
|
|||
|
||||
## Layout inputs
|
||||
|
||||
- `Port(x, y, r)` snaps coordinates to the integer grid and normalizes the heading in degrees. Heading 0 points east and 90 points north. The heading must be a multiple of 90 after rounding.
|
||||
- `NetSpec(net_id, start, target, width=2.0)` uses a unique ID and two ports. The target heading is the direction of arrival.
|
||||
- `RoutingProblem` describes one routing layer. Use one unit for distances, coordinates, widths, and radii.
|
||||
### Ports and nets
|
||||
|
||||
| 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. |
|
||||
| `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`. |
|
||||
- `Port(x, y, r)` snaps coordinates to the integer grid and normalizes the heading `r` in degrees. Heading 0 points east and 90 points north. The heading must be a multiple of 90 after rounding.
|
||||
- `NetSpec(net_id, start, target, width=2.0)` uses a unique ID and two ports. The target heading is the direction of arrival.
|
||||
|
||||
### RoutingProblem
|
||||
|
||||
The fields below appear in constructor order. Use one layout unit for coordinates, widths, distances, and radii.
|
||||
|
||||
| Field | Default | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `bounds` | Required | Board rectangle as `(xmin, ymin, xmax, ymax)`. |
|
||||
| `nets` | `()` | Sequence of `NetSpec` objects with unique IDs. |
|
||||
| `static_obstacles` | `()` | Shapely polygons that define keepouts. |
|
||||
| `initial_paths` | Empty mapping | Net IDs mapped to `PathSeed` objects. |
|
||||
| `clearance` | `2.0` | Required spacing between physical shapes. |
|
||||
| `safety_zone_radius` | `0.0021` | Tolerance for very small obstacle intersections at ports during search. |
|
||||
|
||||
## Path seeds
|
||||
|
||||
|
|
@ -36,12 +41,13 @@ Omitting `options` uses `RoutingOptions()`. To observe live congestion iteration
|
|||
| `RoutingRunResult.results_by_net` | A mapping from net ID to `RoutingResult`. |
|
||||
| `RoutingResult.is_valid` and `outcome` | Final validity and a status of `completed`, `colliding`, `partial`, or `unroutable`. |
|
||||
| `RoutingResult.path` | Ordered path components from the source to the last reached state. An unroutable result has an empty path. |
|
||||
| `RoutingResult.reached_target` and `report` | Arrival status, physical length, and collision details. |
|
||||
| `RoutingResult.reached_target` | Whether the path reached the target port with its required heading. |
|
||||
| `RoutingResult.report` | `total_length` in layout units plus static, dynamic, and self-collision counts. `out_of_bounds` records a board containment failure when checked. |
|
||||
| `RoutingResult.locked_geometry` and `as_seed()` | Physical polygons for export or fixed obstacles, and the move sequence for reuse as a seed. |
|
||||
| `RoutingRunResult.automatic` | In automatic mode, the selected planner, verified IDs, stage history, and any capacity or port-conflict bound. `None` for explicit modes. |
|
||||
| `RoutingRunResult.topology` and `metrics` | Corridor counts and seed work when reported by the selected worker, plus work counters across the run. |
|
||||
|
||||
Before using a route's physical polygons in your layout, follow the [export checks](tune-and-troubleshoot.md#read-the-result).
|
||||
To read a route's polygons and write them to a test file, follow the [geometry export steps](route-a-layout.md#export-verified-geometry).
|
||||
|
||||
## Options and defaults
|
||||
|
||||
|
|
@ -109,6 +115,8 @@ Increase the iteration limit when later reroutes might resolve conflicts. Adjust
|
|||
|
||||
### TopologyOptions
|
||||
|
||||
For a layout that repeatedly stops short at an opening, `guide` can suggest a passage while letting search choose where to turn. To compare this with realizing a physical starting path in `seed`, see the [routing mode choices](tune-and-troubleshoot.md#choose-a-routing-mode).
|
||||
|
||||
| Field | Default | Effect |
|
||||
| --- | --- | --- |
|
||||
| `mode` | `"automatic"` | Select a [routing mode](tune-and-troubleshoot.md#choose-a-routing-mode). |
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
# Route a layout
|
||||
|
||||
Start with the [first route](../../README.md#route-a-net), then replace the example ports and add your layout's constraints.
|
||||
To get a result you can experiment with, run the [single-net quick start](../../README.md#route-a-net). To route your own design, set up the board and connections in the order below.
|
||||
|
||||
## Define the inputs
|
||||
|
||||
1. **Choose a coordinate unit.** Inire snaps port coordinates to an integer grid. Choose a unit fine enough to preserve narrow gaps, and use it for widths, radii, clearance, and bounds too.
|
||||
2. **Set source and target headings.** Heading 0 points east and 90 points north. The source heading points along the launch. The target heading points along the arrival. If your device library labels the target port with its outward heading, reverse it by 180 degrees.
|
||||
3. **Add a net for each connection.** Give each `NetSpec` a unique ID and the guide width. Set your process limits through `SearchOptions` and choose the required clearance on `RoutingProblem`.
|
||||
4. **Add keepouts.** Supply Shapely polygons in `static_obstacles` and use `bounds` for the board rectangle. Leave enough access at the ports for the guide and its permitted bends.
|
||||
5. **Run and check.** Call `route(problem, options=options)`. Start with automatic mode for general layouts and [check each net before export](tune-and-troubleshoot.md#read-the-result).
|
||||
|
||||
For the constructor signatures and field defaults, see the [layout input reference](api-reference.md#layout-inputs).
|
||||
3. **Add a net for each connection.** Give each `NetSpec` a unique ID and the guide width. Use your process's allowed bend radii in [`SearchOptions`](api-reference.md#searchoptions).
|
||||
4. **Set the board and keepouts.** Pass the board rectangle as `bounds`, Shapely polygons as `static_obstacles`, and the required physical spacing as `clearance`. For the defaults and accepted inputs, see [`RoutingProblem`](api-reference.md#routingproblem).
|
||||
5. **Route and check.** Call `route(problem, options=options)` with automatic mode for a general layout. Before exporting, [check each net's result](tune-and-troubleshoot.md#read-the-result).
|
||||
|
||||
<a id="connect-a-preplaced-crossing"></a>
|
||||
|
||||
|
|
@ -22,9 +20,9 @@ For the constructor signatures and field defaults, see the [layout input referen
|
|||
|
||||

|
||||
|
||||
Dashed outlines show the complete device footprints. Shading shows the keepouts passed to Inire. The external route connects the two port markers. The arrow at each marker shows the heading.
|
||||
The dashed outlines show the full footprints of crossings A and B. The shaded keepouts leave a port opening on each facing edge. The external waveguide leaves A at `(80, 75)` and enters B at `(260, 115)`. Both arrows point east.
|
||||
|
||||
Inire applies `clearance` around the supplied keepout polygons. A straight approach of width `w` between two keepout edges needs at least `w + 2 * clearance` of open width. Leave room for any turn near the port and check the opening after snapping the port to the grid.
|
||||
Each opening is 12 units wide. A straight approach of width 2 with clearance 4 on each side needs `2 + 2 * 4 = 10` units between keepout edges. Leave extra room for any turn near a port, and check the opening after snapping the port to the grid.
|
||||
|
||||
```python
|
||||
from shapely.geometry import box
|
||||
|
|
@ -59,40 +57,61 @@ problem = RoutingProblem(
|
|||
search = SearchOptions(
|
||||
bend_radii=(25,), sbend_radii=(25,),
|
||||
)
|
||||
opts = RoutingOptions(search=search)
|
||||
run = route(problem, options=opts)
|
||||
options = RoutingOptions(search=search)
|
||||
run = route(problem, options=options)
|
||||
result = run.results_by_net[net_id]
|
||||
assert result.is_valid
|
||||
```
|
||||
|
||||
Before export, check the port joins and clearance against the actual placed-cell geometry. Inire verifies the external route against the keepouts you supplied.
|
||||
|
||||
## Export verified geometry
|
||||
|
||||
Use `result.locked_geometry` to pass a verified net's physical polygons to a layout writer. For a test file, continue from the quick start or the crossing example and write the polygons as WKT in the layout's coordinate unit.
|
||||
|
||||
```python
|
||||
from pathlib import Path
|
||||
|
||||
from shapely.geometry import GeometryCollection
|
||||
|
||||
if not result.is_valid:
|
||||
raise ValueError(f"{result.net_id}: {result.outcome}")
|
||||
|
||||
geometry = GeometryCollection(result.locked_geometry)
|
||||
Path("route.wkt").write_text(geometry.wkt + "\n", encoding="utf-8")
|
||||
```
|
||||
|
||||
For a multi-net layout, apply the validity check to every net you intend to export. If a route is short or colliding, use its outcome to choose the [next troubleshooting check](tune-and-troubleshoot.md#read-the-result).
|
||||
|
||||
## Reuse an existing route
|
||||
|
||||
- **Give the router a route it can move.** Put `result.as_seed()` in `initial_paths` under the net's ID. A seed uses the current start port, width, and geometry settings. A partial seed can suggest an approach. To build a hint from turns and straights, see the [path seed reference](api-reference.md#path-seeds).
|
||||
- **Hold a route fixed.** Add `result.locked_geometry` to `static_obstacles` while routing other nets. The next run applies its own clearance.
|
||||
|
||||
To reuse the verified routes from a first problem as fixed obstacles, add them to a second problem that contains the remaining nets.
|
||||
Route a straight net, then use its polygons as keepouts in a second routing problem. The second net has to detour around one end of the fixed route.
|
||||
|
||||
```python
|
||||
from dataclasses import replace
|
||||
from inire import route
|
||||
from inire import (
|
||||
NetSpec, Port, RoutingOptions,
|
||||
RoutingProblem, SearchOptions, route,
|
||||
)
|
||||
|
||||
first = route(first_problem)
|
||||
locked = tuple(
|
||||
polygon
|
||||
for result in first.results_by_net.values()
|
||||
if result.is_valid
|
||||
for polygon in result.locked_geometry
|
||||
bounds = (0, -50, 100, 50)
|
||||
options = RoutingOptions(search=SearchOptions(bend_radii=(10,)))
|
||||
first = RoutingProblem(
|
||||
bounds=bounds,
|
||||
nets=(NetSpec("fixed", Port(10, 0, 0), Port(90, 0, 0)),),
|
||||
)
|
||||
obstacles = (
|
||||
next_problem.static_obstacles
|
||||
+ locked
|
||||
fixed = route(first, options=options).results_by_net["fixed"]
|
||||
assert fixed.is_valid
|
||||
|
||||
second = RoutingProblem(
|
||||
bounds=bounds,
|
||||
nets=(NetSpec("detour", Port(50, -20, 90), Port(50, 20, 90)),),
|
||||
static_obstacles=fixed.locked_geometry,
|
||||
)
|
||||
second = route(replace(
|
||||
next_problem,
|
||||
static_obstacles=obstacles,
|
||||
))
|
||||
detour = route(second, options=options).results_by_net["detour"]
|
||||
assert detour.is_valid
|
||||
```
|
||||
|
||||
To see the second route detour around a fixed path, run the [locked-path example](../../examples/README.md#route-around-fixed-geometry).
|
||||
To compare the two paths on a plot, see the [fixed-route example](../../examples/README.md#route-around-fixed-geometry).
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
# Tune and troubleshoot a route
|
||||
|
||||
Check whether the layout can fit the connection before spending more search time. Start with the per-net result and change one setting at a time.
|
||||
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. Use `locked_geometry` for physical polygons and `report.total_length` for length. |
|
||||
| `colliding` | The path reached its target. Read `report` for static, dynamic, or self-collisions and any automatic board containment failure. |
|
||||
| `partial` | Inspect where the path ends. Check the next turn, available radius, and search limit. |
|
||||
| `unroutable` | No path was returned. Check the launch heading and room for the first straight or bend. |
|
||||
| `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 for a geometric bound.** In an automatic run, `max_routed` is an upper bound. If it is below the requested count, read `capacity_limit` or `port_conflicts` to see where to widen a passage or move a port. A result below the bound can still leave feasible nets unfinished.
|
||||
2. **Check the port and turn geometry.** For static or self-collisions, inspect physical clearance and bend room. For dynamic collisions, inspect the routes that compete for the same space.
|
||||
3. **Check the search budget.** If the verified count is below the bound and the geometry looks feasible, try raising a small `search.node_limit`. The limit is per search. A run can try the same net several times.
|
||||
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).
|
||||
|
||||

|
||||
|
||||
The dashed route stops short at three nodes per search. To reproduce both outcomes, try 3 and 500 with the same layout and options in the [best-effort example](../../examples/09_unroutable_best_effort.py).
|
||||
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
|
||||
|
||||
|
|
@ -43,9 +43,9 @@ Set `TopologyOptions(mode=...)` and pass it as `topology` in `RoutingOptions`.
|
|||
|
||||
| Observation | Next comparison |
|
||||
| --- | --- |
|
||||
| Multiple routes reach their ports and collide with one another | Try a different `congestion.net_order` or allow more `max_iterations`. Compare the unresolved IDs. |
|
||||
| Valid routes use too many small bends | Increase `objective.bend_penalty`. Compare bend counts and physical lengths to see whether a straighter path needs a longer detour. |
|
||||
| Refinement dominates runtime | Try `refinement.max_windows_per_net=1`. Compare the verified paths and cost before adopting the smaller limit. |
|
||||
| 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.
|
||||
|
||||
|
|
@ -62,5 +62,3 @@ faster_refinement = replace(
|
|||
)
|
||||
run = route(problem, options=faster_refinement)
|
||||
```
|
||||
|
||||
For accepted values and defaults, use the [option reference](api-reference.md#options-and-defaults).
|
||||
|
|
|
|||
Loading…
Reference in a new issue