Skip to content

Commit 640de0d

Browse files
committed
EvaluatorRepairRequest fallback metrics added
1 parent 638c2f2 commit 640de0d

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

openevolve/evaluation_result.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import json
66
from dataclasses import dataclass, field
7-
from typing import Dict, Union
7+
from typing import Dict, Optional, Union
88

99

1010
class EvaluatorRepairRequest(Exception):
@@ -18,17 +18,23 @@ class EvaluatorRepairRequest(Exception):
1818
original.
1919
2020
Args:
21-
message: Human-readable error description (shown in repair history
22-
and logged).
23-
broken_code: The full source that failed. Must be the complete file,
24-
not just the error region, so the repair LLM has full
25-
context.
26-
repair_context: Optional extra information for the repair prompt (e.g.
27-
full compiler stderr, runtime traceback). Defaults to
28-
the same text as *message*.
29-
language: Source-language identifier used in the prompt code fence
30-
(e.g. ``"cpp"``, ``"python"``). Defaults to
31-
``"python"``.
21+
message: Human-readable error description (shown in repair history
22+
and logged).
23+
broken_code: The full source that failed. Must be the complete file,
24+
not just the error region, so the repair LLM has full
25+
context.
26+
repair_context: Optional extra information for the repair prompt (e.g.
27+
full compiler stderr, runtime traceback). Defaults to
28+
the same text as *message*.
29+
language: Source-language identifier used in the prompt code fence
30+
(e.g. ``"cpp"``, ``"python"``). Defaults to
31+
``"python"``.
32+
fallback_metrics: Metrics dict to use if repair is disabled or all repair
33+
attempts are exhausted. Should include all feature
34+
dimensions required by the MAP-Elites database set to
35+
appropriate penalty values, plus ``combined_score: 0.0``.
36+
When ``None``, a minimal ``{"combined_score": 0.0}`` is
37+
used.
3238
"""
3339

3440
def __init__(
@@ -37,11 +43,13 @@ def __init__(
3743
broken_code: str,
3844
repair_context: str = "",
3945
language: str = "python",
46+
fallback_metrics: Optional[Dict[str, float]] = None,
4047
) -> None:
4148
super().__init__(message)
4249
self.broken_code = broken_code
4350
self.repair_context = repair_context or message
4451
self.language = language
52+
self.fallback_metrics: Dict[str, float] = fallback_metrics or {"combined_score": 0.0}
4553

4654

4755
@dataclass

openevolve/evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ async def evaluate_program(
293293
"compile_error": str(repair_req),
294294
"repair_context": repair_req.repair_context,
295295
})
296-
return {"combined_score": 0.0, "error": 0.0}
296+
return repair_req.fallback_metrics
297297

298298
except Exception as e:
299299
last_exception = e

0 commit comments

Comments
 (0)