selection_utils (macula_tweann v0.11.3)

View Source

Selection utilities for evolutionary algorithms.

Provides selection mechanisms used throughout the evolution process: - Roulette wheel selection (fitness-proportionate) - Random uniform selection - Weighted selection

Summary

Functions

Uniformly select a random element from a list.

Roulette wheel selection based on weights.

Select element with custom weight function.

Functions

random_select(Items)

-spec random_select([term()]) -> term().

Uniformly select a random element from a list.

Each element has equal probability of selection.

roulette_wheel(WeightedItems)

-spec roulette_wheel([{term(), number()}]) -> term().

Roulette wheel selection based on weights.

Selects an element with probability proportional to its weight. Higher weight = higher probability of selection.

Algorithm: 1. Calculate total weight 2. Generate random value in [0, total) 3. Accumulate weights until random value exceeded

weighted_select(Items, WeightFun)

-spec weighted_select([term()], fun((term()) -> number())) -> term().

Select element with custom weight function.

Applies a weight function to each element, then performs roulette wheel selection.