Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

openevolve

> AI 编程
Open source

Open-source implementation of AlphaEvolve

6.8K stars0 likes0 views
WebsiteGitHub

About

Open-source implementation of AlphaEvolve

OpenEvolve


Why OpenEvolve?

Autonomous Discovery

LLMs don't just optimize—they discover entirely new algorithms. No human guidance needed.

Proven Results

2-3x speedups on real hardware. State-of-the-art circle packing. Breakthrough optimizations.

Research Grade

Full reproducibility, extensive evaluation pipelines, and scientific rigor built-in.

OpenEvolve vs Manual Optimization:

Aspect Manual Optimization OpenEvolve
Time to Solution Days to weeks Hours
Exploration Breadth Limited by human creativity Unlimited LLM creativity
Reproducibility Hard to replicate Fully deterministic
Multi-objective Complex tradeoffs Automatic Pareto optimization
Scaling Doesn't scale Parallel evolution across islands

Proven Achievements

Quick Start

Get from zero to evolving code in 30 seconds:

bash
# Install OpenEvolve
pip install openevolve

# The example uses Google Gemini by default (free tier available)
# Get your API key from: https://aistudio.google.com/apikey
export OPENAI_API_KEY="your-gemini-api-key"  # Yes, use OPENAI_API_KEY env var

# Run your first evolution!
python openevolve-run.py examples/function_minimization/initial_program.py \
  examples/function_minimization/evaluator.py \
  --config examples/function_minimization/config.yaml \
  --iterations 50

Note: The example config uses Gemini by default, but you can use any OpenAI-compatible provider by modifying the config.yaml. See the configs for full configuration options.

Library Usage

OpenEvolve can be used as a library without any external files:

…

Prefer Docker? See the Installation & Setup section for Docker options.

See It In Action

Circle Packing: From Random to State-of-the-Art

Watch OpenEvolve discover optimal circle packing in real-time:

Generation 1 Generation 190 Generation 460 (Final)
Random placement Learning structure State-of-the-art result

Result: Matches published benchmarks for n=26 circle packing problem.

GPU Kernel Evolution

Before (Baseline):

metal
// Standard attention implementation
kernel void attention_baseline(/* ... */) {
    // Generic matrix multiplication
    float sum = 0.0;
    for (int i = 0; i < seq_len; i++) {
        sum += query[tid] * key[i];
    }
}

After Evolution (2.8x faster):

metal
// OpenEvolve discovered optimization
kernel void attention_evolved(/* ... */) {
    // Hardware-aware tiling + unified memory optimization
    threadgroup float shared_mem[256];
    // ... evolved algorithm exploiting Apple Silicon architecture
}

Performance Impact: 2.8x speedup on Apple M1 Pro, maintaining numerical accuracy.

How OpenEvolve Works

OpenEvolve implements a sophisticated evolutionary coding pipeline that goes far beyond simple optimization:

Core Innovation: MAP-Elites + LLMs

  • Quality-Diversity Evolution: Maintains diverse populations across feature dimensions
  • Island-Based Architecture: Multiple populations prevent premature convergence
  • LLM Ensemble: Multiple models with intelligent fallback strategies
  • Artifact Side-Channel: Error feedback improves subsequent generations

Advanced Features

Scientific Reproducibility
  • Comprehensive Seeding: Every component (LLM, database, evaluation) is seeded
  • Default Seed=42: Immediate reproducible results out of the box
  • Deterministic Evolution: Exact reproduction of runs across machines
  • Component Isolation: Hash-based isolation prevents cross-contamination
Advanced LLM Integration
  • Universal API: Works with OpenAI, Google, Claude Code CLI, local models, and proxies
  • Intelligent Ensembles: Weighted combinations with sophisticated fallback
  • Test-Time Compute: Enhanced reasoning through proxy systems (see OptiLLM setup)
  • Plugin Ecosystem: Support for advanced reasoning plugins
