Jido.Evolve.Examples.HelloWorld (Jido Evolve v1.0.0)

Copy Markdown View Source

A simple example of evolving text towards a target string.

This example demonstrates how to use Jido.Evolve to evolve a string towards the target "Hello, world!" using random mutations and tournament selection with adaptive mutation rates.

Summary

Functions

Default implementation of batch_evaluate/2 that delegates to shared implementation.

Run a quick demo that prints progress.

Fitness function that measures similarity to the target string.

Run the hello world evolution example.

Functions

batch_evaluate(entities, context)

Default implementation of batch_evaluate/2 that delegates to shared implementation.

Raises on invalid fitness results. Override to customize error handling.

demo()

Run a quick demo that prints progress.

evaluate(text, context)

Fitness function that measures similarity to the target string.

Higher scores indicate better fitness (closer to target).

run(opts \\ [])

Run the hello world evolution example.

Options

  • :population_size - Size of the population (default: 100)
  • :generations - Maximum generations (default: 300)
  • :mutation_rate - Mutation rate (default: 0.3)
  • :crossover_rate - Crossover rate (default: 0.8)
  • :elitism_rate - Elitism rate (default: 0.02)
  • :target_fitness - Stop when fitness reaches this value (default: 0.99)
  • :seed - Initial population (default: 100 random strings)
  • :verbose - Print progress (default: false)

Examples

# Run with defaults
Jido.Evolve.Examples.HelloWorld.run()

# Run with custom settings
Jido.Evolve.Examples.HelloWorld.run(
  population_size: 50,
  mutation_rate: 0.6,
  verbose: true
)