Skip to content

Commit 1ee049a

Browse files
committed
fix
1 parent 956525a commit 1ee049a

File tree

2 files changed

+120
-2
lines changed

2 files changed

+120
-2
lines changed

CLAUDE.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Overview
6+
7+
OpenEvolve is an open-source implementation of Google DeepMind's AlphaEvolve system - an evolutionary coding agent that uses LLMs to optimize code through iterative evolution. The framework can evolve code in multiple languages (Python, R, Rust, etc.) for tasks like scientific computing, optimization, and algorithm discovery.
8+
9+
## Essential Commands
10+
11+
### Development Setup
12+
```bash
13+
# Install in development mode with all dependencies
14+
pip install -e ".[dev]"
15+
16+
# Or use Makefile
17+
make install
18+
```
19+
20+
### Running Tests
21+
```bash
22+
# Run all tests
23+
python -m unittest discover tests
24+
25+
# Or use Makefile
26+
make test
27+
```
28+
29+
### Code Formatting
30+
```bash
31+
# Format with Black
32+
python -m black openevolve examples tests scripts
33+
34+
# Or use Makefile
35+
make lint
36+
```
37+
38+
### Running OpenEvolve
39+
```bash
40+
# Basic evolution run
41+
python openevolve-run.py path/to/initial_program.py path/to/evaluator.py --config path/to/config.yaml --iterations 1000
42+
43+
# Resume from checkpoint
44+
python openevolve-run.py path/to/initial_program.py path/to/evaluator.py \
45+
--config path/to/config.yaml \
46+
--checkpoint path/to/checkpoint_directory \
47+
--iterations 50
48+
```
49+
50+
### Visualization
51+
```bash
52+
# View evolution tree
53+
python scripts/visualizer.py --path examples/function_minimization/openevolve_output/checkpoints/checkpoint_100/
54+
```
55+
56+
## High-Level Architecture
57+
58+
### Core Components
59+
60+
1. **Controller (`openevolve/controller.py`)**: Main orchestrator that manages the evolution process using ProcessPoolExecutor for parallel iteration execution.
61+
62+
2. **Database (`openevolve/database.py`)**: Implements MAP-Elites algorithm with island-based evolution:
63+
- Programs mapped to multi-dimensional feature grid
64+
- Multiple isolated populations (islands) evolve independently
65+
- Periodic migration between islands prevents convergence
66+
- Tracks absolute best program separately
67+
68+
3. **Evaluator (`openevolve/evaluator.py`)**: Cascade evaluation pattern:
69+
- Stage 1: Quick validation
70+
- Stage 2: Basic performance testing
71+
- Stage 3: Comprehensive evaluation
72+
- Programs must pass thresholds at each stage
73+
74+
4. **LLM Integration (`openevolve/llm/`)**: Ensemble approach with multiple models, configurable weights, and async generation with retry logic.
75+
76+
5. **Iteration (`openevolve/iteration.py`)**: Worker process that samples from islands, generates mutations via LLM, evaluates programs, and stores artifacts.
77+
78+
### Key Architectural Patterns
79+
80+
- **Island-Based Evolution**: Multiple populations evolve separately with periodic migration
81+
- **MAP-Elites**: Maintains diversity by mapping programs to feature grid cells
82+
- **Artifact System**: Side-channel for programs to return debugging data, stored as JSON or files
83+
- **Process Worker Pattern**: Each iteration runs in fresh process with database snapshot
84+
- **Double-Selection**: Programs for inspiration differ from those shown to LLM
85+
- **Lazy Migration**: Islands migrate based on generation counts, not iterations
86+
87+
### Code Evolution Markers
88+
89+
Mark code sections to evolve using:
90+
```python
91+
# EVOLVE-BLOCK-START
92+
# Code to evolve goes here
93+
# EVOLVE-BLOCK-END
94+
```
95+
96+
### Configuration
97+
98+
YAML-based configuration with hierarchical structure:
99+
- LLM models and parameters
100+
- Evolution strategies (diff-based vs full rewrites)
101+
- Database and island settings
102+
- Evaluation parameters
103+
104+
### Important Patterns
105+
106+
1. **Checkpoint/Resume**: Automatic saving of entire system state with seamless resume capability
107+
2. **Parallel Evaluation**: Multiple programs evaluated concurrently via TaskPool
108+
3. **Error Resilience**: Individual failures don't crash system - extensive retry logic and timeout protection
109+
4. **Prompt Engineering**: Template-based system with context-aware building and evolution history
110+
111+
### Development Notes
112+
113+
- Python >=3.9 required
114+
- Uses OpenAI-compatible APIs for LLM integration
115+
- Tests use unittest framework
116+
- Black for code formatting
117+
- Artifacts threshold: Small (<10KB) stored in DB, large saved to disk
118+
- Process workers load database snapshots for true parallelism

configs/default_config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# You can use this as a template for your own configuration
44

55
# General settings
6-
max_iterations: 1000 # Maximum number of evolution iterations
7-
checkpoint_interval: 50 # Save checkpoints every N iterations
6+
max_iterations: 100 # Maximum number of evolution iterations
7+
checkpoint_interval: 10 # Save checkpoints every N iterations
88
log_level: "INFO" # Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
99
log_dir: null # Custom directory for logs (default: output_dir/logs)
1010
random_seed: 42 # Random seed for reproducibility (null = random, 42 = default)

0 commit comments

Comments
 (0)