Skip to main content

PopulationState

Trait PopulationState 

Source
pub trait PopulationState: State {
    // Required methods
    fn candidates(&self) -> &[Self::Param];
    fn costs(&self) -> &[Self::Float];
}
Expand description

States built around a population of λ candidate parameters and parallel costs.

Mirrors SimplexState: the trait exists so termination criteria that need to inspect the whole population (diversity, generation spread, stall counters) can bound on a richer view than State::param / State::cost, which only see the best candidate. The vehicle for stochastic solvers (RandomSearch; CMA-ES once it lands).

§Contract

  • Implementor must: keep candidates and costs sorted by ascending cost at the start and end of every Solver::next_iter call (and at the end of Solver::init). So State::param / State::cost always return the current best candidate (candidates[0] / costs[0]).
  • Implementor must: sort NaN costs last, so a single bad evaluation can’t drag itself to the front and become the “best” candidate.
  • Implementor must: keep the two slices the same length and in parallel order — costs[i] is the cost at candidates[i].

Required Methods§

Source

fn candidates(&self) -> &[Self::Param]

All λ candidates, sorted by ascending cost.

Source

fn costs(&self) -> &[Self::Float]

Costs in parallel with candidates, sorted ascending.

Implementors§