fix examples

This commit is contained in:
Jan Petykiewicz 2026-03-30 21:22:20 -07:00
commit e11132b51d

View file

@ -270,7 +270,12 @@ def run_example_06() -> ScenarioOutcome:
_build_evaluator(bounds, obstacles=obstacles),
{"clipped_model": (Port(10, 20, 0), Port(90, 40, 90))},
{"clipped_model": 2.0},
{"bend_radii": [10.0], "bend_collision_type": "clipped_bbox", "use_tiered_strategy": False},
{
"bend_radii": [10.0],
"bend_collision_type": "clipped_bbox",
"bend_clip_margin": 1.0,
"use_tiered_strategy": False,
},
),
]
@ -323,9 +328,11 @@ def run_example_07() -> ScenarioOutcome:
"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,
"shuffle_nets": True,
"seed": 42,
@ -333,7 +340,10 @@ def run_example_07() -> ScenarioOutcome:
)
def iteration_callback(idx: int, current_results: dict[str, RoutingResult]) -> None:
_ = idx, current_results
_ = current_results
new_greedy = max(1.1, 1.5 - ((idx + 1) / 10.0) * 0.4)
evaluator.greedy_h_weight = new_greedy
metrics.reset_per_route()
t0 = perf_counter()
results = pathfinder.route_all(iteration_callback=iteration_callback)
@ -345,27 +355,27 @@ def run_example_08() -> ScenarioOutcome:
bounds = (0, 0, 150, 150)
netlist = {"custom_bend": (Port(20, 20, 0), Port(100, 100, 90))}
widths = {"custom_bend": 2.0}
custom_model = Polygon([(0, -11), (11, -11), (11, 0), (9, 0), (9, -9), (0, -9)])
standard_evaluator = _build_evaluator(bounds)
custom_evaluator = _build_evaluator(bounds)
custom_model = Polygon([(-10, -10), (10, -10), (10, 10), (-10, 10)])
evaluator = _build_evaluator(bounds)
t0 = perf_counter()
results_std = _build_pathfinder(
standard_evaluator,
evaluator,
bounds=bounds,
nets=_net_specs(netlist, widths),
bend_radii=[10.0],
sbend_radii=[],
use_tiered_strategy=False,
max_iterations=1,
metrics=AStarMetrics(),
).route_all()
results_custom = _build_pathfinder(
custom_evaluator,
evaluator,
bounds=bounds,
nets=_net_specs({"custom_model": netlist["custom_bend"]}, {"custom_model": 2.0}),
bend_radii=[10.0],
bend_collision_type=custom_model,
sbend_radii=[],
max_iterations=1,
use_tiered_strategy=False,
metrics=AStarMetrics(),
).route_all()
@ -386,7 +396,7 @@ def run_example_09() -> ScenarioOutcome:
widths=widths,
obstacles=obstacles,
evaluator_kwargs={"bend_penalty": 50.0, "sbend_penalty": 150.0},
request_kwargs={"node_limit": 3, "bend_radii": [10.0], "warm_start_enabled": False},
request_kwargs={"node_limit": 3, "bend_radii": [10.0], "warm_start_enabled": False, "max_iterations": 1},
)
t0 = perf_counter()
results = pathfinder.route_all()
@ -397,7 +407,7 @@ def run_example_09() -> ScenarioOutcome:
SCENARIOS: tuple[tuple[str, ScenarioRun], ...] = (
("example_01_simple_route", run_example_01),
("example_02_congestion_resolution", run_example_02),
("example_03_locked_routes", run_example_03),
("example_03_locked_paths", run_example_03),
("example_04_sbends_and_radii", run_example_04),
("example_05_orientation_stress", run_example_05),
("example_06_bend_collision_models", run_example_06),