Simplify routing verification and isolate benchmark policies

This commit is contained in:
Jan Petykiewicz 2026-11-26 21:55:34 -08:00
commit ec2768853e
25 changed files with 1874 additions and 1164 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
# Conflict Trace # Conflict Trace
Generated at 2026-04-02T14:24:39-07:00 by `scripts/record_conflict_trace.py`. Generated at 2026-11-26T21:47:32-08:00 by `scripts/record_conflict_trace.py`.
## example_07_large_scale_routing_no_warm_start ## example_07_large_scale_routing_no_warm_start
@ -10,8 +10,8 @@ Results: 10 valid / 10 reached / 10 total.
| :-- | --: | --: | --: | --: | | :-- | --: | --: | --: | --: |
| iteration | 0 | 9 | 16 | 1 | | iteration | 0 | 9 | 16 | 1 |
| iteration | 1 | 8 | 12 | 2 | | iteration | 1 | 8 | 12 | 2 |
| iteration | 2 | 6 | 5 | 4 | | iteration | 2 | 5 | 4 | 5 |
| iteration | 3 | 4 | 2 | 6 | | iteration | 3 | 8 | 4 | 2 |
| iteration | 4 | 4 | 2 | 6 | | iteration | 4 | 4 | 2 | 6 |
| iteration | 5 | 4 | 2 | 6 | | iteration | 5 | 4 | 2 | 6 |
| restored_best | | 4 | 2 | 6 | | restored_best | | 4 | 2 | 6 |
@ -21,37 +21,37 @@ Top nets by traced dynamic-collision stages:
- `net_06`: 7 - `net_06`: 7
- `net_07`: 7 - `net_07`: 7
- `net_01`: 6 - `net_02`: 7
- `net_00`: 5 - `net_03`: 6
- `net_02`: 5 - `net_00`: 4
- `net_03`: 4 - `net_01`: 4
- `net_08`: 2 - `net_08`: 3
- `net_09`: 2 - `net_09`: 3
- `net_05`: 1 - `net_05`: 1
Top net pairs by frequency: Top net pairs by frequency:
- `net_06` <-> `net_07`: 7 - `net_06` <-> `net_07`: 7
- `net_00` <-> `net_01`: 5 - `net_02` <-> `net_03`: 6
- `net_01` <-> `net_02`: 4 - `net_00` <-> `net_01`: 4
- `net_00` <-> `net_02`: 3 - `net_00` <-> `net_02`: 3
- `net_00` <-> `net_03`: 3 - `net_01` <-> `net_02`: 3
- `net_02` <-> `net_03`: 3 - `net_08` <-> `net_09`: 3
- `net_00` <-> `net_03`: 2
- `net_01` <-> `net_03`: 2 - `net_01` <-> `net_03`: 2
- `net_06` <-> `net_08`: 2 - `net_06` <-> `net_08`: 2
- `net_06` <-> `net_09`: 2 - `net_06` <-> `net_09`: 2
- `net_07` <-> `net_08`: 2
Top component pairs by frequency: Top component pairs by frequency:
- `net_06[2]` <-> `net_07[2]`: 6
- `net_06[3]` <-> `net_07[2]`: 6 - `net_06[3]` <-> `net_07[2]`: 6
- `net_06[2]` <-> `net_07[2]`: 6
- `net_06[1]` <-> `net_07[1]`: 6 - `net_06[1]` <-> `net_07[1]`: 6
- `net_02[2]` <-> `net_03[3]`: 5
- `net_02[1]` <-> `net_03[1]`: 5
- `net_02[2]` <-> `net_03[2]`: 5
- `net_06[2]` <-> `net_07[1]`: 5 - `net_06[2]` <-> `net_07[1]`: 5
- `net_00[2]` <-> `net_01[3]`: 4 - `net_02[1]` <-> `net_03[2]`: 4
- `net_01[2]` <-> `net_02[2]`: 3 - `net_01[2]` <-> `net_02[2]`: 3
- `net_01[2]` <-> `net_02[3]`: 3 - `net_01[2]` <-> `net_02[3]`: 3
- `net_00[2]` <-> `net_01[2]`: 3
- `net_07[3]` <-> `net_08[2]`: 2
- `net_02[1]` <-> `net_03[1]`: 2

View file

