Remove hooks for archived early incumbent experiments
This commit is contained in:
parent
64e103b59e
commit
07a2c0e167
1 changed files with 6 additions and 77 deletions
|
|
@ -13,8 +13,8 @@ from time import perf_counter
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
from inire import route
|
||||
from inire.router._automatic import _AutomaticRun, _INITIAL_NODE_LIMIT, _NEAR_PORT_ITERATION_LIMIT
|
||||
from inire.router._routing_policy import LockPlan, _best_trial, _direct_trials, _disconnected_nets, _route_residual
|
||||
from inire.router._automatic import _AutomaticRun, _NEAR_PORT_ITERATION_LIMIT
|
||||
from inire.router._routing_policy import LockPlan, _best_trial, _disconnected_nets, _route_residual
|
||||
from inire.tests.routing_corpus import (
|
||||
CASE_GROUPS,
|
||||
PROFILES,
|
||||
|
|
@ -35,8 +35,6 @@ if TYPE_CHECKING:
|
|||
@dataclass(frozen=True, slots=True)
|
||||
class _RetryPolicy:
|
||||
lattice_limit: int | None = None
|
||||
recovery_stage: str | None = None
|
||||
recovery_remaining: int = 1
|
||||
probe_iterations: int | None = _NEAR_PORT_ITERATION_LIMIT
|
||||
residual_limit: int | None = None
|
||||
residual_after_fallback: bool = False
|
||||
|
|
@ -45,11 +43,6 @@ class _RetryPolicy:
|
|||
_POLICIES = {
|
||||
"baseline": _RetryPolicy(),
|
||||
**{f"lattice-{limit}": _RetryPolicy(lattice_limit=limit) for limit in (500, 750, 1000, 1500, 2000)},
|
||||
"recover-lookahead": _RetryPolicy(recovery_stage="direct-lookahead-retry"),
|
||||
"recover-near-port": _RetryPolicy(recovery_stage="direct-probe-near-port", recovery_remaining=2),
|
||||
"lattice-1500-and-recover-near-port": _RetryPolicy(
|
||||
lattice_limit=1500, recovery_stage="direct-probe-near-port", recovery_remaining=2
|
||||
),
|
||||
**{f"probe-iterations-{count}": _RetryPolicy(probe_iterations=count) for count in (1, 2, 3)},
|
||||
"probe-full-budget": _RetryPolicy(probe_iterations=None),
|
||||
**{f"residual-{limit}": _RetryPolicy(residual_limit=limit) for limit in (1500, 3000)},
|
||||
|
|
@ -72,7 +65,6 @@ class _RetryExperiment(_AutomaticRun):
|
|||
})
|
||||
|
||||
def _search_trials(self, trials: list[Trial], target: int) -> None:
|
||||
self.routing_bound = target
|
||||
super()._search_trials(trials, target)
|
||||
limit = self.retry_policy.residual_limit
|
||||
if (
|
||||
|
|
@ -91,34 +83,6 @@ class _RetryExperiment(_AutomaticRun):
|
|||
options = replace(self.options, refinement=replace(self.options.refinement, enabled=False))
|
||||
trials.extend(self._widen_residual(options, retained, limit, target, policy="late-bounded-residual", check_connectivity=True))
|
||||
|
||||
def _recover_before_direct_retry(self, attempt: Trial, options: RoutingOptions) -> list[Trial]:
|
||||
target = len(self.problem.nets)
|
||||
verified = len(attempt.valid_costs)
|
||||
if (
|
||||
self.routing_bound < target
|
||||
or target <= 2
|
||||
or self.problem.initial_paths
|
||||
or not 0 < target - verified <= self.retry_policy.recovery_remaining
|
||||
or 3 * verified < 2 * target
|
||||
):
|
||||
return []
|
||||
|
||||
seeded = replace(
|
||||
options,
|
||||
search=replace(options.search, node_limit=min(_INITIAL_NODE_LIMIT, self.options.search.node_limit)),
|
||||
congestion=replace(options.congestion, max_iterations=min(2, options.congestion.max_iterations)),
|
||||
topology=replace(options.topology, mode="seed"),
|
||||
)
|
||||
started, first_run = perf_counter(), len(self.metrics)
|
||||
recovered = self._incumbent_trials(seeded, attempt, target, retry_disconnected=False)
|
||||
complete = any(candidate.selectable and len(candidate.valid_costs) == target for candidate in recovered)
|
||||
outcome = "incomplete" if recovered else "disconnected"
|
||||
self._record_retry("incumbent-recovery", "complete" if complete else outcome, started, first_run)
|
||||
if complete:
|
||||
return recovered
|
||||
# Keep failed experimental work visible without changing the fallback incumbent.
|
||||
return [replace(candidate, selection="incomplete-layout") for candidate in recovered]
|
||||
|
||||
def _direct(self, options: RoutingOptions, policy: str) -> list[Trial]:
|
||||
if policy == "direct-probe-near-port":
|
||||
cap = self.retry_policy.probe_iterations
|
||||
|
|
@ -126,18 +90,7 @@ class _RetryExperiment(_AutomaticRun):
|
|||
iterations = configured if cap is None else min(configured, cap)
|
||||
if iterations != options.congestion.max_iterations:
|
||||
options = replace(options, congestion=replace(options.congestion, max_iterations=iterations))
|
||||
if policy != self.retry_policy.recovery_stage:
|
||||
return super()._direct(options, policy)
|
||||
with self._time("plan", planner="direct", policy=policy):
|
||||
return _direct_trials(
|
||||
self.problem,
|
||||
self.board,
|
||||
options,
|
||||
policy,
|
||||
run_route=partial(self._run, policy=policy),
|
||||
check_trial=self._trial,
|
||||
recover_before_retry=partial(self._recover_before_direct_retry, options=options),
|
||||
)
|
||||
return super()._direct(options, policy)
|
||||
|
||||
def _seed_recovery_trials(self, options: RoutingOptions, trials: list[Trial], target: int) -> None:
|
||||
limit = self.retry_policy.lattice_limit
|
||||
|
|
@ -158,8 +111,8 @@ class _RetryExperiment(_AutomaticRun):
|
|||
trials[-1] = replace(trials[-1], selection="incomplete-layout")
|
||||
super()._seed_recovery_trials(options, trials, target)
|
||||
|
||||
def _incumbent_trials(self, options: RoutingOptions, best: Trial, target: int, *, retry_disconnected: bool = True) -> list[Trial]:
|
||||
trials = super()._incumbent_trials(options, best, target, retry_disconnected=retry_disconnected)
|
||||
def _incumbent_trials(self, options: RoutingOptions, best: Trial, target: int) -> list[Trial]:
|
||||
trials = super()._incumbent_trials(options, best, target)
|
||||
limit = self.retry_policy.residual_limit
|
||||
if (
|
||||
limit is None
|
||||
|
|
|
|||
Loading…
Reference in a new issue