An open-source implementation of the AlphaEvolve system described in the Google DeepMind paper "AlphaEvolve: A coding agent for scientific and algorithmic discovery" (2025).
OpenEvolve is an evolutionary coding agent that uses Large Language Models to optimize code through an iterative process. It orchestrates a pipeline of LLM-based code generation, evaluation, and selection to continuously improve programs for a variety of tasks.
Key features:
- Evolution of entire code files, not just single functions
- Support for multiple programming languages
- Supports OpenAI-compatible APIs for any LLM
- Multi-objective optimization
- Flexible prompt engineering
- Distributed evaluation
OpenEvolve follows an evolutionary approach with the following components:
- Prompt Sampler: Creates context-rich prompts containing past programs, their scores, and problem descriptions
- LLM Ensemble: Generates code modifications via an ensemble of language models
- Evaluator Pool: Tests generated programs and assigns scores
- Program Database: Stores programs and their evaluation metrics, guiding future evolution
The controller orchestrates interactions between these components in an asynchronous pipeline, maximizing throughput to evaluate as many candidate solutions as possible.
To install natively, use:
git clone https://github.com/codelion/openevolve.git
cd openevolve
pip install -e .
We use the OpenAI SDK, so you can use any LLM or provider that supports an OpenAI compatible API. Just set the OPENAI_API_KEY
environment variable
and update the api_base
in config.yaml if you are using a provider other than OpenAI. For local models, you can use
an inference server like optillm.
from openevolve import OpenEvolve
# Initialize the system
evolve = OpenEvolve(
initial_program_path="path/to/initial_program.py",
evaluation_file="path/to/evaluator.py",
config_path="path/to/config.yaml"
)
# Run the evolution
best_program = await evolve.run(iterations=1000)
print(f"Best program metrics:")
for name, value in best_program.metrics.items():
print(f" {name}: {value:.4f}")
OpenEvolve can also be run from the command line:
python openevolve-run.py path/to/initial_program.py path/to/evaluator.py --config path/to/config.yaml --iterations 1000
OpenEvolve automatically saves checkpoints at intervals specified by the checkpoint_interval
config parameter (default is 10 iterations). You can resume an evolution run from a saved checkpoint:
python openevolve-run.py path/to/initial_program.py path/to/evaluator.py \
--config path/to/config.yaml \
--checkpoint path/to/checkpoint_directory \
--iterations 50
When resuming from a checkpoint:
- The system loads all previously evolved programs and their metrics
- Checkpoint numbering continues from where it left off (e.g., if loaded from checkpoint_50, the next checkpoint will be checkpoint_60)
- All evolution state is preserved (best programs, feature maps, archives, etc.)
- Each checkpoint directory contains a copy of the best program at that point in time
Example workflow with checkpoints:
# Run for 50 iterations (creates checkpoints at iterations 10, 20, 30, 40, 50)
python openevolve-run.py examples/function_minimization/initial_program.py \
examples/function_minimization/evaluator.py \
--iterations 50
# Resume from checkpoint 50 for another 50 iterations (creates checkpoints at 60, 70, 80, 90, 100)
python openevolve-run.py examples/function_minimization/initial_program.py \
examples/function_minimization/evaluator.py \
--checkpoint examples/function_minimization/openevolve_output/checkpoints/checkpoint_50 \
--iterations 50
Each checkpoint directory contains the best program found up to that point, making it easy to compare solutions over time:
checkpoints/
checkpoint_10/
best_program.py # Best program at iteration 10
best_program_info.json # Metrics and details
programs/ # All programs evaluated so far
metadata.json # Database state
checkpoint_20/
best_program.py # Best program at iteration 20
...
You can compare the evolution of solutions by examining the best programs at different checkpoints:
# Compare best programs at different checkpoints
diff -u checkpoints/checkpoint_10/best_program.py checkpoints/checkpoint_20/best_program.py
# Compare metrics
cat checkpoints/checkpoint_*/best_program_info.json | grep -A 10 metrics
You can also install and execute via Docker:
docker build -t openevolve .
docker run --rm -v $(pwd):/app openevolve examples/function_minimization/initial_program.py examples/function_minimization/evaluator.py --config examples/function_minimization/config.yaml --iterations 1000
OpenEvolve is highly configurable. You can specify configuration options in a YAML file:
# Example configuration
max_iterations: 1000
llm:
primary_model: "gemini-2.0-flash-lite"
secondary_model: "gemini-2.0-flash"
temperature: 0.7
database:
population_size: 500
num_islands: 5
Sample configuration files are available in the configs/
directory:
default_config.yaml
: Comprehensive configuration with all available options
See the Configuration Guide for a full list of options.
See the examples/
directory for complete examples of using OpenEvolve on various problems:
A comprehensive example demonstrating OpenEvolve's application to symbolic regression tasks using the LLM-SRBench benchmark. This example shows how OpenEvolve can evolve simple mathematical expressions (like linear models) into complex symbolic formulas that accurately fit scientific datasets.
Explore the Symbolic Regression Example
Key features:
- Automatic generation of initial programs from benchmark tasks
- Evolution from simple linear models to complex mathematical expressions
- Evaluation on physics, chemistry, biology, and material science datasets
- Competitive results compared to state-of-the-art symbolic regression methods
Our implementation of the circle packing problem from the AlphaEvolve paper. For the n=26 case, where one needs to pack 26 circles in a unit square we also obtain SOTA results.
Explore the Circle Packing Example
We have sucessfully replicated the results from the AlphaEvolve paper, below is the packing found by OpenEvolve after 800 iterations
This is exactly the packing reported by AlphaEvolve in their paper (Figure 14):
An example showing how OpenEvolve can transform a simple random search algorithm into a sophisticated simulated annealing approach.
Explore the Function Minimization Example
To use OpenEvolve for your own problems:
- Mark code sections to evolve with
# EVOLVE-BLOCK-START
and# EVOLVE-BLOCK-END
comments - Create an evaluation function that returns a dictionary of metrics
- Configure OpenEvolve with appropriate parameters
- Run the evolution process
If you use OpenEvolve in your research, please cite:
@software{openevolve,
title = {OpenEvolve: Open-source implementation of AlphaEvolve},
author = {Asankhaya Sharma},
year = {2025},
publisher = {GitHub},
url = {https://github.com/codelion/openevolve}
}