Represents the state of an evolutionary algorithm at a given generation.
This structure tracks the current population, their fitness scores, and metadata about the evolution process.
Summary
Functions
Calculate diversity of the current population.
Create a new state from attributes.
Create a new initial state from a population and config.
Create a new state, raising on validation errors.
Update the population and advance the generation counter.
Add metadata to the state.
Check if termination criteria are met.
Update the state with new fitness scores.
Types
@type t() :: %Jido.Evolve.State{ average_score: number(), best_entity: nil | nil | any(), best_score: number(), config: %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() }, diversity: number(), fitness_history: [number()], generation: integer(), metadata: map(), population: [any()], scores: map() }
Functions
Calculate diversity of the current population.
This is useful for monitoring convergence and maintaining diversity.
Create a new state from attributes.
@spec new([any()], Jido.Evolve.Config.t()) :: t()
Create a new initial state from a population and config.
Examples
iex> config = Jido.Evolve.Config.new!()
iex> state = Jido.Evolve.State.new(["a", "b", "c"], config)
iex> state.population
["a", "b", "c"]
Create a new state, raising on validation errors.
Update the population and advance the generation counter.
Add metadata to the state.
Check if termination criteria are met.
Update the state with new fitness scores.
This recalculates the best entity, best score, and average score.