Initial buildout
This commit is contained in:
parent
34615f3aac
commit
84b76d0f6a
3 changed files with 25658 additions and 25 deletions
170
docs/user/api-reference.md
Normal file
170
docs/user/api-reference.md
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
# Public API reference
|
||||
|
||||
Import these types from `inire`.
|
||||
|
||||
- [Layout example](route-a-layout.md#define-the-inputs)
|
||||
|
||||
## Route a problem
|
||||
|
||||
```text
|
||||
route(problem, *, options=None, iteration_callback=None) -> RoutingRunResult
|
||||
```
|
||||
|
||||
The default is `RoutingOptions()`. The progress callback accepts `(index, results_by_net)` for each completed congestion iteration. Indices increase across attempts, with gaps for timeouts. Use the returned result for final coverage.
|
||||
|
||||
For a zero-node attempt that completes its replay iteration, the callback receives the verified results after any refinement.
|
||||
|
||||
## Layout inputs
|
||||
|
||||
### Ports and nets
|
||||
|
||||
- `Port(x, y, r)` rounds coordinates to integers. The heading `r` is in degrees, with 0 east, 90 north, 180 west, and 270 south. The rounded angle must be a multiple of 90 and is wrapped to the range 0–359.
|
||||
- `NetSpec(net_id, start, target, width=2.0)` uses a unique string ID, two ports, and a finite positive width. Set the start heading to the direction of departure and the target heading to the direction of arrival. Identical snapped ports produce an `unroutable` result with a `terminal_error` for that net. This diagnostic appears in the final results and iteration callbacks. The router plans the remaining nets and ignores seeds for coincident ports. Check the placed connection directly when the ports are intended to abut.
|
||||
|
||||
### RoutingProblem
|
||||
|
||||
The fields below appear in constructor order. Use one layout unit for coordinates, widths, distances, and radii.
|
||||
|
||||
| Field | Default | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `bounds` | Required | Finite board rectangle as `(xmin, ymin, xmax, ymax)`, with each minimum below its maximum. |
|
||||
| `nets` | `()` | Sequence of `NetSpec` objects with unique IDs. Duplicate IDs raise `ValueError`. |
|
||||
| `static_obstacles` | `()` | Valid, nonempty Shapely `Polygon` objects in board coordinates that define routing keepouts. Coordinates may be fractional. |
|
||||
| `initial_paths` | Empty mapping | A read-only snapshot of net IDs mapped to `PathSeed` objects. Supply a new mapping to change seeds. |
|
||||
| `clearance` | `2.0` | Finite, nonnegative spacing required between distinct nets and between a net and a keepout. At zero clearance, distinct nets must still be disjoint, including at vertices. Boundary contact with a keepout is allowed. |
|
||||
| `safety_zone_radius` | `0.0021` | Distance around move endpoints where a local proxy intersection can be rechecked against the physical polygons. The physical polygons must meet clearance. Also supplies the margin for the optimistic connectivity estimate in automatic mode. |
|
||||
| `self_clearance` | `0.0` | Optional spacing within one net. Applies between components when the intervening centerline is at least this long. Adjacent joins and components immediately on either side of one bend are exempt. At an adjacent join involving a custom outline, boundary contact is allowed and area overlap is a collision. |
|
||||
| `fixed_routes` | `()` | Completed or imported net geometry supplied as `FixedRoute(net_id, polygons)`. Search and verification check clearance to fixed routes using the physical outlines. IDs must be unique across fixed and active nets. |
|
||||
|
||||
## Path seeds
|
||||
|
||||
`PathSeed(segments)` holds an ordered tuple of `StraightSeed(length)`, `Bend90Seed(radius, direction)`, and `SBendSeed(offset, radius)` moves. Lengths and radii must be finite and positive. When routing a seed, straight lengths are rounded to the nearest grid unit, with ties rounded to even and a minimum of one unit. Bend directions are `"CW"` and `"CCW"`. S-bend offsets must be nonzero integers with magnitude less than twice the radius. A seed is materialized from the net's current start port using its width and the run's geometry options. Moves that use a generated circular outline or a proxy derived from one require a radius of at least half the net width.
|
||||
|
||||
A disabled radius or offset or an ambiguous S-bend outline discards the seed and sets the net's `seed_error`. Active search can route the net from scratch. Zero-node replay still checks the other seeds. Unknown net IDs raise `ValueError`.
|
||||
|
||||
## Results
|
||||
|
||||
| Value | Read it for |
|
||||
| --- | --- |
|
||||
| `RoutingRunResult.results_by_net` | A read-only mapping from net ID to `RoutingResult`. Use `dict(run.results_by_net)` to make an editable copy. |
|
||||
| `RoutingResult.is_valid` and `outcome` | `is_valid` is true when the outcome is `completed`. Read `outcome` to distinguish success, a failed geometry check (`colliding`), a path that stopped short (`partial`), or an empty path (`unroutable`). |
|
||||
| `RoutingResult.requested_net` and `effective_net` | The net as supplied and the net used by the worker, including resolved headings. |
|
||||
| `RoutingResult.path` | Ordered path components from the source to the last reached state. Each component carries its move specification and placed start and end ports. An unroutable result has an empty path. |
|
||||
| `RoutingResult.reached_target` | Whether the path reached the target position and heading. With heading inference, the check uses the chosen heading. Read `is_valid` for the result of geometry verification. |
|
||||
| `RoutingResult.report` | `total_length` in layout units plus static, dynamic, and self-collision counts. `out_of_bounds` flags geometry outside the board. `invalid_geometry` flags invalid polygons or a rejected seed that produced no path. `seed_error` describes a seed rejected by the configured move options or by geometry preparation. `terminal_error` identifies coincident ports or an inaccessible start or target face. `sbend_template_error` identifies S-bend moves skipped because multiple outlines matched the net width. A route using other moves can still complete. |
|
||||
| `RoutingResult.as_seed()` | The ordered moves for [saving a placement recipe](route-a-layout.md#save-a-placement-recipe) or replaying a path. |
|
||||
| `RoutingResult.locked_geometry` | Physical polygons checked during routing. Use these to inspect the route or [reserve a completed net](route-a-layout.md#reuse-an-existing-route). |
|
||||
| `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. |
|
||||
|
||||
Check the continuity of the assembled polygons in your layout tool. The legacy `discontinuous` field stays false on new routing reports.
|
||||
|
||||
For structured logging, `dataclasses.asdict(run)` preserves the per-net fields. Choose how to encode the Shapely polygons when writing JSON.
|
||||
|
||||
## Options and defaults
|
||||
|
||||
`RoutingOptions` accepts six option groups. Each group uses the defaults in its table when omitted.
|
||||
|
||||
| Group | Type |
|
||||
| --- | --- |
|
||||
| `search` | [SearchOptions](#searchoptions) |
|
||||
| `objective` | [ObjectiveWeights](#objectiveweights) |
|
||||
| `congestion` | [CongestionOptions](#congestionoptions) |
|
||||
| `refinement` | [RefinementOptions](#refinementoptions) |
|
||||
| `topology` | [TopologyOptions](#topologyoptions) |
|
||||
| `diagnostics` | [DiagnosticsOptions](#diagnosticsoptions) |
|
||||
|
||||
### SearchOptions
|
||||
|
||||
| Field | Default | Effect |
|
||||
| --- | --- | --- |
|
||||
| `node_limit` | `1_000_000` | Nonnegative integer per-search expansion ceiling. Automatic uses smaller budgets for its initial stages. Zero skips search and corridor preparation and verifies supplied seeds in one pass if congestion iterations are enabled. Disable refinement to inspect the unchanged seed geometry. |
|
||||
| `min_straight_length` | `5.0` | Finite, nonnegative minimum length for regular forward moves in lattice search. |
|
||||
| `max_straight_length` | `2000.0` | Finite, positive maximum distance for the forward scan in lattice search. |
|
||||
| `greedy_h_weight` | `1.5` | Finite, nonnegative weight on the estimated cost still needed to reach the target. Lower values give more influence to the cost of the path so far. |
|
||||
| `bend_radii` | `(50.0, 100.0)` | Finite, positive radii permitted for 90-degree bends in search and seeds. Generated circular outlines and proxies derived from them require a radius of at least half the net width. Fractional circular radii retain their curvature and extend both tangents to the next grid point. An empty list disables 90-degree bends. |
|
||||
| `sbend_radii` | `(10.0,)` | Finite, positive radii permitted for S-bends in search and seeds. Generated S-bends require a radius of at least half the net width. An empty list disables S-bends. |
|
||||
| `sbend_offsets` | `None` | `None` lets the router choose signed lateral offsets. An explicit list restricts routing and seeds to those offsets after rounding to the grid. An empty list disables S-bends. |
|
||||
| `bend_collision_type` | `"arc"` | Search proxy, one of `"arc"`, `"bbox"`, or `"clipped_bbox"`. The legacy polygon form defines both shapes unless split geometry is supplied. |
|
||||
| `bend_proxy_geometry` | `None` | Override the bend proxy. A polygon applies to 90-degree bends. A custom polygon proxy by itself keeps the standard physical arc and emits a warning. |
|
||||
| `bend_physical_geometry` | `None` | Override 90-degree bend geometry with `"arc"` or a polygon. A custom physical polygon also supplies the default proxy when the collision type is `"arc"`. Define the polygon relative to the arc center and include both tangent extensions for a fractional radius. |
|
||||
| `bend_clip_margin` | `None` | Optional legacy shrink margin for `"clipped_bbox"`. The default uses an eight-point proxy for each arc and extends it along any grid tangents. |
|
||||
| `visibility_guidance` | `"tangent_corner"` | Choose tangent candidates, local visibility tests from indexed corners with `"exact_corner"`, or no visibility suggestions with `"off"`. |
|
||||
| `sbend_outlines` | `()` | Complete custom S-bend polygons, supplied as `SBendOutline(offset, radius, width, polygon)` entries. An entry applies when its signed offset and radius are enabled and its width matches the net. Disabled entries stay registered for reuse with other search settings. |
|
||||
| `proximity_range` | `10.0` | Obstacle proximity scoring range in layout units. Scale it with the coordinates when changing units. Large perimeters use an exact boundary index once the sample budget is reached. |
|
||||
| `bend_physical_length` | `None` | Optional authored centerline length for the shared custom 90-degree template, including tangent extensions. Search, refinement, and reports use it when supplied. |
|
||||
| `distance_heuristic_weight` | `1.0` | Finite, nonnegative multiplier for the remaining-distance term only. Increase it to favor progress toward the target relative to estimated turn penalties. The routed path's objective stays the same. |
|
||||
|
||||
A custom S-bend outline uses local coordinates. Its input face is centered at `(0, 0)`, its output face at `(span, offset)`, and both ports face east. Use the same grid span as `SBendSeed(offset, radius)`, including any tangent extension to reach the output face. For example, an offset of `40` with radius `50` has its output at `(80, 40)`. The router rotates and translates the entire outline and uses it for collision checks and seed replay. Supply a separate outline to customize the opposite offset. Width matching allows a relative difference of `1e-12` to account for floating-point conversions. If multiple outlines apply to the same move, `route()` skips that move for the affected net and sets `sbend_template_error` in the final result and iteration callbacks. Direct calls to `SearchOptions.sbend_template()` and `sbend_outline()` raise `ValueError` for an ambiguous match. Moves with no matching outline use the circular S-bend. Set `SBendOutline.length` to use a process-specific centerline length for scoring, refinement, and reporting. The default is the nominal circular length. Automatic mode uses lattice search when an enabled outline matches a net width. Bundle mode requires circular bends for its nets.
|
||||
|
||||
Match custom outline faces to their declared ports and width. `SBendOutline` warns about a mismatch at construction. For a custom 90-degree outline used in a result, `route()` warns once per radius and net width. Replay an `SBendSeed` with the same outlines and bend settings.
|
||||
|
||||
Constructive planners that need exact integer S-bend spans check up to 65,536 implicit offsets. When that budget would be exceeded, automatic routing tries other candidates. In explicit bundle mode, supply `sbend_offsets` to check a specific list of offsets.
|
||||
|
||||
Search and replay use placed custom outlines for board containment. When a declared port lies outside the board, proximity scoring samples the nearest point on the placed outline. Final verification checks the placed polygons against the board, keepouts, and other routes.
|
||||
|
||||
For a complete custom S-bend outline, or a custom 90-degree bend with a custom polygon proxy, the radius determines the declared snapped endpoints. Use the supplied polygons to represent the process geometry.
|
||||
|
||||
Circular bends approximate the outer edge within a sagitta of 0.01 layout units. The router also sizes the subdivision for the outer edge of a clearance-expanded circular proxy. A generated circular arc that needs more than 250,000 subdivisions is rejected before sampling. Use coarser layout units if the required radii exceed this limit.
|
||||
|
||||
### ObjectiveWeights
|
||||
|
||||
The search objective scores path length, components, and proximity. All weights must be finite and nonnegative. Increasing a component penalty makes routes with more of that component less attractive. Refinement can use its own objective.
|
||||
|
||||
| Field | Default | Effect |
|
||||
| --- | --- | --- |
|
||||
| `unit_length_cost` | `1.0` | Cost per unit of path length, including estimated remaining distance in lattice and corridor search. At zero, the estimate still includes configured turning penalties. |
|
||||
| `bend_penalty` | `250.0` | Additional cost of a 90-degree bend. Smaller radii incur a larger surcharge when this penalty is positive. |
|
||||
| `sbend_penalty` | `500.0` | Additional cost of an S-bend. |
|
||||
| `danger_weight` | `1.0` | Weight of the obstacle proximity cost. |
|
||||
|
||||
### CongestionOptions
|
||||
|
||||
Increase the iteration limit when later reroutes might resolve conflicts. Adjust the initial penalty or multiplier when nets keep competing for the same space.
|
||||
|
||||
| Field | Default | Effect |
|
||||
| --- | --- | --- |
|
||||
| `max_iterations` | `10` | Nonnegative integer maximum for congestion iterations per attempt. Automatic's initial probe may use fewer. Zero skips warm-start and corridor searches. |
|
||||
| `base_penalty` | `100.0` | Finite, nonnegative initial penalty for overlapping other routes. |
|
||||
| `multiplier` | `1.5` | Finite, nonnegative penalty multiplier between unresolved iterations. |
|
||||
| `use_tiered_strategy` | `False` | Opt into a first iteration without congestion scoring when corridor guidance is absent. That iteration substitutes the clipped bounding-box proxy when the configured proxy is `arc`. |
|
||||
| `net_order` | `"user"` | Start from input order or sort by the sum of the horizontal and vertical distances between ports with `"shortest"` or `"longest"`. |
|
||||
| `warm_start_enabled` | `True` | Build greedy seeds before congestion iterations. |
|
||||
| `shuffle_nets` | `False` | Shuffle routing order between iterations. |
|
||||
| `seed` | `None` | Random seed for shuffled ordering. |
|
||||
|
||||
### RefinementOptions
|
||||
|
||||
| Field | Default | Effect |
|
||||
| --- | --- | --- |
|
||||
| `enabled` | `True` | Try geometric improvements after routing. |
|
||||
| `objective` | `None` | Use another `ObjectiveWeights` value for refinement, or reuse the search objective. When set, automatic mode uses this objective to compare a verified refinement with its incumbent on the same net set. `automatic_length_weights` still applies to planner selection. |
|
||||
| `max_windows_per_net` | `4` | Maximum number of path sections to try replacing per net across improvement rounds. Use `1` for a shorter pass or `None` to remove this limit. |
|
||||
|
||||
### TopologyOptions
|
||||
|
||||
|
||||
|
||||
| Field | Default | Effect |
|
||||
| --- | --- | --- |
|
||||
| `mode` | `"automatic"` | Select a [routing mode](tune-and-troubleshoot.md#choose-a-routing-mode). |
|
||||
| `max_corridors` | `3` | Maximum proposed passages per net. |
|
||||
| `guide_strength` | `0.75` | Maximum added guidance cost per unit length. Explicit guide and seed runs with at least two configured congestion iterations may try one additional iteration from the start with zero guidance cost. The retry retains corridor move proposals and wins only with higher verified coverage. |
|
||||
| `seed_node_limit` | `600` | Total seed-search expansions per net, capped by the active search limit. |
|
||||
| `infer_terminal_headings` | `False` | Let automatic or bundle mode choose headings for supported layouts with flexible port directions. Automatic preserves caller headings when initial paths are supplied. |
|
||||
| `automatic_cost` | `"selective"` | Try a second column-planning pass based on route cost when the first pass chains short S-bends. Use `"always"` to try both passes or `"never"` to plan by span alone. |
|
||||
| `automatic_length_weights` | `None` | Optional straight, 90-degree bend, and S-bend length multipliers for automatic candidate selection. The default uses the search objective. |
|
||||
|
||||
### DiagnosticsOptions
|
||||
|
||||
The flags default to `False`.
|
||||
|
||||
| Flag | Use it to |
|
||||
| --- | --- |
|
||||
| `capture_expanded` | Plot the states explored by search. |
|
||||
| `capture_iteration_trace` | Attribute search work to individual nets and iterations. |
|
||||
| `capture_conflict_trace` | Find pairs of routes with clearance conflicts. |
|
||||
| `capture_frontier_trace` | See why search pruned moves near a final route conflict. |
|
||||
| `capture_pre_pair_frontier_trace` | Inspect the routing state before pair-local repair. |
|
||||
|
||||
- [Diagnostics fields and worked trace](../routing-diagnostics.md#traces)
|
||||
154
docs/user/route-a-layout.md
Normal file
154
docs/user/route-a-layout.md
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
# Route a layout
|
||||
|
||||
- [Quick start](../../README.md#route-a-net)
|
||||
|
||||
## Define the inputs
|
||||
|
||||
Choose a coordinate unit fine enough for your layout. `Port` rounds coordinates to integers. Use the direction of travel at both ports (0° east, 90° north).
|
||||
|
||||
```python
|
||||
from shapely.geometry import box
|
||||
|
||||
from inire import NetSpec, Port, RoutingProblem, route
|
||||
|
||||
net = NetSpec("input", Port(10, 20, 0), Port(90, 20, 0), width=2)
|
||||
problem = RoutingProblem(
|
||||
bounds=(0, 0, 100, 80),
|
||||
nets=(net,),
|
||||
static_obstacles=(box(40, 40, 60, 60),),
|
||||
clearance=2,
|
||||
)
|
||||
result = route(problem).results_by_net["input"]
|
||||
```
|
||||
|
||||
- [Route outcomes](tune-and-troubleshoot.md#read-the-result)
|
||||
- [Bend radius settings](api-reference.md#searchoptions)
|
||||
- [Layout input types and defaults](api-reference.md#routingproblem)
|
||||
|
||||
<a id="connect-a-preplaced-crossing"></a>
|
||||
|
||||
## Route between placed crossings
|
||||
|
||||
1. Place both cells and transform their ports into board coordinates.
|
||||
2. Use the cells' routing keepouts or cut port openings in copies of their footprints.
|
||||
3. Add a net for each external connection. A route entering B's west-facing port travels east, so its target heading is 0.
|
||||
|
||||

|
||||
|
||||
The shaded keepouts have 12-unit openings in the dashed cell footprints. A straight approach needs 10 units (width 2 plus clearance 4 on each side).
|
||||
|
||||
```python
|
||||
from shapely.geometry import box
|
||||
|
||||
from inire import (
|
||||
NetSpec, Port, RoutingOptions,
|
||||
RoutingProblem, SearchOptions,
|
||||
route,
|
||||
)
|
||||
|
||||
# Example footprints and access openings in board coordinates.
|
||||
a = box(30, 50, 80, 100)
|
||||
b = box(260, 90, 310, 140)
|
||||
a_access = box(74, 69, 82, 81)
|
||||
b_access = box(258, 109, 266, 121)
|
||||
a_keepout = a.difference(a_access)
|
||||
b_keepout = b.difference(b_access)
|
||||
|
||||
net_id = "A_east_to_B_west"
|
||||
link = NetSpec(
|
||||
net_id,
|
||||
Port(80, 75, 0),
|
||||
Port(260, 115, 0),
|
||||
width=2,
|
||||
)
|
||||
problem = RoutingProblem(
|
||||
bounds=(0, 0, 340, 180),
|
||||
nets=(link,),
|
||||
static_obstacles=(a_keepout, b_keepout),
|
||||
clearance=4,
|
||||
)
|
||||
search = SearchOptions(
|
||||
bend_radii=(25,), sbend_radii=(25,),
|
||||
)
|
||||
options = RoutingOptions(search=search)
|
||||
run = route(problem, options=options)
|
||||
result = run.results_by_net[net_id]
|
||||
assert result.is_valid
|
||||
```
|
||||
|
||||
Check joins and clearance against the full cells when assembling the layout.
|
||||
|
||||
## Save a placement recipe
|
||||
|
||||
Keep a verified route's resolved net, ordered moves, component settings, and coordinate unit. This snippet uses `result` and `options` from the crossing example.
|
||||
|
||||
```python
|
||||
if not result.is_valid:
|
||||
raise ValueError(f"Route {result.net_id!r} ended with outcome {result.outcome!r}")
|
||||
|
||||
placement = (result.effective_net, result.as_seed(), options.search)
|
||||
```
|
||||
|
||||
For a run with default options, use `RoutingOptions().search`.
|
||||
|
||||
Place each move at the previous move's endpoint, starting at the resolved start port. For explicit placements, read `move_spec`, `start_port`, and `end_port` from `result.path`. Use `result.locked_geometry` to compare your layout against the checked polygons, allowing for the writer's rounding.
|
||||
|
||||
## Reuse an existing route
|
||||
|
||||
- **Allow changes.** Pass `initial_paths={net_id: result.as_seed()}`. Search can follow or leave the [seed](api-reference.md#path-seeds).
|
||||
- **Hold the route fixed.** Pass `FixedRoute.from_result(result)` in `fixed_routes`. It blocks contact with other nets even at zero clearance.
|
||||
|
||||
Replay the crossing example with its resolved net and saved moves. Reuse `problem` and `options` from that example.
|
||||
|
||||
```python
|
||||
from dataclasses import replace
|
||||
|
||||
from inire import RefinementOptions, TopologyOptions, route
|
||||
|
||||
chosen = route(problem, options=options)
|
||||
verified_nets = []
|
||||
seeds = {}
|
||||
for net in problem.nets:
|
||||
result = chosen.results_by_net[net.net_id]
|
||||
if result.is_valid:
|
||||
verified_nets.append(result.effective_net)
|
||||
seeds[net.net_id] = result.as_seed()
|
||||
|
||||
replay = route(
|
||||
replace(problem, nets=tuple(verified_nets), initial_paths=seeds),
|
||||
options=replace(
|
||||
options,
|
||||
search=replace(options.search, node_limit=0),
|
||||
topology=TopologyOptions(mode="off"),
|
||||
refinement=RefinementOptions(enabled=False),
|
||||
),
|
||||
)
|
||||
for net in verified_nets:
|
||||
result = replay.results_by_net[net.net_id]
|
||||
assert result.is_valid
|
||||
assert result.locked_geometry == chosen.results_by_net[net.net_id].locked_geometry
|
||||
```
|
||||
|
||||
Route a straight net, then reserve it while routing another net on the same layer. The second net has to detour around one end of the fixed route.
|
||||
|
||||
```python
|
||||
from dataclasses import replace
|
||||
|
||||
from inire import FixedRoute, NetSpec, Port, RoutingOptions, RoutingProblem, SearchOptions, route
|
||||
|
||||
bounds = (0, -50, 100, 50)
|
||||
options = RoutingOptions(search=SearchOptions(bend_radii=(10,)))
|
||||
fixed_net = NetSpec("fixed", Port(10, 0, 0), Port(90, 0, 0))
|
||||
detour_net = NetSpec("detour", Port(50, -20, 90), Port(50, 20, 90))
|
||||
problem = RoutingProblem(bounds=bounds, nets=(fixed_net, detour_net), clearance=0)
|
||||
fixed = route(replace(problem, nets=(fixed_net,)), options=options).results_by_net["fixed"]
|
||||
|
||||
remaining = replace(problem, nets=(detour_net,), fixed_routes=(FixedRoute.from_result(fixed),))
|
||||
detour = route(remaining, options=options).results_by_net["detour"]
|
||||
assert detour.is_valid
|
||||
detour_placement = (detour.effective_net, detour.as_seed(), options.search)
|
||||
```
|
||||
|
||||
For imported artwork in board coordinates, use `FixedRoute("existing_net", imported_polygons)` if it belongs to a net. Use `static_obstacles` for other keepouts.
|
||||
|
||||
- [Fixed-route example and plot](../../examples/README.md#route-around-fixed-geometry)
|
||||
67
docs/user/tune-and-troubleshoot.md
Normal file
67
docs/user/tune-and-troubleshoot.md
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# Tune and troubleshoot a route
|
||||
|
||||
## Read the result
|
||||
|
||||
Get the route with `result = run.results_by_net[net_id]`.
|
||||
|
||||
| `result.outcome` | What to inspect |
|
||||
| --- | --- |
|
||||
| `completed` | The path reached its target and passed verification. Read its length in `report.total_length` and [save its placement recipe](route-a-layout.md#save-a-placement-recipe). |
|
||||
| `colliding` | Reached the target and failed verification. Check `result.report` for collisions, invalid polygons, or a board boundary violation. |
|
||||
| `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. |
|
||||
|
||||
Place the result when `result.is_valid` is true.
|
||||
|
||||
## Why a net stopped short
|
||||
|
||||
1. **Check the bound in automatic mode.** If `run.automatic.max_routed` is below the requested count, check `capacity_limit` for a bottleneck and `port_conflicts` for ports that are too close.
|
||||
2. **Check room for the next turn.** For a [partial result](#read-the-result), start at `result.path[-1].end_port`. Compare the allowed radii and clearance with the room to reach the target heading.
|
||||
3. **Try a larger search budget.** If the approach fits, increase `node_limit` in [`SearchOptions`](api-reference.md#searchoptions) and compare the endpoint and verified count. The limit is per search, and a run can search a net more than once.
|
||||
|
||||

|
||||
|
||||
Rerun the [best-effort example](../../examples/09_unroutable_best_effort.py) with `node_limit` raised from 3 to 500.
|
||||
|
||||
## 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 and configure a usable positive integer radius in both `bend_radii` and `sbend_radii`. Unsupported layouts and invalid schedules raise `ValueError` when routing iterations are enabled.
|
||||
|
||||
### Mode requirements
|
||||
|
||||
- Inire requires Shapely 2.1 or newer with GEOS 3.10 or newer. In guide and seed modes, nets that receive no corridor can use ordinary lattice search. Set `node_limit=0` to verify supplied seeds without planning corridors. [Constrained triangulation requirements](https://shapely.readthedocs.io/en/2.1.2/reference/shapely.constrained_delaunay_triangles.html)
|
||||
- Seed mode gives complete caller-supplied paths priority when they can be reserved without collisions. Partial paths are hints. Seed mode may replace them with complete paths generated from a corridor before the main search.
|
||||
- Use `infer_terminal_headings` with automatic or bundle mode if your ports may change direction and the layout supports bundle planning. Compare fixed and flexible headings in [complex-routing example 1](../../examples/advanced.md#complex-routing-example-1).
|
||||
- Automatic starts with smaller budgets and can retry up to your ceiling. It can try lattice search after constructive planning and corridor-guided search leave unresolved nets.
|
||||
|
||||
[Compare all five modes on one board](../complex-routing-example-1.md#compare-all-routing-modes)
|
||||
|
||||
## 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)
|
||||
```
|
||||
Loading…
Reference in a new issue