Reuse residual routing for perimeter recovery
This commit is contained in:
parent
15c2714f1f
commit
926b2645b5
2 changed files with 29 additions and 17 deletions
|
|
@ -35,6 +35,7 @@ from inire.router._routing_policy import (
|
||||||
_is_short_shift,
|
_is_short_shift,
|
||||||
_residual_problem,
|
_residual_problem,
|
||||||
_route_prepared_residual,
|
_route_prepared_residual,
|
||||||
|
_route_residual,
|
||||||
_trial,
|
_trial,
|
||||||
)
|
)
|
||||||
from inire.router._seed_materialization import materialize_path_seed
|
from inire.router._seed_materialization import materialize_path_seed
|
||||||
|
|
@ -331,27 +332,20 @@ class _AutomaticRun:
|
||||||
if not candidate.valid_costs:
|
if not candidate.valid_costs:
|
||||||
continue
|
continue
|
||||||
chosen = candidate.run.results_by_net[net.net_id]
|
chosen = candidate.run.results_by_net[net.net_id]
|
||||||
residual = replace(
|
policy = "perimeter-residual"
|
||||||
|
guide = replace(options, congestion=replace(options.congestion, max_iterations=1))
|
||||||
|
run, stage = _route_residual(
|
||||||
problem,
|
problem,
|
||||||
nets=tuple(other for other in problem.nets if other != net),
|
guide,
|
||||||
static_obstacles=problem.static_obstacles + chosen.locked_geometry,
|
LockPlan({net.net_id: chosen}),
|
||||||
|
residual_mode="guide",
|
||||||
|
run_route=partial(self._run, policy=policy),
|
||||||
)
|
)
|
||||||
guide = replace(options, topology=replace(options.topology, mode="guide"), congestion=replace(options.congestion, max_iterations=1))
|
stage = replace(stage, kind=policy, policy=policy, planner="perimeter")
|
||||||
run = self._run(residual, options=guide, policy="perimeter-residual")
|
trials.append(self._trial(run, stage))
|
||||||
combined = {net.net_id: chosen, **run.results_by_net}
|
|
||||||
stage = RoutingStage(
|
|
||||||
"guide",
|
|
||||||
(net.net_id,),
|
|
||||||
run.metrics.nodes_expanded,
|
|
||||||
options.search.node_limit,
|
|
||||||
kind="perimeter-residual",
|
|
||||||
policy="perimeter-residual",
|
|
||||||
planner="perimeter",
|
|
||||||
)
|
|
||||||
trials.append(self._trial(replace(run, results_by_net=combined), stage))
|
|
||||||
if len(trials[-1].valid_costs) == len(problem.nets):
|
if len(trials[-1].valid_costs) == len(problem.nets):
|
||||||
trials[-1] = replace(trials[-1], selection="requires-layout-check")
|
trials[-1] = replace(trials[-1], selection="requires-layout-check")
|
||||||
seeds = {net_id: result.as_seed() for net_id, result in combined.items()}
|
seeds = {net_id: result.as_seed() for net_id, result in run.results_by_net.items()}
|
||||||
trials.append(self._verify(replace(problem, initial_paths=seeds), "perimeter"))
|
trials.append(self._verify(replace(problem, initial_paths=seeds), "perimeter"))
|
||||||
if len(trials[-1].valid_costs) == len(problem.nets):
|
if len(trials[-1].valid_costs) == len(problem.nets):
|
||||||
break
|
break
|
||||||
|
|
|
||||||
|
|
@ -572,6 +572,24 @@ def test_paired_perimeters_respect_the_supplied_detour() -> None:
|
||||||
assert run.results_by_net[net_id].as_seed() == seed
|
assert run.results_by_net[net_id].as_seed() == seed
|
||||||
|
|
||||||
|
|
||||||
|
def test_perimeter_residual_preserves_its_lock_and_verifies_the_layout(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
|
(case,) = CASE_GROUPS["terminal-bench-pair"]
|
||||||
|
options = automatic_options(profile_options(case, "corpus-regression"), "corpus-regression")
|
||||||
|
planner = _AutomaticRun(case.problem, options, None)
|
||||||
|
monkeypatch.setattr(_AutomaticRun, "_paired_perimeter", lambda *_args: None)
|
||||||
|
|
||||||
|
trials = planner._perimeter_trials(options)
|
||||||
|
|
||||||
|
residual = [trial for trial in trials if trial.stage.kind == "perimeter-residual"]
|
||||||
|
assert residual
|
||||||
|
assert all(trial.stage.mode == "guide" and len(trial.stage.direct_net_ids) == 1 for trial in residual)
|
||||||
|
assert all(not trial.stage.skipped_net_ids for trial in residual)
|
||||||
|
assert residual[-1].selection == "requires-layout-check"
|
||||||
|
assert trials[-1].selectable
|
||||||
|
assert trials[-1].stage.kind == "perimeter"
|
||||||
|
assert set(trials[-1].valid_costs) == {net.net_id for net in case.problem.nets}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("name", ["fallback-custom-proxy", "fallback-custom-physical"])
|
@pytest.mark.parametrize("name", ["fallback-custom-proxy", "fallback-custom-physical"])
|
||||||
def test_automatic_preserves_custom_bend_geometry(name: str) -> None:
|
def test_automatic_preserves_custom_bend_geometry(name: str) -> None:
|
||||||
case = next(case for case in FALLBACK_BENCHMARK_CASES if case.name == name)
|
case = next(case for case in FALLBACK_BENCHMARK_CASES if case.name == name)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue