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 interpreted as “lower is better” (cost). Tournament selection retains the smallest fitness seen across all candidates in a single draw; truncation selection returns the top_k entries with the smallest fitnesses.

Functions§

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 lowest-fitness members.
truncation_select
Gathers the top_k lowest-fitness rows out of a population tensor.