Skip to content

metaforismo/OpenAlphaEvolve

Repository files navigation

AlphaEvolve

A simplified recreation of the OpenEvolve project - an evolutionary coding agent that uses LLMs to evolve and optimize code.

What is this?

This is a learning project that recreates the core structure of OpenEvolve, an open-source implementation of evolutionary coding algorithms. The goal is to understand how evolutionary algorithms can be combined with Large Language Models (LLMs) to autonomously discover and optimize code solutions.

Project Structure

AlphaEvolve/
├── openevolve/                 # Main package
│   ├── __init__.py            
│   ├── _version.py            
│   ├── cli.py                 # Command-line interface
│   └── evaluation_result.py   # Evaluation result container
├── examples/                   # Example problems
│   └── function_minimization/  # Example: optimize a search algorithm
│       ├── initial_program.py  # Starting algorithm (random search)
│       ├── evaluator.py        # Evaluation metrics
│       └── config.yaml         # Configuration
├── openevolve-run.py          # Main entry point
├── setup.py                   
├── pyproject.toml             
├── README.md                  
└── LEARNINGS.md               # Personal learnings and insights

Key Concepts

Evolutionary Coding

  • Uses LLMs to generate code variations (mutations)
  • Evaluates each variation against objective metrics
  • Selects the best performers to create next generation
  • Iterates to discover increasingly better solutions

Example: Function Minimization

The included example demonstrates optimizing a search algorithm:

  • Initial Program: Simple random search (often gets stuck in local minima)
  • Goal: Evolve it to reliably find the global minimum of a complex function
  • Target Function: f(x,y) = sin(x)*cos(y) + sin(x*y) + (x²+y²)/20

Installation

# Install in development mode
pip install -e .

# Run the example (requires LLM API key)
export OPENAI_API_KEY="your-api-key"
python openevolve-run.py examples/function_minimization/initial_program.py \
  examples/function_minimization/evaluator.py \
  --config examples/function_minimization/config.yaml \
  --iterations 100

Requirements

  • Python 3.10+
  • numpy
  • pyyaml

How It Works

  1. Initial Program: Start with a basic implementation
  2. Evaluation: Run the program and measure performance
  3. Evolution: Use LLM to generate improved versions
  4. Selection: Keep the best performing variants
  5. Iteration: Repeat until convergence or max iterations

Note

This is a minimal recreation for learning purposes. The original OpenEvolve includes:

  • MAP-Elites quality-diversity algorithm
  • Island-based parallel evolution
  • Advanced LLM ensemble strategies
  • Comprehensive evaluation pipelines
  • Result visualization tools

For the full implementation, see the original OpenEvolve repository.

Learning Goals

This project explores:

  • How evolutionary algorithms work
  • Integration of LLMs in code generation
  • Evaluation metrics for algorithm quality
  • Python package structure and design patterns

See LEARNINGS.md for detailed personal insights.

License

MIT License - This is an educational recreation

Acknowledgments

Based on OpenEvolve by the OpenEvolve community.

About

AlphaEvolve but OpenSource from scratch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages