Skip to content

Commit dd2e3e4

Browse files
authored
Merge pull request #341 from algorithmicsuperintelligence/fix-readme
Fix readme
2 parents ee63e6d + 08f04ad commit dd2e3e4

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

examples/README.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ def helper_function():
3232

3333
### 2. Evaluator (`evaluator.py`)
3434

35-
Your evaluator must return a **dictionary** with specific metric names:
35+
Your evaluator can return either a **dictionary** or an **`EvaluationResult`** object:
3636

3737
```python
3838
def evaluate(program_path: str) -> Dict:
3939
"""
40-
Evaluate the program and return metrics as a dictionary.
41-
42-
CRITICAL: Must return a dictionary, not an EvaluationResult object.
40+
Evaluate the program and return metrics.
41+
42+
Can return either a dict or EvaluationResult object.
43+
Use EvaluationResult if you want to include artifacts for debugging.
4344
"""
4445
try:
4546
# Import and run your program
@@ -57,13 +58,23 @@ def evaluate(program_path: str) -> Dict:
5758
'combined_score': 0.0, # Always return combined_score, even on error
5859
'error': str(e)
5960
}
61+
62+
# Or use EvaluationResult for artifacts support:
63+
from openevolve.evaluation_result import EvaluationResult
64+
65+
def evaluate(program_path: str) -> EvaluationResult:
66+
return EvaluationResult(
67+
metrics={'combined_score': 0.8, 'accuracy': 0.9},
68+
artifacts={'debug_info': 'useful debugging data'}
69+
)
6070
```
6171

6272
**Critical Requirements:**
63-
-**Return a dictionary**, not `EvaluationResult` object
73+
-**Return a dictionary or `EvaluationResult`** - both are supported
6474
-**Must include `'combined_score'`** - this is the primary metric OpenEvolve uses
6575
- ✅ Higher `combined_score` values should indicate better programs
6676
- ✅ Handle exceptions and return `combined_score: 0.0` on failure
77+
- ✅ Use `EvaluationResult` with artifacts for richer debugging feedback
6778

6879
### 3. Configuration (`config.yaml`)
6980

@@ -121,18 +132,17 @@ log_level: "INFO"
121132

122133
## Common Configuration Mistakes
123134

124-
❌ **Wrong:** `feature_dimensions: 2`
135+
❌ **Wrong:** `feature_dimensions: 2`
125136
✅ **Correct:** `feature_dimensions: ["score", "complexity"]`
126137

127-
❌ **Wrong:** Returning `EvaluationResult` object
128-
✅ **Correct:** Returning `{'combined_score': 0.8, ...}` dictionary
129-
130-
❌ **Wrong:** Using `'total_score'` metric name
138+
❌ **Wrong:** Using `'total_score'` metric name
131139
✅ **Correct:** Using `'combined_score'` metric name
132140

133-
❌ **Wrong:** Multiple EVOLVE-BLOCK sections
141+
❌ **Wrong:** Multiple EVOLVE-BLOCK sections
134142
✅ **Correct:** Exactly one EVOLVE-BLOCK section
135143

144+
💡 **Tip:** Both `{'combined_score': 0.8, ...}` dict and `EvaluationResult(metrics={...}, artifacts={...})` are valid return types
145+
136146
## MAP-Elites Feature Dimensions Best Practices
137147

138148
When using custom feature dimensions, your evaluator must return **raw continuous values**, not pre-computed bin indices:

0 commit comments

Comments
 (0)