Jido.Evolve.Config (Jido Evolve v1.0.0)

Copy Markdown View Source

Canonical configuration structure for evolutionary algorithms.

This module uses Zoi for validation and provides sensible defaults.

Summary

Functions

Get the number of elite entities to preserve.

Initialize random seed if configured.

Create a new configuration with validation.

Create a new configuration, raising on validation errors.

Types

t()

@type t() :: %Jido.Evolve.Config{
  checkpoint_interval: nil | nil | integer(),
  crossover_rate: number(),
  crossover_strategy: atom(),
  elitism_rate: number(),
  evaluation_timeout: integer() | :infinity,
  generations: integer(),
  max_concurrency: integer(),
  metrics_enabled: boolean(),
  mutation_rate: number(),
  mutation_strategy: atom(),
  population_size: integer(),
  random_seed: nil | nil | integer(),
  selection_pressure: number(),
  selection_strategy: atom(),
  termination_criteria: [
    max_generations: integer(),
    target_fitness: number(),
    no_improvement: integer()
  ],
  tournament_size: integer()
}

Functions

elite_count(config)

@spec elite_count(t()) :: non_neg_integer()

Get the number of elite entities to preserve.

init_random_seed(config)

@spec init_random_seed(t()) :: :ok
@spec init_random_seed(t()) :: :ok

Initialize random seed if configured.

Uses explicit :exs1024 algorithm with deterministic seed tuple for reproducibility across OTP versions.

new(opts \\ [])

@spec new(keyword() | map()) :: {:ok, t()} | {:error, term()}

Create a new configuration with validation.

Examples

iex> {:ok, config} = Jido.Evolve.Config.new(population_size: 50)
iex> config.population_size
50

iex> {:error, _error} = Jido.Evolve.Config.new(population_size: -1)

new!(opts \\ [])

@spec new!(keyword() | map()) :: t()

Create a new configuration, raising on validation errors.

Examples

iex> config = Jido.Evolve.Config.new!(population_size: 50)
iex> config.population_size
50