@ -1,79 +1,81 @@
{ {
"generated_at": "2026-04-02T14:24:39-07:00", "generated_at": "2026-11-26T21:47:35-08:00",
"generator": "scripts/record_frontier_trace.py", "generator": "scripts/record_frontier_trace.py",
"scenarios": [ "scenarios": [
{ {
"frontier_trace": [], "frontier_trace": [],
"metrics": { "metrics": {
"congestion_cache_hits": 31, "congestion_cache_hits": 24,
"congestion_cache_misses": 4625, "congestion_cache_misses": 3411,
"congestion_candidate_ids": 9924, "congestion_candidate_ids": 7213,
"congestion_candidate_nets": 9979, "congestion_candidate_nets": 7410,
"congestion_candidate_precheck_hits": 2562, "congestion_candidate_precheck_hits": 1677,
"congestion_candidate_precheck_misses": 2165, "congestion_candidate_precheck_misses": 1795,
"congestion_candidate_precheck_skips": 71, "congestion_candidate_precheck_skips": 37,
"congestion_check_calls": 4625, "congestion_check_calls": 3411,
"congestion_exact_pair_checks": 8122, "congestion_exact_pair_checks": 5860,
"congestion_grid_net_cache_hits": 2457, "congestion_grid_net_cache_hits": 1676,
"congestion_grid_net_cache_misses": 3942, "congestion_grid_net_cache_misses": 3276,
"congestion_grid_span_cache_hits": 2283, "congestion_grid_span_cache_hits": 1517,
"congestion_grid_span_cache_misses": 1948, "congestion_grid_span_cache_misses": 1637,
"congestion_lazy_requeues": 0, "congestion_lazy_requeues": 0,
"congestion_lazy_resolutions": 0, "congestion_lazy_resolutions": 0,
"congestion_net_envelope_cache_hits": 2673, "congestion_net_envelope_cache_hits": 1801,
"congestion_net_envelope_cache_misses": 4139, "congestion_net_envelope_cache_misses": 3433,
"congestion_presence_cache_hits": 2858, "congestion_presence_cache_hits": 1857,
"congestion_presence_cache_misses": 2556, "congestion_presence_cache_misses": 2075,
"congestion_presence_skips": 687, "congestion_presence_skips": 460,
"danger_map_cache_hits": 16878, "danger_map_cache_hits": 13605,
"danger_map_cache_misses": 7425, "danger_map_cache_misses": 6252,
"danger_map_lookup_calls": 24303, "danger_map_lookup_calls": 19857,
"danger_map_query_calls": 7425, "danger_map_query_calls": 6252,
"danger_map_total_ns": 212814061, "danger_map_total_ns": 180793966,
"dynamic_grid_rebuilds": 0, "dynamic_grid_rebuilds": 0,
"dynamic_path_objects_added": 471, "dynamic_path_objects_added": 430,
"dynamic_path_objects_removed": 423, "dynamic_path_objects_removed": 384,
"dynamic_tree_rebuilds": 0, "dynamic_tree_rebuilds": 0,
"guidance_bonus_applied": 11000.0, "guidance_bonus_applied": 3275.0,
"guidance_bonus_applied_bend90": 3500.0, "guidance_bonus_applied_bend90": 1075.0,
"guidance_bonus_applied_sbend": 625.0, "guidance_bonus_applied_sbend": 200.0,
"guidance_bonus_applied_straight": 6875.0, "guidance_bonus_applied_straight": 2000.0,
"guidance_match_moves": 176, "guidance_match_moves": 131,
"guidance_match_moves_bend90": 56, "guidance_match_moves_bend90": 43,
"guidance_match_moves_sbend": 10, "guidance_match_moves_sbend": 8,
"guidance_match_moves_straight": 110, "guidance_match_moves_straight": 80,
"hard_collision_cache_hits": 0, "hard_collision_cache_hits": 0,
"iteration_conflict_edges": 39, "iteration_conflict_edges": 40,
"iteration_conflicting_nets": 36, "iteration_conflicting_nets": 39,
"iteration_reverified_nets": 60, "iteration_reverified_nets": 60,
"iteration_reverify_calls": 6, "iteration_reverify_calls": 6,
"move_cache_abs_hits": 2559, "late_phase_capped_fallbacks": 2,
"move_cache_abs_misses": 6494, "late_phase_capped_nets": 2,
"move_cache_rel_hits": 5872, "move_cache_abs_hits": 1831,
"move_cache_rel_misses": 622, "move_cache_abs_misses": 5516,
"moves_added": 8081, "move_cache_rel_hits": 4926,
"moves_generated": 9053, "move_cache_rel_misses": 590,
"nets_carried_forward": 0, "moves_added": 6594,
"nets_reached_target": 60, "moves_generated": 7347,
"nets_routed": 60, "nets_carried_forward": 6,
"nodes_expanded": 1764, "nets_reached_target": 52,
"nets_routed": 54,
"nodes_expanded": 1408,
"pair_local_search_accepts": 2, "pair_local_search_accepts": 2,
"pair_local_search_attempts": 2, "pair_local_search_attempts": 3,
"pair_local_search_nodes_expanded": 68, "pair_local_search_nodes_expanded": 42,
"pair_local_search_pairs_considered": 2, "pair_local_search_pairs_considered": 2,
"path_cost_calls": 0, "path_cost_calls": 0,
"pruned_closed_set": 439, "pruned_closed_set": 414,
"pruned_cost": 533, "pruned_cost": 339,
"pruned_hard_collision": 0, "pruned_hard_collision": 0,
"ray_cast_calls": 5477, "ray_cast_calls": 4577,
"ray_cast_calls_expand_forward": 1704, "ray_cast_calls_expand_forward": 1356,
"ray_cast_calls_expand_snap": 46, "ray_cast_calls_expand_snap": 36,
"ray_cast_calls_other": 0, "ray_cast_calls_other": 0,
"ray_cast_calls_straight_static": 3721, "ray_cast_calls_straight_static": 3179,
"ray_cast_calls_visibility_build": 0, "ray_cast_calls_visibility_build": 0,
"ray_cast_calls_visibility_query": 0, "ray_cast_calls_visibility_query": 0,
"ray_cast_calls_visibility_tangent": 6, "ray_cast_calls_visibility_tangent": 6,
"ray_cast_candidate_bounds": 305, "ray_cast_candidate_bounds": 162,
"ray_cast_exact_geometry_checks": 0, "ray_cast_exact_geometry_checks": 0,
"refine_path_calls": 10, "refine_path_calls": 10,
"refinement_candidate_side_extents": 0, "refinement_candidate_side_extents": 0,
@ -84,17 +86,17 @@
"refinement_static_bounds_checked": 0, "refinement_static_bounds_checked": 0,
"refinement_windows_considered": 0, "refinement_windows_considered": 0,
"route_iterations": 6, "route_iterations": 6,
"score_component_calls": 8634, "score_component_calls": 6958,
"score_component_total_ns": 241025335, "score_component_total_ns": 205362623,
"static_net_tree_rebuilds": 1, "static_net_tree_rebuilds": 1,
"static_raw_tree_rebuilds": 1, "static_raw_tree_rebuilds": 1,
"static_safe_cache_hits": 2482, "static_safe_cache_hits": 1778,
"static_tree_rebuilds": 1, "static_tree_rebuilds": 1,
"timeout_events": 0, "timeout_events": 0,
"verify_dynamic_candidate_nets": 2106, "verify_dynamic_candidate_nets": 1638,
"verify_dynamic_exact_pair_checks": 558, "verify_dynamic_exact_pair_checks": 507,
"verify_path_report_calls": 190, "verify_path_report_calls": 152,
"verify_static_buffer_ops": 895, "verify_static_buffer_ops": 699,
"visibility_builds": 0, "visibility_builds": 0,
"visibility_corner_hits_exact": 0, "visibility_corner_hits_exact": 0,
"visibility_corner_index_builds": 1, "visibility_corner_index_builds": 1,
@ -105,7 +107,7 @@
"visibility_point_queries": 0, "visibility_point_queries": 0,
"visibility_tangent_candidate_corner_checks": 6, "visibility_tangent_candidate_corner_checks": 6,
"visibility_tangent_candidate_ray_tests": 6, "visibility_tangent_candidate_ray_tests": 6,
"visibility_tangent_candidate_scans": 1704, "visibility_tangent_candidate_scans": 1356,
"warm_start_paths_built": 0, "warm_start_paths_built": 0,
"warm_start_paths_used": 0 "warm_start_paths_used": 0
}, },

View file

@ -1,6 +1,6 @@
# Frontier Trace # Frontier Trace
Generated at 2026-04-02T14:24:39-07:00 by `scripts/record_frontier_trace.py`. Generated at 2026-11-26T21:47:35-08:00 by `scripts/record_frontier_trace.py`.
## example_07_large_scale_routing_no_warm_start ## example_07_large_scale_routing_no_warm_start

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
# Iteration Trace # Iteration Trace
Generated at 2026-04-02T18:51:01-07:00 by `scripts/record_iteration_trace.py`. Generated at 2026-11-26T21:47:40-08:00 by `scripts/record_iteration_trace.py`.
## example_07_large_scale_routing_no_warm_start ## example_07_large_scale_routing_no_warm_start
@ -9,36 +9,37 @@ Results: 10 valid / 10 reached / 10 total.
| Iteration | Penalty | Routed Nets | Completed | Conflict Edges | Dynamic Collisions | Nodes | Congestion Checks | Candidate Ids | Exact Pairs | | Iteration | Penalty | Routed Nets | Completed | Conflict Edges | Dynamic Collisions | Nodes | Congestion Checks | Candidate Ids | Exact Pairs |
| --: | --: | --: | --: | --: | --: | --: | --: | --: | --: | | --: | --: | --: | --: | --: | --: | --: | --: | --: | --: |
| 0 | 100.0 | 10 | 1 | 16 | 50 | 571 | 0 | 0 | 0 | | 0 | 100.0 | 10 | 1 | 16 | 50 | 571 | 0 | 0 | 0 |
| 1 | 140.0 | 10 | 2 | 12 | 54 | 253 | 974 | 2378 | 1998 | | 1 | 140.0 | 10 | 2 | 12 | 54 | 269 | 1074 | 2581 | 2150 |
| 2 | 196.0 | 10 | 4 | 5 | 22 | 253 | 993 | 1928 | 1571 | | 2 | 196.0 | 10 | 5 | 4 | 18 | 244 | 980 | 1868 | 1539 |
| 3 | 274.4 | 10 | 6 | 2 | 10 | 100 | 437 | 852 | 698 | | 3 | 274.4 | 10 | 2 | 4 | 20 | 95 | 483 | 977 | 749 |
| 4 | 384.2 | 4 | 6 | 2 | 10 | 81 | 332 | 627 | 513 | | 4 | 384.2 | 10 | 6 | 2 | 10 | 196 | 703 | 1370 | 1137 |
| 5 | 537.8 | 4 | 6 | 2 | 10 | 33 | 171 | 417 | 285 |
Top nets by iteration-attributed nodes expanded: Top nets by iteration-attributed nodes expanded:
- `net_09`: 242 - `net_09`: 249
- `net_00`: 201 - `net_03`: 217
- `net_02`: 157 - `net_00`: 213
- `net_06`: 155 - `net_08`: 159
- `net_01`: 147 - `net_02`: 158
- `net_08`: 144 - `net_06`: 151
- `net_03`: 141 - `net_01`: 129
- `net_07`: 45 - `net_07`: 91
- `net_04`: 13 - `net_04`: 21
- `net_05`: 13 - `net_05`: 20
Top nets by iteration-attributed congestion checks: Top nets by iteration-attributed congestion checks:
- `net_06`: 569 - `net_03`: 687
- `net_02`: 514 - `net_06`: 545
- `net_01`: 468 - `net_02`: 538
- `net_03`: 425 - `net_01`: 433
- `net_00`: 203 - `net_07`: 358
- `net_08`: 170 - `net_08`: 254
- `net_07`: 143 - `net_00`: 219
- `net_09`: 124 - `net_09`: 165
- `net_04`: 60 - `net_04`: 108
- `net_05`: 60 - `net_05`: 104
## example_07_large_scale_routing_no_warm_start_seed43 ## example_07_large_scale_routing_no_warm_start_seed43
@ -47,35 +48,35 @@ Results: 10 valid / 10 reached / 10 total.
| Iteration | Penalty | Routed Nets | Completed | Conflict Edges | Dynamic Collisions | Nodes | Congestion Checks | Candidate Ids | Exact Pairs | | Iteration | Penalty | Routed Nets | Completed | Conflict Edges | Dynamic Collisions | Nodes | Congestion Checks | Candidate Ids | Exact Pairs |
| --: | --: | --: | --: | --: | --: | --: | --: | --: | --: | | --: | --: | --: | --: | --: | --: | --: | --: | --: | --: |
| 0 | 100.0 | 10 | 1 | 16 | 50 | 571 | 0 | 0 | 0 | | 0 | 100.0 | 10 | 1 | 16 | 50 | 571 | 0 | 0 | 0 |
| 1 | 140.0 | 10 | 1 | 13 | 53 | 269 | 961 | 2562 | 2032 | | 1 | 140.0 | 10 | 1 | 13 | 53 | 281 | 1037 | 2807 | 2205 |
| 2 | 196.0 | 10 | 4 | 3 | 15 | 140 | 643 | 1610 | 1224 | | 2 | 196.0 | 10 | 4 | 3 | 15 | 157 | 697 | 1678 | 1289 |
| 3 | 274.4 | 6 | 4 | 3 | 15 | 54 | 250 | 557 | 428 | | 3 | 274.4 | 6 | 4 | 3 | 15 | 59 | 277 | 610 | 455 |
| 4 | 384.2 | 6 | 6 | 2 | 10 | 136 | 505 | 1025 | 829 | | 4 | 384.2 | 6 | 6 | 2 | 10 | 167 | 584 | 1201 | 958 |
| 5 | 537.8 | 4 | 6 | 2 | 10 | 33 | 171 | 419 | 287 | | 5 | 537.8 | 4 | 6 | 2 | 10 | 33 | 171 | 419 | 287 |
Top nets by iteration-attributed nodes expanded: Top nets by iteration-attributed nodes expanded:
- `net_09`: 250 - `net_09`: 248
- `net_03`: 199 - `net_03`: 219
- `net_00`: 177 - `net_00`: 176
- `net_08`: 166 - `net_08`: 168
- `net_07`: 140 - `net_07`: 140
- `net_06`: 105 - `net_06`: 130
- `net_02`: 79 - `net_02`: 97
- `net_01`: 65 - `net_01`: 65
- `net_05`: 12 - `net_05`: 13
- `net_04`: 10 - `net_04`: 12
Top nets by iteration-attributed congestion checks: Top nets by iteration-attributed congestion checks:
- `net_03`: 639 - `net_03`: 695
- `net_07`: 454 - `net_07`: 454
- `net_06`: 382 - `net_06`: 449
- `net_02`: 290 - `net_02`: 368
- `net_08`: 283 - `net_08`: 302
- `net_09`: 178 - `net_09`: 178
- `net_01`: 135 - `net_01`: 136
- `net_00`: 82 - `net_00`: 75
- `net_05`: 47 - `net_05`: 55
- `net_04`: 40 - `net_04`: 54

View file

@ -1,23 +1,21 @@
# Performance Baseline # Performance Baseline
Generated on 2026-04-02 by `scripts/record_performance_baseline.py`. Generated on 2026-11-26 by `scripts/record_performance_baseline.py`.
The full machine-readable snapshot is in [performance_baseline.json](performance_baseline.json). The full machine-readable snapshot is in [performance_baseline.json](performance_baseline.json).
Use `scripts/diff_performance_baseline.py` to compare a fresh run against that snapshot. Use `scripts/diff_performance_baseline.py` to compare a fresh run against that snapshot.
The default table below intentionally excludes the heavier performance-only no-warm `example_07` canaries. Use `scripts/record_iteration_trace.py` and `scripts/record_pre_pair_frontier_trace.py` to inspect the late negotiated-congestion basin and pair-local handoff behavior for those scenarios.
| Scenario | Duration (s) | Total | Valid | Reached | Iter | Nets Routed | Nodes | Ray Casts | Moves Gen | Moves Added | Dyn Tree | Visibility Builds | Congestion Checks | Verify Calls | | Scenario | Duration (s) | Total | Valid | Reached | Iter | Nets Routed | Nodes | Ray Casts | Moves Gen | Moves Added | Dyn Tree | Visibility Builds | Congestion Checks | Verify Calls |
| :-- | --: | --: | --: | --: | --: | --: | --: | --: | --: | --: | --: | --: | --: | --: | | :-- | --: | --: | --: | --: | --: | --: | --: | --: | --: | --: | --: | --: | --: | --: |
| example_01_simple_route | 0.0037 | 1 | 1 | 1 | 1 | 1 | 2 | 10 | 11 | 7 | 0 | 0 | 0 | 5 | | example_01_simple_route | 0.0043 | 1 | 1 | 1 | 1 | 1 | 2 | 10 | 11 | 7 | 0 | 0 | 0 | 4 |
| example_02_congestion_resolution | 0.3361 | 3 | 3 | 3 | 1 | 3 | 366 | 1164 | 1413 | 668 | 0 | 0 | 0 | 41 | | example_02_congestion_resolution | 0.2536 | 3 | 3 | 3 | 1 | 3 | 366 | 1164 | 1413 | 668 | 0 | 0 | 0 | 16 |
| example_03_locked_paths | 0.1877 | 2 | 2 | 2 | 2 | 2 | 191 | 657 | 904 | 307 | 0 | 0 | 0 | 18 | | example_03_locked_paths | 0.1450 | 2 | 2 | 2 | 2 | 2 | 191 | 657 | 904 | 307 | 0 | 0 | 0 | 10 |
| example_04_sbends_and_radii | 0.0269 | 2 | 2 | 2 | 1 | 2 | 15 | 70 | 123 | 65 | 0 | 0 | 0 | 10 | | example_04_sbends_and_radii | 0.0217 | 2 | 2 | 2 | 1 | 2 | 15 | 70 | 123 | 65 | 0 | 0 | 0 | 8 |
| example_05_orientation_stress | 0.2311 | 3 | 3 | 3 | 2 | 5 | 297 | 1274 | 1680 | 689 | 0 | 0 | 146 | 20 | | example_05_orientation_stress | 0.1859 | 3 | 3 | 3 | 2 | 5 | 297 | 1274 | 1680 | 689 | 0 | 0 | 146 | 17 |
| example_06_bend_collision_models | 0.1988 | 3 | 3 | 3 | 3 | 3 | 240 | 682 | 1026 | 629 | 0 | 0 | 0 | 15 | | example_06_bend_collision_models | 0.1723 | 3 | 3 | 3 | 3 | 3 | 240 | 682 | 1026 | 629 | 0 | 0 | 0 | 12 |
| example_07_large_scale_routing | 0.2088 | 10 | 10 | 10 | 1 | 10 | 78 | 383 | 372 | 227 | 0 | 0 | 0 | 50 | | example_07_large_scale_routing | 0.1860 | 10 | 10 | 10 | 1 | 10 | 78 | 383 | 372 | 227 | 0 | 0 | 0 | 40 |
| example_08_custom_bend_geometry | 0.0177 | 2 | 2 | 2 | 2 | 2 | 18 | 56 | 78 | 56 | 0 | 0 | 0 | 10 | | example_08_custom_bend_geometry | 0.0152 | 2 | 2 | 2 | 2 | 2 | 18 | 56 | 78 | 56 | 0 | 0 | 0 | 8 |
| example_09_unroutable_best_effort | 0.0057 | 1 | 0 | 0 | 1 | 1 | 3 | 13 | 16 | 10 | 0 | 0 | 0 | 1 | | example_09_unroutable_best_effort | 0.0053 | 1 | 0 | 0 | 1 | 1 | 3 | 13 | 16 | 10 | 0 | 0 | 0 | 1 |
## Full Counter Set ## Full Counter Set

View file

@ -1,9 +1,9 @@
{ {
"generated_on": "2026-04-02", "generated_on": "2026-11-26",
"generator": "scripts/record_performance_baseline.py", "generator": "scripts/record_performance_baseline.py",
"scenarios": [ "scenarios": [
{ {
"duration_s": 0.003715757979080081, "duration_s": 0.004315305966883898,
"metrics": { "metrics": {
"congestion_cache_hits": 0, "congestion_cache_hits": 0,
"congestion_cache_misses": 0, "congestion_cache_misses": 0,
@ -87,7 +87,7 @@
"refinement_windows_considered": 0, "refinement_windows_considered": 0,
"route_iterations": 1, "route_iterations": 1,
"score_component_calls": 11, "score_component_calls": 11,
"score_component_total_ns": 16864, "score_component_total_ns": 19890,
"static_net_tree_rebuilds": 1, "static_net_tree_rebuilds": 1,
"static_raw_tree_rebuilds": 0, "static_raw_tree_rebuilds": 0,
"static_safe_cache_hits": 1, "static_safe_cache_hits": 1,
@ -95,7 +95,7 @@
"timeout_events": 0, "timeout_events": 0,
"verify_dynamic_candidate_nets": 0, "verify_dynamic_candidate_nets": 0,
"verify_dynamic_exact_pair_checks": 0, "verify_dynamic_exact_pair_checks": 0,
"verify_path_report_calls": 5, "verify_path_report_calls": 4,
"verify_static_buffer_ops": 0, "verify_static_buffer_ops": 0,
"visibility_builds": 0, "visibility_builds": 0,
"visibility_corner_hits_exact": 0, "visibility_corner_hits_exact": 0,
@ -117,7 +117,7 @@
"valid_results": 1 "valid_results": 1
}, },
{ {
"duration_s": 0.33605348505079746, "duration_s": 0.25360398599877954,
"metrics": { "metrics": {
"congestion_cache_hits": 0, "congestion_cache_hits": 0,
"congestion_cache_misses": 0, "congestion_cache_misses": 0,
@ -177,7 +177,7 @@
"pair_local_search_attempts": 0, "pair_local_search_attempts": 0,
"pair_local_search_nodes_expanded": 0, "pair_local_search_nodes_expanded": 0,
"pair_local_search_pairs_considered": 0, "pair_local_search_pairs_considered": 0,
"path_cost_calls": 14, "path_cost_calls": 30,
"pruned_closed_set": 157, "pruned_closed_set": 157,
"pruned_cost": 208, "pruned_cost": 208,
"pruned_hard_collision": 380, "pruned_hard_collision": 380,
@ -194,22 +194,22 @@
"refine_path_calls": 3, "refine_path_calls": 3,
"refinement_candidate_side_extents": 26, "refinement_candidate_side_extents": 26,
"refinement_candidates_accepted": 2, "refinement_candidates_accepted": 2,
"refinement_candidates_built": 26, "refinement_candidates_built": 2,
"refinement_candidates_verified": 26, "refinement_candidates_verified": 2,
"refinement_dynamic_bounds_checked": 20, "refinement_dynamic_bounds_checked": 20,
"refinement_static_bounds_checked": 0, "refinement_static_bounds_checked": 0,
"refinement_windows_considered": 10, "refinement_windows_considered": 4,
"route_iterations": 1, "route_iterations": 1,
"score_component_calls": 976, "score_component_calls": 1088,
"score_component_total_ns": 1109505, "score_component_total_ns": 1145758,
"static_net_tree_rebuilds": 3, "static_net_tree_rebuilds": 3,
"static_raw_tree_rebuilds": 0, "static_raw_tree_rebuilds": 0,
"static_safe_cache_hits": 1, "static_safe_cache_hits": 1,
"static_tree_rebuilds": 2, "static_tree_rebuilds": 2,
"timeout_events": 0, "timeout_events": 0,
"verify_dynamic_candidate_nets": 92, "verify_dynamic_candidate_nets": 14,
"verify_dynamic_exact_pair_checks": 90, "verify_dynamic_exact_pair_checks": 12,
"verify_path_report_calls": 41, "verify_path_report_calls": 16,
"verify_static_buffer_ops": 0, "verify_static_buffer_ops": 0,
"visibility_builds": 0, "visibility_builds": 0,
"visibility_corner_hits_exact": 0, "visibility_corner_hits_exact": 0,
@ -231,7 +231,7 @@
"valid_results": 3 "valid_results": 3
}, },
{ {
"duration_s": 0.18771230895072222, "duration_s": 0.14500006497837603,
"metrics": { "metrics": {
"congestion_cache_hits": 0, "congestion_cache_hits": 0,
"congestion_cache_misses": 0, "congestion_cache_misses": 0,
@ -291,7 +291,7 @@
"pair_local_search_attempts": 0, "pair_local_search_attempts": 0,
"pair_local_search_nodes_expanded": 0, "pair_local_search_nodes_expanded": 0,
"pair_local_search_pairs_considered": 0, "pair_local_search_pairs_considered": 0,
"path_cost_calls": 9, "path_cost_calls": 10,
"pruned_closed_set": 97, "pruned_closed_set": 97,
"pruned_cost": 140, "pruned_cost": 140,
"pruned_hard_collision": 181, "pruned_hard_collision": 181,
@ -308,23 +308,23 @@
"refine_path_calls": 2, "refine_path_calls": 2,
"refinement_candidate_side_extents": 8, "refinement_candidate_side_extents": 8,
"refinement_candidates_accepted": 1, "refinement_candidates_accepted": 1,
"refinement_candidates_built": 8, "refinement_candidates_built": 1,
"refinement_candidates_verified": 8, "refinement_candidates_verified": 1,
"refinement_dynamic_bounds_checked": 2, "refinement_dynamic_bounds_checked": 2,
"refinement_static_bounds_checked": 2, "refinement_static_bounds_checked": 2,
"refinement_windows_considered": 2, "refinement_windows_considered": 2,
"route_iterations": 2, "route_iterations": 2,
"score_component_calls": 504, "score_component_calls": 510,
"score_component_total_ns": 546567, "score_component_total_ns": 545847,
"static_net_tree_rebuilds": 2, "static_net_tree_rebuilds": 2,
"static_raw_tree_rebuilds": 1, "static_raw_tree_rebuilds": 1,
"static_safe_cache_hits": 1, "static_safe_cache_hits": 1,
"static_tree_rebuilds": 1, "static_tree_rebuilds": 1,
"timeout_events": 0, "timeout_events": 0,
"verify_dynamic_candidate_nets": 10, "verify_dynamic_candidate_nets": 8,
"verify_dynamic_exact_pair_checks": 10, "verify_dynamic_exact_pair_checks": 8,
"verify_path_report_calls": 18, "verify_path_report_calls": 10,
"verify_static_buffer_ops": 90, "verify_static_buffer_ops": 48,
"visibility_builds": 0, "visibility_builds": 0,
"visibility_corner_hits_exact": 0, "visibility_corner_hits_exact": 0,
"visibility_corner_index_builds": 2, "visibility_corner_index_builds": 2,
@ -345,7 +345,7 @@
"valid_results": 2 "valid_results": 2
}, },
{ {
"duration_s": 0.026945222169160843, "duration_s": 0.021677320008166134,
"metrics": { "metrics": {
"congestion_cache_hits": 0, "congestion_cache_hits": 0,
"congestion_cache_misses": 0, "congestion_cache_misses": 0,
@ -429,15 +429,15 @@
"refinement_windows_considered": 0, "refinement_windows_considered": 0,
"route_iterations": 1, "route_iterations": 1,
"score_component_calls": 90, "score_component_calls": 90,
"score_component_total_ns": 97710, "score_component_total_ns": 94482,
"static_net_tree_rebuilds": 2, "static_net_tree_rebuilds": 2,
"static_raw_tree_rebuilds": 0, "static_raw_tree_rebuilds": 0,
"static_safe_cache_hits": 1, "static_safe_cache_hits": 1,
"static_tree_rebuilds": 1, "static_tree_rebuilds": 1,
"timeout_events": 0, "timeout_events": 0,
"verify_dynamic_candidate_nets": 12, "verify_dynamic_candidate_nets": 9,
"verify_dynamic_exact_pair_checks": 0, "verify_dynamic_exact_pair_checks": 0,
"verify_path_report_calls": 10, "verify_path_report_calls": 8,
"verify_static_buffer_ops": 0, "verify_static_buffer_ops": 0,
"visibility_builds": 0, "visibility_builds": 0,
"visibility_corner_hits_exact": 0, "visibility_corner_hits_exact": 0,
@ -459,7 +459,7 @@
"valid_results": 2 "valid_results": 2
}, },
{ {
"duration_s": 0.23108969815075397, "duration_s": 0.18591969890985638,
"metrics": { "metrics": {
"congestion_cache_hits": 3, "congestion_cache_hits": 3,
"congestion_cache_misses": 146, "congestion_cache_misses": 146,
@ -543,7 +543,7 @@
"refinement_windows_considered": 0, "refinement_windows_considered": 0,
"route_iterations": 2, "route_iterations": 2,
"score_component_calls": 1234, "score_component_calls": 1234,
"score_component_total_ns": 1223569, "score_component_total_ns": 1189711,
"static_net_tree_rebuilds": 3, "static_net_tree_rebuilds": 3,
"static_raw_tree_rebuilds": 0, "static_raw_tree_rebuilds": 0,
"static_safe_cache_hits": 8, "static_safe_cache_hits": 8,
@ -551,7 +551,7 @@
"timeout_events": 0, "timeout_events": 0,
"verify_dynamic_candidate_nets": 8, "verify_dynamic_candidate_nets": 8,
"verify_dynamic_exact_pair_checks": 12, "verify_dynamic_exact_pair_checks": 12,
"verify_path_report_calls": 20, "verify_path_report_calls": 17,
"verify_static_buffer_ops": 0, "verify_static_buffer_ops": 0,
"visibility_builds": 0, "visibility_builds": 0,
"visibility_corner_hits_exact": 0, "visibility_corner_hits_exact": 0,
@ -573,7 +573,7 @@
"valid_results": 3 "valid_results": 3
}, },
{ {
"duration_s": 0.19879506202414632, "duration_s": 0.1722618379862979,
"metrics": { "metrics": {
"congestion_cache_hits": 0, "congestion_cache_hits": 0,
"congestion_cache_misses": 0, "congestion_cache_misses": 0,
@ -599,7 +599,7 @@
"danger_map_cache_misses": 731, "danger_map_cache_misses": 731,
"danger_map_lookup_calls": 1914, "danger_map_lookup_calls": 1914,
"danger_map_query_calls": 731, "danger_map_query_calls": 731,
"danger_map_total_ns": 19050142, "danger_map_total_ns": 18541396,
"dynamic_grid_rebuilds": 0, "dynamic_grid_rebuilds": 0,
"dynamic_path_objects_added": 54, "dynamic_path_objects_added": 54,
"dynamic_path_objects_removed": 36, "dynamic_path_objects_removed": 36,
@ -645,7 +645,7 @@
"ray_cast_calls_visibility_build": 0, "ray_cast_calls_visibility_build": 0,
"ray_cast_calls_visibility_query": 0, "ray_cast_calls_visibility_query": 0,
"ray_cast_calls_visibility_tangent": 34, "ray_cast_calls_visibility_tangent": 34,
"ray_cast_candidate_bounds": 97, "ray_cast_candidate_bounds": 88,
"ray_cast_exact_geometry_checks": 0, "ray_cast_exact_geometry_checks": 0,
"refine_path_calls": 3, "refine_path_calls": 3,
"refinement_candidate_side_extents": 0, "refinement_candidate_side_extents": 0,
@ -657,7 +657,7 @@
"refinement_windows_considered": 0, "refinement_windows_considered": 0,
"route_iterations": 3, "route_iterations": 3,
"score_component_calls": 842, "score_component_calls": 842,
"score_component_total_ns": 21353240, "score_component_total_ns": 20820878,
"static_net_tree_rebuilds": 3, "static_net_tree_rebuilds": 3,
"static_raw_tree_rebuilds": 3, "static_raw_tree_rebuilds": 3,
"static_safe_cache_hits": 141, "static_safe_cache_hits": 141,
@ -665,8 +665,8 @@
"timeout_events": 0, "timeout_events": 0,
"verify_dynamic_candidate_nets": 0, "verify_dynamic_candidate_nets": 0,
"verify_dynamic_exact_pair_checks": 0, "verify_dynamic_exact_pair_checks": 0,
"verify_path_report_calls": 15, "verify_path_report_calls": 12,
"verify_static_buffer_ops": 90, "verify_static_buffer_ops": 72,
"visibility_builds": 0, "visibility_builds": 0,
"visibility_corner_hits_exact": 0, "visibility_corner_hits_exact": 0,
"visibility_corner_index_builds": 3, "visibility_corner_index_builds": 3,
@ -687,7 +687,7 @@
"valid_results": 3 "valid_results": 3
}, },
{ {
"duration_s": 0.20880168909206986, "duration_s": 0.18596431298647076,
"metrics": { "metrics": {
"congestion_cache_hits": 0, "congestion_cache_hits": 0,
"congestion_cache_misses": 0, "congestion_cache_misses": 0,
@ -713,7 +713,7 @@
"danger_map_cache_misses": 448, "danger_map_cache_misses": 448,
"danger_map_lookup_calls": 681, "danger_map_lookup_calls": 681,
"danger_map_query_calls": 448, "danger_map_query_calls": 448,
"danger_map_total_ns": 11025527, "danger_map_total_ns": 10931551,
"dynamic_grid_rebuilds": 0, "dynamic_grid_rebuilds": 0,
"dynamic_path_objects_added": 132, "dynamic_path_objects_added": 132,
"dynamic_path_objects_removed": 88, "dynamic_path_objects_removed": 88,
@ -771,16 +771,16 @@
"refinement_windows_considered": 0, "refinement_windows_considered": 0,
"route_iterations": 1, "route_iterations": 1,
"score_component_calls": 291, "score_component_calls": 291,
"score_component_total_ns": 11875928, "score_component_total_ns": 11785678,
"static_net_tree_rebuilds": 10, "static_net_tree_rebuilds": 10,
"static_raw_tree_rebuilds": 1, "static_raw_tree_rebuilds": 1,
"static_safe_cache_hits": 6, "static_safe_cache_hits": 6,
"static_tree_rebuilds": 10, "static_tree_rebuilds": 10,
"timeout_events": 0, "timeout_events": 0,
"verify_dynamic_candidate_nets": 476, "verify_dynamic_candidate_nets": 370,
"verify_dynamic_exact_pair_checks": 72, "verify_dynamic_exact_pair_checks": 56,
"verify_path_report_calls": 50, "verify_path_report_calls": 40,
"verify_static_buffer_ops": 220, "verify_static_buffer_ops": 176,
"visibility_builds": 0, "visibility_builds": 0,
"visibility_corner_hits_exact": 0, "visibility_corner_hits_exact": 0,
"visibility_corner_index_builds": 10, "visibility_corner_index_builds": 10,
@ -801,7 +801,7 @@
"valid_results": 10 "valid_results": 10
}, },
{ {
"duration_s": 0.017696003895252943, "duration_s": 0.015218257089145482,
"metrics": { "metrics": {
"congestion_cache_hits": 0, "congestion_cache_hits": 0,
"congestion_cache_misses": 0, "congestion_cache_misses": 0,
@ -885,7 +885,7 @@
"refinement_windows_considered": 0, "refinement_windows_considered": 0,
"route_iterations": 2, "route_iterations": 2,
"score_component_calls": 72, "score_component_calls": 72,
"score_component_total_ns": 87742, "score_component_total_ns": 84457,
"static_net_tree_rebuilds": 2, "static_net_tree_rebuilds": 2,
"static_raw_tree_rebuilds": 0, "static_raw_tree_rebuilds": 0,
"static_safe_cache_hits": 2, "static_safe_cache_hits": 2,
@ -893,7 +893,7 @@
"timeout_events": 0, "timeout_events": 0,
"verify_dynamic_candidate_nets": 0, "verify_dynamic_candidate_nets": 0,
"verify_dynamic_exact_pair_checks": 0, "verify_dynamic_exact_pair_checks": 0,
"verify_path_report_calls": 10, "verify_path_report_calls": 8,
"verify_static_buffer_ops": 0, "verify_static_buffer_ops": 0,
"visibility_builds": 0, "visibility_builds": 0,
"visibility_corner_hits_exact": 0, "visibility_corner_hits_exact": 0,
@ -915,7 +915,7 @@
"valid_results": 2 "valid_results": 2
}, },
{ {
"duration_s": 0.005660973023623228, "duration_s": 0.005253698094747961,
"metrics": { "metrics": {
"congestion_cache_hits": 0, "congestion_cache_hits": 0,
"congestion_cache_misses": 0, "congestion_cache_misses": 0,
@ -941,7 +941,7 @@
"danger_map_cache_misses": 20, "danger_map_cache_misses": 20,
"danger_map_lookup_calls": 30, "danger_map_lookup_calls": 30,
"danger_map_query_calls": 20, "danger_map_query_calls": 20,
"danger_map_total_ns": 515133, "danger_map_total_ns": 504814,
"dynamic_grid_rebuilds": 0, "dynamic_grid_rebuilds": 0,
"dynamic_path_objects_added": 2, "dynamic_path_objects_added": 2,
"dynamic_path_objects_removed": 1, "dynamic_path_objects_removed": 1,
@ -999,7 +999,7 @@
"refinement_windows_considered": 0, "refinement_windows_considered": 0,
"route_iterations": 1, "route_iterations": 1,
"score_component_calls": 14, "score_component_calls": 14,
"score_component_total_ns": 554809, "score_component_total_ns": 543596,
"static_net_tree_rebuilds": 1, "static_net_tree_rebuilds": 1,
"static_raw_tree_rebuilds": 1, "static_raw_tree_rebuilds": 1,
"static_safe_cache_hits": 0, "static_safe_cache_hits": 0,

File diff suppressed because it is too large Load diff

View file

@ -1,25 +1,25 @@
# Pre-Pair Frontier Trace # Pre-Pair Frontier Trace
Generated at 2026-04-02T18:51:01-07:00 by `scripts/record_pre_pair_frontier_trace.py`. Generated at 2026-11-26T21:47:45-08:00 by `scripts/record_pre_pair_frontier_trace.py`.
## example_07_large_scale_routing_no_warm_start ## example_07_large_scale_routing_no_warm_start
Results: 10 valid / 10 reached / 10 total. Results: 10 valid / 10 reached / 10 total.
Captured iteration: `4` Captured iteration: `5`
Conflict edges: `(('net_01', 'net_02'), ('net_06', 'net_07'))` Conflict edges: `(('net_02', 'net_03'), ('net_06', 'net_07'))`
| Net | Nodes | Checks | Closed-Set | Cost | Hard Collision | Guidance Seed | Frontier Samples | | Net | Nodes | Checks | Closed-Set | Cost | Hard Collision | Guidance Seed | Frontier Samples |
| :-- | --: | --: | --: | --: | --: | :--: | --: | | :-- | --: | --: | --: | --: | --: | :--: | --: |
| net_07 | 7 | 30 | 1 | 0 | 0 | yes | 0 | | net_07 | 16 | 85 | 3 | 0 | 0 | yes | 2 |
| net_06 | 46 | 179 | 7 | 15 | 0 | yes | 5 | | net_02 | 17 | 86 | 4 | 0 | 0 | yes | 3 |
| net_00 | 10 | 43 | 1 | 0 | 0 | yes | 0 | | net_06 | 0 | 0 | 0 | 0 | 0 | yes | 10 |
| net_01 | 18 | 80 | 3 | 0 | 0 | yes | 0 | | net_03 | 0 | 0 | 0 | 0 | 0 | yes | 16 |
Frontier prune totals by reason: Frontier prune totals by reason:
- `closed_set`: 5 - `closed_set`: 31
- `hard_collision`: 0 - `hard_collision`: 0
- `self_collision`: 0 - `self_collision`: 0
- `cost`: 0 - `cost`: 0
@ -36,12 +36,12 @@ Conflict edges: `(('net_02', 'net_03'), ('net_06', 'net_07'))`
| :-- | --: | --: | --: | --: | --: | :--: | --: | | :-- | --: | --: | --: | --: | --: | :--: | --: |
| net_07 | 16 | 85 | 3 | 0 | 0 | yes | 2 | | net_07 | 16 | 85 | 3 | 0 | 0 | yes | 2 |
| net_02 | 17 | 86 | 4 | 0 | 0 | yes | 3 | | net_02 | 17 | 86 | 4 | 0 | 0 | yes | 3 |
| net_06 | 0 | 0 | 0 | 0 | 0 | yes | 8 | | net_06 | 0 | 0 | 0 | 0 | 0 | yes | 10 |
| net_03 | 0 | 0 | 0 | 0 | 0 | yes | 12 | | net_03 | 0 | 0 | 0 | 0 | 0 | yes | 14 |
Frontier prune totals by reason: Frontier prune totals by reason:
- `closed_set`: 25 - `closed_set`: 29
- `hard_collision`: 0 - `hard_collision`: 0
- `self_collision`: 0 - `self_collision`: 0
- `cost`: 0 - `cost`: 0

View file

@ -42,7 +42,7 @@ Capture the no-warm-start fan-out scenario from the repository root.
```sh ```sh
python -m scripts.record_iteration_trace --scenario example_07_large_scale_routing_no_warm_start \ python -m scripts.record_iteration_trace --scenario example_07_large_scale_routing_no_warm_start \
--include-performance-only --output-dir /tmp/inire-trace --output-dir /tmp/inire-trace
``` ```
1. Open the generated `iteration_trace.md`. Compare the last iteration's completed count and conflict edges with the final result summary. In the recorded example, the last iteration had six completed nets and two conflict edges. 1. Open the generated `iteration_trace.md`. Compare the last iteration's completed count and conflict edges with the final result summary. In the recorded example, the last iteration had six completed nets and two conflict edges.
@ -64,6 +64,6 @@ python -m scripts.routing_benchmark_parity capture /tmp/routing-after.json --cas
python -m scripts.routing_benchmark_parity compare /tmp/routing-before.json /tmp/routing-after.json python -m scripts.routing_benchmark_parity compare /tmp/routing-before.json /tmp/routing-after.json
``` ```
Use `scripts.record_iteration_trace` and `scripts.record_pre_pair_frontier_trace` to inspect a late conflict. Use `scripts.record_conflict_trace` and `scripts.record_frontier_trace` to locate an overlap and inspect rejected moves near it. Pass `--output-dir /tmp/inire-trace` for a scratch capture. The trace writers support `--scenario` for an individual built-in case and `--include-performance-only` for the heavier cases. Use `scripts.record_iteration_trace` and `scripts.record_pre_pair_frontier_trace` to inspect a late conflict. Use `scripts.record_conflict_trace` and `scripts.record_frontier_trace` to locate an overlap and inspect rejected moves near it. Pass `--output-dir /tmp/inire-trace` for a scratch capture. Select any built-in trace case by name with `--scenario`.
For isolated timing gates, run `INIRE_RUN_PERFORMANCE=1 python -m pytest -q inire/tests/test_example_performance.py`. Use `scripts.record_performance_baseline` with `--output-dir` to record a snapshot. Use `scripts.diff_performance_baseline` to compare a fresh run with the archived baseline, or pass `--baseline` to select a different snapshot. Use `--metric` to select counters. [Routing development archive](../archive/routing/README.md) For isolated timing gates, run `INIRE_RUN_PERFORMANCE=1 python -m pytest -q inire/tests/test_example_performance.py`. Use `scripts.record_performance_baseline` with `--output-dir` to record a snapshot. Use `scripts.diff_performance_baseline` to compare a fresh run with the archived baseline, or pass `--baseline` to select a different snapshot. Use `--metric` to select counters. [Routing development archive](../archive/routing/README.md)

View file

@ -142,12 +142,6 @@ class RoutingWorld:
def _ensure_static_raw_tree(self) -> None: def _ensure_static_raw_tree(self) -> None:
self._static_obstacles.ensure_raw_tree() self._static_obstacles.ensure_raw_tree()
def _ensure_dynamic_tree(self) -> None:
self._dynamic_paths.ensure_tree()
def _ensure_dynamic_grid(self) -> None:
self._dynamic_paths.ensure_grid()
def add_path( def add_path(
self, self,
net_id: str, net_id: str,
@ -349,10 +343,6 @@ class RoutingWorld:
if not dynamic_paths.dilated: if not dynamic_paths.dilated:
return {} return {}
self._ensure_dynamic_grid()
if not dynamic_paths.grid:
return {}
candidates_by_net: dict[str, dict[int, set[int]]] = {} candidates_by_net: dict[str, dict[int, set[int]]] = {}
for test_geometry_index, test_bounds in enumerate(result.dilated_bounds): for test_geometry_index, test_bounds in enumerate(result.dilated_bounds):
if not self._has_possible_congestion_in_grid(test_bounds, net_id): if not self._has_possible_congestion_in_grid(test_bounds, net_id):
@ -407,16 +397,16 @@ class RoutingWorld:
net_id: str, net_id: str,
) -> bool: ) -> bool:
gx_min, gy_min, gx_max, gy_max = grid_cell_span(bounds, self.grid_cell_size) gx_min, gy_min, gx_max, gy_max = grid_cell_span(bounds, self.grid_cell_size)
dynamic_paths = self._dynamic_paths cells = self._dynamic_paths.grid_net_obj_ids
if gx_min == gx_max and gy_min == gy_max: if gx_min == gx_max and gy_min == gy_max:
net_counts = dynamic_paths.grid_net_counts.get((gx_min, gy_min)) members = cells.get((gx_min, gy_min))
return bool(net_counts and (len(net_counts) > 1 or net_id not in net_counts)) return bool(members and (len(members) > 1 or net_id not in members))
for gx in range(gx_min, gx_max + 1): for gx in range(gx_min, gx_max + 1):
for gy in range(gy_min, gy_max + 1): for gy in range(gy_min, gy_max + 1):
net_counts = dynamic_paths.grid_net_counts.get((gx, gy)) members = cells.get((gx, gy))
if net_counts and (len(net_counts) > 1 or net_id not in net_counts): if members and (len(members) > 1 or net_id not in members):
return True return True
return False return False
@ -430,10 +420,6 @@ class RoutingWorld:
if not dynamic_paths.dilated: if not dynamic_paths.dilated:
return False return False
self._ensure_dynamic_grid()
if not dynamic_paths.grid:
return False
for bounds in result.dilated_bounds: for bounds in result.dilated_bounds:
gx_min, gy_min, gx_max, gy_max = grid_cell_span(bounds, self.grid_cell_size) gx_min, gy_min, gx_max, gy_max = grid_cell_span(bounds, self.grid_cell_size)
cache_key = (net_id, gx_min, gy_min, gx_max, gy_max) cache_key = (net_id, gx_min, gy_min, gx_max, gy_max)

View file

@ -1,13 +1,10 @@
from __future__ import annotations from __future__ import annotations
from contextlib import suppress
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import numpy
import rtree import rtree
from shapely.strtree import STRtree
from inire.geometry.index_helpers import build_index_payload, iter_grid_cells from inire.geometry.index_helpers import iter_grid_cells
if TYPE_CHECKING: if TYPE_CHECKING:
from collections.abc import Sequence from collections.abc import Sequence
@ -29,16 +26,10 @@ class DynamicPathIndex:
"net_envelopes", "net_envelopes",
"net_envelope_obj_ids", "net_envelope_obj_ids",
"net_envelope_obj_to_net", "net_envelope_obj_to_net",
"tree",
"obj_ids",
"grid",
"grid_net_obj_ids", "grid_net_obj_ids",
"grid_net_counts",
"obj_cells", "obj_cells",
"net_to_obj_ids", "net_to_obj_ids",
"id_counter", "id_counter",
"net_ids_array",
"bounds_array",
) )
def __init__(self, engine: RoutingWorld) -> None: def __init__(self, engine: RoutingWorld) -> None:
@ -52,16 +43,10 @@ class DynamicPathIndex:
self.net_envelopes: dict[str, tuple[float, float, float, float]] = {} self.net_envelopes: dict[str, tuple[float, float, float, float]] = {}
self.net_envelope_obj_ids: dict[str, int] = {} self.net_envelope_obj_ids: dict[str, int] = {}
self.net_envelope_obj_to_net: dict[int, str] = {} self.net_envelope_obj_to_net: dict[int, str] = {}
self.tree: STRtree | None = None
self.obj_ids: numpy.ndarray = numpy.array([], dtype=numpy.int32)
self.grid: dict[tuple[int, int], list[int]] = {}
self.grid_net_obj_ids: dict[tuple[int, int], dict[str, set[int]]] = {} self.grid_net_obj_ids: dict[tuple[int, int], dict[str, set[int]]] = {}
self.grid_net_counts: dict[tuple[int, int], dict[str, int]] = {}
self.obj_cells: dict[int, tuple[tuple[int, int], ...]] = {} self.obj_cells: dict[int, tuple[tuple[int, int], ...]] = {}
self.net_to_obj_ids: dict[str, set[int]] = {} self.net_to_obj_ids: dict[str, set[int]] = {}
self.id_counter = 0 self.id_counter = 0
self.net_ids_array = numpy.array([], dtype=object)
self.bounds_array = numpy.array([], dtype=numpy.float64).reshape(0, 4)
def _combine_net_bounds(self, obj_ids: set[int]) -> tuple[float, float, float, float]: def _combine_net_bounds(self, obj_ids: set[int]) -> tuple[float, float, float, float]:
first_obj_id = next(iter(obj_ids)) first_obj_id = next(iter(obj_ids))
@ -104,34 +89,6 @@ class DynamicPathIndex:
return return
self._set_net_envelope(net_id, self._combine_net_bounds(obj_ids)) self._set_net_envelope(net_id, self._combine_net_bounds(obj_ids))
def invalidate_queries(self) -> None:
self.tree = None
self.grid = {}
self.grid_net_obj_ids = {}
self.grid_net_counts = {}
self.obj_cells = {}
def ensure_tree(self) -> None:
if self.tree is None and self.dilated:
if self.engine.metrics is not None:
self.engine.metrics.total_dynamic_tree_rebuilds += 1
ids, geometries, bounds_array = build_index_payload(self.dilated)
self.tree = STRtree(geometries)
self.obj_ids = numpy.array(ids, dtype=numpy.int32)
self.bounds_array = bounds_array
net_ids = [self.geometries[obj_id][0] for obj_id in self.obj_ids]
self.net_ids_array = numpy.array(net_ids, dtype=object)
def ensure_grid(self) -> None:
if self.grid or not self.dilated:
return
if self.engine.metrics is not None:
self.engine.metrics.total_dynamic_grid_rebuilds += 1
cell_size = self.engine.grid_cell_size
for obj_id, polygon in self.dilated.items():
self._register_grid_membership(obj_id, self.geometries[obj_id][0], polygon.bounds, cell_size=cell_size)
def _register_grid_membership( def _register_grid_membership(
self, self,
obj_id: int, obj_id: int,
@ -143,39 +100,17 @@ class DynamicPathIndex:
cells = tuple(iter_grid_cells(bounds, cell_size)) cells = tuple(iter_grid_cells(bounds, cell_size))
self.obj_cells[obj_id] = cells self.obj_cells[obj_id] = cells
for cell in cells: for cell in cells:
self.grid.setdefault(cell, []).append(obj_id) self.grid_net_obj_ids.setdefault(cell, {}).setdefault(net_id, set()).add(obj_id)
net_obj_ids = self.grid_net_obj_ids.setdefault(cell, {})
net_obj_ids.setdefault(net_id, set()).add(obj_id)
net_counts = self.grid_net_counts.setdefault(cell, {})
net_counts[net_id] = net_counts.get(net_id, 0) + 1
def _unregister_grid_membership(self, obj_id: int, net_id: str) -> None: def _unregister_grid_membership(self, obj_id: int, net_id: str) -> None:
cells = self.obj_cells.pop(obj_id, ()) for cell in self.obj_cells.pop(obj_id):
for cell in cells: net_obj_ids = self.grid_net_obj_ids[cell]
obj_ids = self.grid.get(cell) member_ids = net_obj_ids[net_id]
if obj_ids is not None: member_ids.remove(obj_id)
with suppress(ValueError): if not member_ids:
obj_ids.remove(obj_id) del net_obj_ids[net_id]
if not obj_ids: if not net_obj_ids:
self.grid.pop(cell, None) del self.grid_net_obj_ids[cell]
net_obj_ids = self.grid_net_obj_ids.get(cell)
if net_obj_ids is not None:
member_ids = net_obj_ids.get(net_id)
if member_ids is not None:
member_ids.discard(obj_id)
if not member_ids:
net_obj_ids.pop(net_id, None)
if not net_obj_ids:
self.grid_net_obj_ids.pop(cell, None)
net_counts = self.grid_net_counts.get(cell)
if net_counts is not None:
remaining = net_counts.get(net_id, 0) - 1
if remaining > 0:
net_counts[net_id] = remaining
else:
net_counts.pop(net_id, None)
if not net_counts:
self.grid_net_counts.pop(cell, None)
def add_path( def add_path(
self, self,
@ -200,7 +135,6 @@ class DynamicPathIndex:
self.net_to_obj_ids.setdefault(net_id, set()).add(obj_id) self.net_to_obj_ids.setdefault(net_id, set()).add(obj_id)
self._register_grid_membership(obj_id, net_id, dilated_bounds, cell_size=cell_size) self._register_grid_membership(obj_id, net_id, dilated_bounds, cell_size=cell_size)
self._refresh_net_envelope(net_id) self._refresh_net_envelope(net_id)
self.tree = None
def remove_path(self, net_id: str) -> None: def remove_path(self, net_id: str) -> None:
to_remove = list(self.net_to_obj_ids.get(net_id, ())) to_remove = list(self.net_to_obj_ids.get(net_id, ()))
@ -229,4 +163,3 @@ class DynamicPathIndex:
self.net_to_obj_ids.pop(net_id, None) self.net_to_obj_ids.pop(net_id, None)
for net_id in affected_nets: for net_id in affected_nets:
self._refresh_net_envelope(net_id) self._refresh_net_envelope(net_id)
self.tree = None

View file

@ -391,7 +391,7 @@ class _AutomaticRun:
policy = "incumbent-residual" policy = "incumbent-residual"
locks = LockPlan(retained) locks = LockPlan(retained)
run, stage = _route_residual(problem, options, "direct-seed", locks, run_route=partial(self._run, policy=policy)) run, stage = _route_residual(problem, options, locks, residual_mode="seed", run_route=partial(self._run, policy=policy))
stage = replace(stage, kind=policy, policy=policy, retry_reason="Residual terminals remain connected with the incumbents locked") stage = replace(stage, kind=policy, policy=policy, retry_reason="Residual terminals remain connected with the incumbents locked")
trial = self._trial(run, stage) trial = self._trial(run, stage)
if len(trial.valid_costs) == len(problem.nets): if len(trial.valid_costs) == len(problem.nets):
@ -580,7 +580,7 @@ class _AutomaticRun:
return None return None
retry = replace(options, congestion=replace(options.congestion, max_iterations=min(3, options.congestion.max_iterations))) retry = replace(options, congestion=replace(options.congestion, max_iterations=min(3, options.congestion.max_iterations)))
run, stage = _route_residual( run, stage = _route_residual(
self.problem, retry, "direct-seed", locks, run_route=partial(self._run, policy=policy, corridors=corridors) self.problem, retry, locks, residual_mode="seed", run_route=partial(self._run, policy=policy, corridors=corridors)
) )
stage = replace( stage = replace(
stage, stage,

View file

@ -382,21 +382,15 @@ class PathFinder:
if result and result.path and (result.reached_target or not state.corridors): if result and result.path and (result.reached_target or not state.corridors):
self._install_path(net_id, result.path) self._install_path(net_id, result.path)
def _analyze_restored_best( def _review_restored_best(self, state: _RoutingState) -> _IterationReview:
self, diagnostics = self.context.options.diagnostics
state: _RoutingState,
) -> tuple[dict[str, PathVerificationDetail], _IterationReview]:
capture_component_conflicts = (
self.context.options.diagnostics.capture_conflict_trace
or self.context.options.diagnostics.capture_pre_pair_frontier_trace
)
state.results, details_by_net, review = self._analyze_results( state.results, details_by_net, review = self._analyze_results(
state.ordered_net_ids, state.ordered_net_ids,
state.results, state.results,
capture_component_conflicts=capture_component_conflicts, capture_component_conflicts=diagnostics.capture_conflict_trace or diagnostics.capture_pre_pair_frontier_trace,
count_iteration_metrics=False, count_iteration_metrics=False,
) )
if self.context.options.diagnostics.capture_conflict_trace: if diagnostics.capture_conflict_trace:
self._capture_conflict_trace_entry( self._capture_conflict_trace_entry(
state, state,
stage="restored_best", stage="restored_best",
@ -405,13 +399,13 @@ class PathFinder:
details_by_net=details_by_net, details_by_net=details_by_net,
review=review, review=review,
) )
if self.context.options.diagnostics.capture_pre_pair_frontier_trace: if diagnostics.capture_pre_pair_frontier_trace:
self.pre_pair_frontier_trace = self._materialize_pre_pair_frontier_trace( self.pre_pair_frontier_trace = self._materialize_pre_pair_frontier_trace(
state, state,
state.results, state.results,
details_by_net, details_by_net,
) )
return details_by_net, review return review
def _update_best_iteration(self, state: _RoutingState, review: _IterationReview) -> bool: def _update_best_iteration(self, state: _RoutingState, review: _IterationReview) -> bool:
completed_nets = len(review.completed_net_ids) completed_nets = len(review.completed_net_ids)
@ -874,13 +868,7 @@ class PathFinder:
self._replace_installed_paths(state, incumbent_results) self._replace_installed_paths(state, incumbent_results)
return incumbent_review return incumbent_review
def _run_pair_local_search(self, state: _RoutingState) -> None: def _run_pair_local_search(self, state: _RoutingState, review: _IterationReview) -> None:
state.results, _details_by_net, review = self._analyze_results(
state.ordered_net_ids,
state.results,
capture_component_conflicts=True,
count_iteration_metrics=False,
)
targets = self._collect_pair_local_targets(state, state.results, review) targets = self._collect_pair_local_targets(state, state.results, review)
if not targets: if not targets:
return return
@ -1192,10 +1180,13 @@ class PathFinder:
timed_out = self._run_iterations(state, iteration_callback) timed_out = self._run_iterations(state, iteration_callback)
self.accumulated_expanded_nodes = list(state.accumulated_expanded_nodes) self.accumulated_expanded_nodes = list(state.accumulated_expanded_nodes)
self._restore_best_iteration(state) self._restore_best_iteration(state)
self._analyze_restored_best(state)
diagnostics = self.context.options.diagnostics
if not timed_out or diagnostics.capture_conflict_trace or diagnostics.capture_pre_pair_frontier_trace:
review = self._review_restored_best(state)
if not timed_out:
self._run_pair_local_search(state, review)
if not timed_out: if not timed_out:
self._run_pair_local_search(state)
with phase_timer("refine") if phase_timer is not None and self.context.options.refinement.enabled else nullcontext(): with phase_timer("refine") if phase_timer is not None and self.context.options.refinement.enabled else nullcontext():
self._refine_results(state) self._refine_results(state)
with phase_timer("verify") if phase_timer is not None else nullcontext(): with phase_timer("verify") if phase_timer is not None else nullcontext():

View file

@ -33,33 +33,6 @@ class RouteCall(Protocol):
def __call__(self, problem: RoutingProblem, *, options: RoutingOptions) -> RoutingRunResult: ... def __call__(self, problem: RoutingProblem, *, options: RoutingOptions) -> RoutingRunResult: ...
@dataclass(frozen=True, slots=True)
class _DirectPolicy:
residual_mode: Literal["guide", "seed"] | None = None
check_connectivity: bool = False
reorder_disconnected: bool = False
split_budget: bool = False
probe: Literal["first", "near-port", "after"] | None = None
retry_unresolved: bool = False
_LOOKAHEAD_RETRY = _DirectPolicy(check_connectivity=True, reorder_disconnected=True, split_budget=True)
_DIRECT_POLICY_SETTINGS = {
"direct-guide": _DirectPolicy(residual_mode="guide"),
"direct-seed": _DirectPolicy(residual_mode="seed"),
"direct-adaptive": _DirectPolicy(),
"direct-adaptive-retry": _DirectPolicy(retry_unresolved=True),
"direct-cull": _DirectPolicy(check_connectivity=True),
"direct-lookahead": _DirectPolicy(check_connectivity=True, reorder_disconnected=True),
"direct-budgeted-retry": _DirectPolicy(split_budget=True),
"direct-lookahead-retry": _LOOKAHEAD_RETRY,
"direct-probe-first": replace(_LOOKAHEAD_RETRY, probe="first"),
"direct-probe-near-port": replace(_LOOKAHEAD_RETRY, probe="near-port"),
"direct-probe-after": replace(_LOOKAHEAD_RETRY, probe="after"),
}
DIRECT_POLICIES = tuple(_DIRECT_POLICY_SETTINGS)
@dataclass(frozen=True, slots=True) @dataclass(frozen=True, slots=True)
class LockPlan: class LockPlan:
direct: dict[str, RoutingResult] direct: dict[str, RoutingResult]
@ -176,15 +149,48 @@ def _plan_locks(
problem: RoutingProblem, problem: RoutingProblem,
board: Polygon, board: Polygon,
options: RoutingOptions, options: RoutingOptions,
policy: _DirectPolicy,
*, *,
check_connectivity: bool = True,
priority: frozenset[str] = frozenset(), priority: frozenset[str] = frozenset(),
) -> LockPlan: ) -> LockPlan:
direct = _direct_paths(problem, board, options, priority=priority) direct = _direct_paths(problem, board, options, priority=priority)
disconnected = _disconnected_nets(problem, board, options, direct) if direct and policy.check_connectivity else frozenset() disconnected = _disconnected_nets(problem, board, options, direct) if direct and check_connectivity else frozenset()
return LockPlan(direct, disconnected) return LockPlan(direct, disconnected)
def _prefer_connected_locks(problem: RoutingProblem, board: Polygon, options: RoutingOptions, locks: LockPlan) -> LockPlan:
if not locks.disconnected:
return locks
candidate = _plan_locks(problem, board, options, priority=locks.disconnected)
return candidate if len(candidate.disconnected) < len(locks.disconnected) else locks
def _alternate_locks(
problem: RoutingProblem,
board: Polygon,
options: RoutingOptions,
locks: LockPlan,
*,
check_connectivity: bool = True,
) -> LockPlan | None:
if not 0 < len(locks.direct) < len(problem.nets) or options.search.node_limit <= 1:
return None
priority = frozenset(net.net_id for net in problem.nets if net.net_id not in locks.direct)
candidate = _plan_locks(problem, board, options, check_connectivity=check_connectivity, priority=priority)
if candidate.direct.keys() != locks.direct.keys() and len(candidate.disconnected) <= len(locks.disconnected):
return candidate
return None
def _split_search_budget(options: RoutingOptions, probe_limit: int) -> tuple[RoutingOptions, RoutingOptions]:
remaining = options.search.node_limit - probe_limit
first_limit = remaining // 2
return (
replace(options, search=replace(options.search, node_limit=first_limit)),
replace(options, search=replace(options.search, node_limit=remaining - first_limit)),
)
def _residual_problem(problem: RoutingProblem, locks: LockPlan) -> RoutingProblem: def _residual_problem(problem: RoutingProblem, locks: LockPlan) -> RoutingProblem:
if not locks.direct and not locks.disconnected: if not locks.direct and not locks.disconnected:
return problem return problem
@ -196,15 +202,14 @@ def _residual_problem(problem: RoutingProblem, locks: LockPlan) -> RoutingProble
def _route_residual( def _route_residual(
problem: RoutingProblem, problem: RoutingProblem,
options: RoutingOptions, options: RoutingOptions,
policy: str,
locks: LockPlan, locks: LockPlan,
*, *,
residual_mode: Literal["guide", "seed"] | None = None,
run_route: RouteCall = route_once, run_route: RouteCall = route_once,
) -> tuple[RoutingRunResult, RoutingStage]: ) -> tuple[RoutingRunResult, RoutingStage]:
direct = locks.direct direct = locks.direct
problem = _residual_problem(problem, locks) problem = _residual_problem(problem, locks)
residual = problem.nets residual = problem.nets
residual_mode = _DIRECT_POLICY_SETTINGS[policy].residual_mode
if not residual: if not residual:
mode = "off" mode = "off"
elif residual_mode is not None: elif residual_mode is not None:
@ -227,11 +232,7 @@ def _route_residual(
) )
def _length(result: RoutingResult) -> float: def _trial(run: RoutingRunResult, stage: RoutingStage, board: Polygon, *, score: Scorer) -> Trial:
return sum(component.length for component in result.path)
def _trial(run: RoutingRunResult, stage: RoutingStage, board: Polygon, *, score: Scorer = _length) -> Trial:
outside = tuple( outside = tuple(
net_id net_id
for net_id, result in run.results_by_net.items() for net_id, result in run.results_by_net.items()
@ -292,65 +293,33 @@ def _direct_trials(
options: RoutingOptions, options: RoutingOptions,
strategy: str, strategy: str,
*, *,
check_trial: CheckTrial,
run_route: RouteCall = route_once, run_route: RouteCall = route_once,
score: Scorer = _length,
check_trial: CheckTrial | None = None,
) -> list[Trial]: ) -> list[Trial]:
def check(run: RoutingRunResult, stage: RoutingStage) -> Trial: def check(run: RoutingRunResult, stage: RoutingStage) -> Trial:
stage = replace(stage, policy=strategy) return check_trial(run, replace(stage, policy=strategy))
return _trial(run, stage, board, score=score) if check_trial is None else check_trial(run, stage)
policy = _DIRECT_POLICY_SETTINGS[strategy] locks = _prefer_connected_locks(problem, board, options, _plan_locks(problem, board, options))
locks = _plan_locks(problem, board, options, policy) retry_locks = _alternate_locks(problem, board, options, locks)
if locks.disconnected and policy.reorder_disconnected: first_options = options
candidate = _plan_locks(problem, board, options, policy, priority=locks.disconnected) retry_options = options
if len(candidate.disconnected) < len(locks.disconnected):
locks = candidate
first_options = retry_options = options
retry_locks = None
probe_limit = 0 probe_limit = 0
can_reorder = 0 < len(locks.direct) < len(problem.nets) if retry_locks is not None:
if can_reorder and policy.split_budget and options.search.node_limit > 1: if strategy == "direct-probe-near-port" and _lock_near_new_port(problem, options, locks, retry_locks):
priority = frozenset(net.net_id for net in problem.nets if net.net_id not in locks.direct) probe_limit = min(32, options.search.node_limit // 3)
candidate = _plan_locks(problem, board, options, policy, priority=priority) first_options, retry_options = _split_search_budget(options, probe_limit)
if candidate.direct.keys() != locks.direct.keys() and len(candidate.disconnected) <= len(locks.disconnected):
retry_locks = candidate
limit = options.search.node_limit
if policy.probe is not None and (
policy.probe != "near-port" or _lock_near_new_port(problem, options, locks, retry_locks)
):
probe_limit = min(32, limit // 3)
remaining = limit - probe_limit
first_limit = remaining // 2
first_options = replace(options, search=replace(options.search, node_limit=first_limit))
retry_options = replace(options, search=replace(options.search, node_limit=remaining - first_limit))
trials = [] trials = []
if probe_limit and policy.probe in ("first", "near-port"): if probe_limit:
probe = _lattice_probe(problem, options, probe_limit, run_route=run_route, check_trial=check) probe = _lattice_probe(problem, options, probe_limit, run_route=run_route, check_trial=check)
trials.append(probe) trials.append(probe)
if len(probe.valid_costs) == len(problem.nets): if len(probe.valid_costs) == len(problem.nets):
return trials return trials
first = check(*_route_residual(problem, first_options, strategy, locks, run_route=run_route)) first = check(*_route_residual(problem, first_options, locks, run_route=run_route))
trials.append(first) trials.append(first)
if len(first.valid_costs) == len(problem.nets): if retry_locks is not None and len(first.valid_costs) < len(problem.nets):
return trials trials.append(check(*_route_residual(problem, retry_options, retry_locks, run_route=run_route)))
if probe_limit and policy.probe == "after":
probe = _lattice_probe(problem, options, probe_limit, run_route=run_route, check_trial=check)
trials.append(probe)
if len(probe.valid_costs) == len(problem.nets):
return trials
if policy.retry_unresolved and can_reorder:
unresolved = frozenset(first.run.results_by_net.keys() - first.valid_costs.keys())
candidate = _plan_locks(problem, board, options, policy, priority=unresolved)
if candidate.direct.keys() != locks.direct.keys():
retry_locks = candidate
if retry_locks is not None:
trials.append(check(*_route_residual(problem, retry_options, strategy, retry_locks, run_route=run_route)))
return trials return trials

View file

@ -0,0 +1,109 @@
"""Direct routing policies available through the benchmark CLI."""
from __future__ import annotations
from dataclasses import dataclass, replace
from functools import partial
from typing import TYPE_CHECKING
from inire.router._routing_policy import (
_alternate_locks,
_direct_trials,
_lattice_probe,
_plan_locks,
_prefer_connected_locks,
_route_residual,
_split_search_budget,
_trial,
)
from inire.router._stack import route_once
from inire.tests.routing_corpus import benchmark_weighted_length
if TYPE_CHECKING:
from typing import Literal
from shapely.geometry import Polygon
from inire import RoutingOptions, RoutingProblem, RoutingRunResult, RoutingStage
from inire.router._routing_policy import LockPlan, Trial
@dataclass(frozen=True, slots=True)
class _DirectExperiment:
residual_mode: Literal["guide", "seed"] | None = None
check_connectivity: bool = False
reorder_disconnected: bool = False
split_budget: bool = False
probe: Literal["first", "after"] | None = None
retry_unresolved: bool = False
_LOOKAHEAD = _DirectExperiment(check_connectivity=True, reorder_disconnected=True)
# The two None entries use the shipped retry sequence.
_EXPERIMENTS = {
"direct-guide": _DirectExperiment(residual_mode="guide"),
"direct-seed": _DirectExperiment(residual_mode="seed"),
"direct-adaptive": _DirectExperiment(),
"direct-adaptive-retry": _DirectExperiment(retry_unresolved=True),
"direct-cull": _DirectExperiment(check_connectivity=True),
"direct-lookahead": _LOOKAHEAD,
"direct-budgeted-retry": _DirectExperiment(split_budget=True),
"direct-lookahead-retry": None,
"direct-probe-first": replace(_LOOKAHEAD, split_budget=True, probe="first"),
"direct-probe-near-port": None,
"direct-probe-after": replace(_LOOKAHEAD, split_budget=True, probe="after"),
}
DIRECT_POLICIES = tuple(_EXPERIMENTS)
def direct_trials(problem: RoutingProblem, board: Polygon, options: RoutingOptions, strategy: str) -> list[Trial]:
experiment = _EXPERIMENTS[strategy]
summarize = partial(_trial, board=board, score=benchmark_weighted_length)
if experiment is None:
return _direct_trials(problem, board, options, strategy, check_trial=summarize)
def check(run: RoutingRunResult, stage: RoutingStage) -> Trial:
return summarize(run, replace(stage, policy=strategy))
def run_residual(worker: RoutingOptions, locks: LockPlan) -> Trial:
return check(*_route_residual(problem, worker, locks, residual_mode=experiment.residual_mode))
plan = partial(_plan_locks, problem, board, options, check_connectivity=experiment.check_connectivity)
locks = plan()
if experiment.reorder_disconnected:
locks = _prefer_connected_locks(problem, board, options, locks)
first_options = options
retry_options = options
retry_locks = None
probe_limit = 0
if experiment.split_budget:
retry_locks = _alternate_locks(problem, board, options, locks, check_connectivity=experiment.check_connectivity)
if retry_locks is not None:
probe_limit = min(32, options.search.node_limit // 3) if experiment.probe else 0
first_options, retry_options = _split_search_budget(options, probe_limit)
trials = []
if probe_limit and experiment.probe == "first":
trials.append(_lattice_probe(problem, options, probe_limit, run_route=route_once, check_trial=check))
if len(trials[-1].valid_costs) == len(problem.nets):
return trials
first = run_residual(first_options, locks)
trials.append(first)
if len(first.valid_costs) == len(problem.nets):
return trials
if probe_limit and experiment.probe == "after":
trials.append(_lattice_probe(problem, options, probe_limit, run_route=route_once, check_trial=check))
if len(trials[-1].valid_costs) == len(problem.nets):
return trials
if experiment.retry_unresolved and 0 < len(locks.direct) < len(problem.nets):
unresolved = frozenset(first.run.results_by_net.keys() - first.valid_costs.keys())
candidate = plan(priority=unresolved)
if candidate.direct.keys() != locks.direct.keys():
retry_locks = candidate
if retry_locks is not None:
trials.append(run_residual(retry_options, retry_locks))
return trials

View file

@ -26,6 +26,7 @@ from inire.geometry.primitives import Port
from inire.results import RouteMetrics, _sum_route_metrics from inire.results import RouteMetrics, _sum_route_metrics
from inire.router._astar_types import AStarContext, AStarMetrics from inire.router._astar_types import AStarContext, AStarMetrics
from inire.router._router import PathFinder from inire.router._router import PathFinder
from inire.router._stack import build_routing_stack
from inire.router.cost import CostEvaluator from inire.router.cost import CostEvaluator
from inire.router.danger_map import DangerMap from inire.router.danger_map import DangerMap
from inire.tests.routing_corpus import SNAPSHOT_CASES, profile_options from inire.tests.routing_corpus import SNAPSHOT_CASES, profile_options
@ -455,54 +456,59 @@ def _build_example_07_variant_stack(
capture_pre_pair_frontier_trace: bool = False, capture_pre_pair_frontier_trace: bool = False,
) -> tuple[CostEvaluator, AStarMetrics, PathFinder]: ) -> tuple[CostEvaluator, AStarMetrics, PathFinder]:
bounds = (0, 0, 1000, 1000) bounds = (0, 0, 1000, 1000)
obstacles = [ obstacles = (
box(450, 0, 550, 400), box(450, 0, 550, 400),
box(450, 600, 550, 1000), box(450, 600, 550, 1000),
] )
start_x = 50 start_x = 50
start_y_base = 500 - (num_nets * 10.0) / 2.0 start_y_base = 500 - (num_nets * 10.0) / 2.0
end_x = 950 end_x = 950
end_y_base = 100 end_y_base = 100
end_y_pitch = 800.0 / (num_nets - 1) end_y_pitch = 800.0 / (num_nets - 1)
netlist = {} nets = []
for index in range(num_nets): for index in range(num_nets):
sy = int(round(start_y_base + index * 10.0)) sy = int(round(start_y_base + index * 10.0))
ey = int(round(end_y_base + index * end_y_pitch)) ey = int(round(end_y_base + index * end_y_pitch))
netlist[f"net_{index:02d}"] = (Port(start_x, sy, 0), Port(end_x, ey, 0)) nets.append(NetSpec(f"net_{index:02d}", Port(start_x, sy, 0), Port(end_x, ey, 0)))
widths = dict.fromkeys(netlist, 2.0) problem = RoutingProblem(
_, evaluator, metrics, pathfinder = _build_routing_stack(
bounds=bounds, bounds=bounds,
netlist=netlist, nets=tuple(nets),
widths=widths, static_obstacles=obstacles,
clearance=6.0, clearance=6.0,
obstacles=obstacles,
evaluator_kwargs={
"greedy_h_weight": 1.5,
"unit_length_cost": 0.1,
"bend_penalty": 100.0,
"sbend_penalty": 400.0,
},
request_kwargs={
"node_limit": 2000000,
"bend_radii": [50.0],
"sbend_radii": [50.0],
"bend_clip_margin": 10.0,
"max_iterations": 15,
"base_penalty": 100.0,
"multiplier": 1.4,
"net_order": "shortest",
"capture_expanded": True,
"capture_conflict_trace": capture_conflict_trace,
"capture_frontier_trace": capture_frontier_trace,
"capture_iteration_trace": capture_iteration_trace,
"capture_pre_pair_frontier_trace": capture_pre_pair_frontier_trace,
"shuffle_nets": True,
"seed": seed,
"warm_start_enabled": warm_start_enabled,
},
) )
return evaluator, metrics, pathfinder options = RoutingOptions(
search=SearchOptions(
node_limit=2_000_000,
bend_radii=(50.0,),
sbend_radii=(50.0,),
greedy_h_weight=1.5,
bend_clip_margin=10.0,
),
objective=ObjectiveWeights(
unit_length_cost=0.1,
bend_penalty=100.0,
sbend_penalty=400.0,
),
congestion=CongestionOptions(
max_iterations=15,
base_penalty=100.0,
multiplier=1.4,
net_order="shortest",
shuffle_nets=True,
seed=seed,
warm_start_enabled=warm_start_enabled,
),
diagnostics=DiagnosticsOptions(
capture_expanded=True,
capture_conflict_trace=capture_conflict_trace,
capture_frontier_trace=capture_frontier_trace,
capture_iteration_trace=capture_iteration_trace,
capture_pre_pair_frontier_trace=capture_pre_pair_frontier_trace,
),
)
stack = build_routing_stack(problem, options)
return stack.evaluator, stack.finder.metrics, stack.finder
def _run_example_07_variant( def _run_example_07_variant(

View file

@ -519,7 +519,7 @@ def test_reverify_iterations_limit_late_reroutes_to_conflicting_nets(monkeypatch
monkeypatch.setattr(PathFinder, "_run_iteration", fake_run_iteration) monkeypatch.setattr(PathFinder, "_run_iteration", fake_run_iteration)
monkeypatch.setattr(PathFinder, "_verify_results", lambda self, state: (dict(state.results), {})) monkeypatch.setattr(PathFinder, "_verify_results", lambda self, state: (dict(state.results), {}))
monkeypatch.setattr(PathFinder, "_run_pair_local_search", lambda self, state: None) monkeypatch.setattr(PathFinder, "_run_pair_local_search", lambda self, state, review: None)
results = pathfinder.route_all() results = pathfinder.route_all()

View file

@ -335,7 +335,7 @@ def test_dynamic_grid_updates_incrementally_on_add_and_remove() -> None:
dynamic_paths = engine._dynamic_paths dynamic_paths = engine._dynamic_paths
assert dynamic_paths.net_to_obj_ids["netA"] assert dynamic_paths.net_to_obj_ids["netA"]
assert dynamic_paths.net_to_obj_ids["netB"] assert dynamic_paths.net_to_obj_ids["netB"]
assert dynamic_paths.grid assert dynamic_paths.grid_net_obj_ids
assert engine.metrics.total_dynamic_grid_rebuilds == 0 assert engine.metrics.total_dynamic_grid_rebuilds == 0
engine.remove_path("netA") engine.remove_path("netA")

Some files were not shown because too many files have changed in this diff Show more