Skip to main content

argmax_host

Function argmax_host 

Source
pub fn argmax_host(fitness: &[f32]) -> usize
Expand description

Returns the index of the largest fitness value.

fitness is canonical (maximise): higher is better. The scan keeps the running best under a strict > seeded from NEG_INFINITY, so:

  • ties resolve to the lowest index,
  • NaN and −inf entries never displace the running best (every comparison against them or the seed is strict), and
  • a slice with no entry above −inf (e.g. all-NaN) falls back to index 0.

§Examples

use rlevo_evolution::ops::selection::argmax_host;

let fitness = [1.0_f32, 5.0, 3.0];
assert_eq!(argmax_host(&fitness), 1);

§Panics

Panics if fitness.is_empty().