Jido.Evolve.Selection behaviour (Jido Evolve v1.0.0)

Copy Markdown View Source

Behaviour for selection strategies.

Selection determines which entities from the current population should be chosen as parents for the next generation.

Summary

Callbacks

Maintain diversity in the selected population.

Select entities from the population for reproduction.

Types

count()

@type count() :: pos_integer()

entity()

@type entity() :: term()

opts()

@type opts() :: keyword()

population()

@type population() :: [entity()]

scores()

@type scores() :: %{required(entity()) => float()}

Callbacks

maintain_diversity(population, population, opts)

(optional)
@callback maintain_diversity(population(), population(), opts()) :: population()

Maintain diversity in the selected population.

This optional callback can be implemented to ensure the selected population maintains genetic diversity.

select(population, scores, count, opts)

@callback select(population(), scores(), count(), opts()) :: population()

Select entities from the population for reproduction.

Parameters

  • population - The current population
  • scores - Map of entity to fitness score
  • count - Number of entities to select
  • opts - Strategy-specific options

Returns

A list of selected entities for reproduction.

Examples

def select(population, scores, count, opts) do
  # Tournament selection implementation
  Enum.take_random(population, count)
end