Trim verification work and plan independent channels before search

This commit is contained in:
Jan Petykiewicz 2026-11-30 15:24:14 -08:00
commit d64c70c68f

View file

@ -506,28 +506,27 @@ class _AutomaticRun:
return True
return False
def _column_recovery_trial(self, options: RoutingOptions) -> Trial | None:
def _try_column_recovery(self, options: RoutingOptions, trials: list[Trial], groups: tuple[RoutingProblem, ...]) -> bool:
problem = self.problem
if problem.initial_paths or not options.search.bend_radii or not problem._blocking_polygons:
return None
planner = "column-recovery"
with self._time("plan", planner=planner):
groups = column_recovery_subproblems(problem)
if not groups:
return None
combined = {}
for group in groups:
for seeds in column_recovery_candidates(group, options.search):
trial = self._verify(replace(group, initial_paths=seeds), planner)
if len(trial.valid_costs) == len(group.nets):
if group is problem:
return trial
trials.append(trial)
return True
combined.update(seeds)
break
else:
return None
return False
trial = self._verify(replace(problem, initial_paths=combined), planner)
return trial if len(trial.valid_costs) == len(problem.nets) else None
if len(trial.valid_costs) == len(problem.nets):
trials.append(trial)
return True
return False
def _search_trials(self, trials: list[Trial], target: int) -> None:
configured_search = self.options.search
@ -561,6 +560,17 @@ class _AutomaticRun:
try_construction_early = not options.congestion.shuffle_nets
if try_construction_early and self._try_column_jogs(options, trials, target):
return True
groups = ()
if (
try_construction_early and target == len(problem.nets) and not problem.initial_paths
and options.search.bend_radii and problem._blocking_polygons
):
with self._time("plan", planner="column-recovery"):
groups = column_recovery_subproblems(problem)
# With independent channels, try construction before spending search
# budget on each net. Keep the general bypass as a later fallback.
if len(groups) > 1 and self._try_column_recovery(options, trials, groups):
return True
probe_iterations = options.congestion.max_iterations
proxy, _ = resolve_bend_geometry(options.search)
# Clipped proxies can find cheaper routes in later probe iterations than in the wider retry.
@ -591,11 +601,8 @@ class _AutomaticRun:
if len(_best_trial(trials).valid_costs) >= target:
return True
if target == len(problem.nets) and not options.congestion.shuffle_nets:
recovery = self._column_recovery_trial(options)
if recovery is not None:
trials.append(recovery)
return True
if len(groups) == 1 and self._try_column_recovery(options, trials, groups):
return True
# Every short shift has lateral displacement, so the direct retry cannot lock
# any straight paths. It would run the same guide with the same budget.