A simplified recreation of the OpenEvolve project - an evolutionary coding agent that uses LLMs to evolve and optimize code.
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.
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
- 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
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
# 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- Python 3.10+
- numpy
- pyyaml
- Initial Program: Start with a basic implementation
- Evaluation: Run the program and measure performance
- Evolution: Use LLM to generate improved versions
- Selection: Keep the best performing variants
- Iteration: Repeat until convergence or max iterations
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.
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.
MIT License - This is an educational recreation
Based on OpenEvolve by the OpenEvolve community.