Evolution Algorithm Innovations
  • Double Selection: Different programs for performance vs inspiration
  • Adaptive Feature Dimensions: Custom quality-diversity metrics
  • Migration Patterns: Ring topology with controlled gene flow
  • Multi-Strategy Sampling: Elite, diverse, and exploratory selection

Perfect For

Use Case Why OpenEvolve Excels
Performance Optimization Discovers hardware-specific optimizations humans miss
Algorithm Discovery Finds novel approaches to classic problems
Scientific Computing Automates tedious manual tuning processes
Competitive Programming Generates multiple solution strategies
Multi-Objective Problems Pareto-optimal solutions across dimensions

Installation & Setup

Requirements

  • Python: 3.10+
  • LLM Access: Any OpenAI-compatible API, or Claude Code CLI
  • Optional: Docker for containerized runs

Installation Options

PyPI (Recommended)
bash
pip install openevolve
Development Install
bash
git clone https://github.com/algorithmicsuperintelligence/openevolve.git
cd openevolve
pip install -e ".[dev]"
Docker
bash
# Pull the image
docker pull ghcr.io/algorithmicsuperintelligence/openevolve:latest

# Run an example
docker run --rm -v $(pwd):/app ghcr.io/algorithmicsuperintelligence/openevolve:latest \
  examples/function_minimization/initial_program.py \
  examples/function_minimization/evaluator.py --iterations 100

Cost Estimation

Cost depends on your LLM provider and iterations:

  • o3: ~$0.15-0.60 per iteration (depending on code size)
  • o3-mini: ~$0.03-0.12 per iteration (more cost-effective)
  • Gemini-2.5-Pro: ~$0.08-0.30 per iteration
  • Gemini-2.5-Flash: ~$0.01-0.05 per iteration (fastest and cheapest)
  • Local models: Nearly free after setup
  • OptiLLM: Use cheaper models with test-time compute for better results

Cost-saving tips:

  • Start with fewer iterations (100-200)
  • Use o3-mini, Gemini-2.5-Flash or local models for exploration
  • Use cascade evaluation to filter bad programs early
  • Configure smaller population sizes initially

LLM Provider Setup

OpenEvolve works with any OpenAI-compatible API:

OpenAI (Direct)
bash
export OPENAI_API_KEY="sk-..."
# Uses OpenAI endpoints by default
Google Gemini
yaml
# config.yaml
llm:
  api_base: "https://generativelanguage.googleapis.com/v1beta/openai/"
  model: "gemini-2.5-pro"
bash
export OPENAI_API_KEY="your-gemini-api-key"
Local Models (Ollama/vLLM)
yaml
# config.yaml
llm:
  api_base: "http://localhost:11434/v1"  # Ollama
  model: "codellama:7b"
⚡ OptiLLM (Advanced)

For maximum flexibility with rate limiting, model routing, and test-time compute:

bash
# Install OptiLLM
pip install optillm

# Start OptiLLM proxy
optillm --port 8000

# Point OpenEvolve to OptiLLM
export OPENAI_API_KEY="your-actual-key"
yaml
llm:
  api_base: "http://localhost:8000/v1"
  model: "moa&readurls-o3"  # Test-time compute + web access
Claude Code CLI (No API Key)

Use the Claude Code CLI as the LLM backend — no API keys needed, authentication uses the CLI's OAuth session.

bash
# Install and authenticate
npm install -g @anthropic-ai/claude-code
claude login
yaml
# config.yaml
llm:
  provider: "claude_code"
  models:
    - name: "sonnet"
      weight: 0.8
      max_tokens: 16000
      max_budget_usd: 1.0
    - name: "haiku"
      weight: 0.2
      max_tokens: 8000

See the Claude Code quickstart example for a complete walkthrough.

Examples Gallery

Quick Example: Function Minimization

Watch OpenEvolve evolve from random search to sophisticated optimization:

python
# Initial Program (Random Search)
def minimize_function(func, bounds, max_evals=1000):
    best_x, best_val = None, float('inf')
    for _ in range(max_evals):
        x = random_point_in_bounds(bounds)
        val = func(x)
        if val < best_val:
            best_x, best_val = x, val
    return best_x, best_val

