Skip to main content

Module selection

Module selection 

Source
Expand description

Parent-selection operators.

Selection operators turn a fitness slice into winner indices that the caller uses (via Tensor::select) to gather parents out of the population. The baseline is host-side sampling + a single device gather; a fused kernel variant is tracked as follow-up work.

All operators that draw random numbers accept an explicit &mut dyn Rng (the host-RNG convention). Operators never touch thread-local or process-wide backend RNG state (B::seed / Tensor::random), which would race with sibling tests under the parallel test runner.

§Fitness convention

Fitness values are canonical (maximise): higher is better. Tournament selection retains the largest fitness seen across all candidates in a single draw; truncation selection returns the top_k entries with the largest fitnesses; argmax_host reduces a fitness slice to the index of its single largest entry.

Functions§

argmax_host
Returns the index of the largest fitness value.
tournament_indices_host
K-ary tournament selection over a fitness slice.
tournament_select
Gathers n_winners rows out of a population tensor by tournament.
truncation_indices_host
Returns the indices of the top_k highest-fitness members.
truncation_select
Gathers the top_k highest-fitness rows out of a population tensor.