Skip to main content

top_set

Function top_set 

pub fn top_set(view: &StudyView) -> Vec<&FrozenTrial>
Expand description

The completed trials that vote on where a study’s optimum is — §8’s candidate and top-set construction. Reused across every parameter: the same top set is what pressure measures crowding against for each open parameter in turn, so a caller builds it once per decision point rather than once per parameter.

§Candidates

Starts from StudyView::completed — Complete only. A Pruned trial’s objective is a partial-curve proxy, never a number the configuration actually achieved, so it does not get a vote; under ASHA/Hyperband, where most trials are pruned, this is a real cost that makes such a study grow more slowly. An objective vector of the wrong arity, or one carrying a NaN, cannot be ranked and is dropped — the same comparability gate crate::pareto::dominates applies.

Constraints use the same declared-first, feasibility-first relation as StudyView::best. If no declared candidate is feasible, the candidates with the least total violation vote instead of producing an empty set. A trial that declared nothing competes normally only while every candidate is undeclared; once any checked result exists, unchecked results cannot outrank it.

A multi-seed fan trial already carries its aggregate in FrozenTrial::values (the one number every sampler ranks), so it needs no special case here; the per-seed FrozenTrial::replicates are never read.

§The top set itself

  • Single objective: the best 25% of the constraint-preferred candidates, clamped to at least 4 and at most 64 — or fewer, when there are not that many candidates to begin with. Ties break toward the lower trial number, so the answer does not depend on completion order (matching StudyView::best’s own tie-break).
  • Multi-objective: the constrained Pareto front (crate::pareto::pareto_front_indices), capped at 64 by crowding distance when the front is larger than that. This branch is reachable only from a reader such as atune doctor: a policy-bound study can never carry more than one objective (Nsga2 — the only built-in sampler that ranks a front — is refused under a policy), so widen() never sees it.