Skip to main content

mu_plus_lambda

Function mu_plus_lambda 

Source
pub fn mu_plus_lambda<B: Backend>(
    parents: Tensor<B, 2>,
    parent_fitness: &[f32],
    offspring: Tensor<B, 2>,
    offspring_fitness: &[f32],
    mu: usize,
    device: &<B as BackendTypes>::Device,
) -> (Tensor<B, 2>, Vec<f32>)
Expand description

(μ + λ) replacement: keeps the μ best individuals from the merged parent and offspring pool.

Concatenates the μ parent rows with the λ offspring rows into a combined pool of size μ + λ, then retains the mu members with the lowest fitness. Parents and offspring compete on equal footing, so a highly-fit parent can survive indefinitely.

The returned tensor has shape (mu, genome_dim) and the returned fitness vector has length mu, both ordered by selection rank (best first).

§Panics

Panics if mu > parent_fitness.len() + offspring_fitness.len() (the underlying truncation cannot select more winners than the combined pool contains).