Evolution Process

python
# Evolved Program (Simulated Annealing + Adaptive Cooling)
def minimize_function(func, bounds, max_evals=1000):
    x = random_point_in_bounds(bounds)
    temp = adaptive_initial_temperature(func, bounds)
    
    for i in range(max_evals):
        neighbor = generate_neighbor(x, temp, bounds)
        delta = func(neighbor) - func(x)
        
        if delta < 0 or random.random() < exp(-delta/temp):
            x = neighbor
            
        temp *= adaptive_cooling_rate(i, max_evals)  # Dynamic cooling
    
    return x, func(x)

Performance: 100x improvement in convergence speed!

Advanced Examples

Prompt Evolution

Evolve prompts instead of code for better LLM performance. See the LLM Prompt Optimization example for a complete case study with HotpotQA achieving +23% accuracy improvement.

Full Example

Competitive Programming

Automatic solution generation for programming contests:

python
# Problem: Find maximum subarray sum
# OpenEvolve discovers multiple approaches:

# Evolution Path 1: Brute Force → Kadane's Algorithm
# Evolution Path 2: Divide & Conquer → Optimized Kadane's
# Evolution Path 3: Dynamic Programming → Space-Optimized DP

Online Judge Integration

Configuration

OpenEvolve offers extensive configuration for advanced users:

…

For Gemini embeddings, set GEMINI_API_KEY. GOOGLE_API_KEY is also supported as a fallback. OpenEvolve uses Google's OpenAI-compatible endpoint automatically.

Feature Engineering

Control how programs are organized in the quality-diversity grid:

yaml
database:
  feature_dimensions: 
    - "complexity"      # Built-in: code length
    - "diversity"       # Built-in: structural diversity
    - "performance"     # Custom: from your evaluator
    - "memory_usage"    # Custom: from your evaluator
    
  feature_bins:
    complexity: 10      # 10 complexity levels
    performance: 20     # 20 performance buckets
    memory_usage: 15    # 15 memory usage categories

Important: Return raw values from evaluator, OpenEvolve handles binning automatically.

Custom Prompt Templates

Advanced prompt engineering with custom templates:

yaml
prompt:
  template_dir: "custom_templates/"
  use_template_stochasticity: true
  template_variations:
    greeting:
      - "Let's enhance this code:"
      - "Time to optimize:"
      - "Improving the algorithm:"
    improvement_suggestion:
      - "Here's how we could improve this code:"
      - "I suggest the following imp

Issues· 120 open

View all issuesOpen on GitHub
  • #464

    Feature Request: Expose Island Selection / Population Management as a Pluggable Strategy

    enhancementUpdated Sep 23, 2026
  • #483

    Novelty judge can never reject: prompt asks for NOT_NOVEL, parser matches "NOT NOVEL"

    Updated Sep 4, 2026
  • #484

    Using Codex Subscription tokens

    Updated Aug 28, 2026
  • #311

    Include competition between evolved populations

    enhancementUpdated Aug 15, 2026
  • #468

    Bidirectional interop with Google Cloud AlphaEvolve (run AE examples on OE, and export OE programs to the AE service)

    enhancementhelp wantedgood first issueUpdated Aug 15, 2026
  • #481

    evaluator` exec_module operator-supplied code in-process; `visualizer` serves checkpoint data with no auth

    Updated Aug 3, 2026
  • #474

    [Question/Usage] What is the best way of passing arguments to the evaluate.py function?

    Updated Jul 26, 2026
  • #413

    How to optimize the whole code repository?

    enhancementquestionUpdated Jun 27, 2026
  • #453

    Enhancing `combined_score` to support multi-objective optimization via lexicographical ordering

    Updated Jun 3, 2026
  • #434

    Add option to checkpoint only when improvement is detected

    enhancementhelp wantedUpdated May 8, 2026

> Tags

Pythonalpha-evolvealphacodealphaevolvecoding-agent

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 23, 2026
CategoryAI 编程
PricingOpen source

> Related tools

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.