diff --git a/examples/arc_benchmark/README.md b/examples/arc_benchmark/README.md new file mode 100644 index 000000000..d663f7a11 --- /dev/null +++ b/examples/arc_benchmark/README.md @@ -0,0 +1,186 @@ +# ARC Benchmark example + +This example demonstrates how one can use OpenEvolve to solve tasks from the [ARC-AGI benchmark](https://arcprize.org/) + +## Problem Description + +At the core of ARC-AGI benchmark design is the principle of "Easy for Humans, Hard for AI." + +In each task, you are provided with a few "train" examples consisting of input-output grid pairs. These pairs have a common underlying transformation that maps the inputs to the outputs. Your objective is to learn this underlying transformation and successfully apply it to the test input(s). You are allowed to make 2 attempts and is any one of them is 100% matching the expected output, you have "passed". This metric is also known as "pass@2 accuracy". Below is an example of such a task ([Task 00576224](https://arcprize.org/tasks/00576224/)). For more examples and information, refer to the [ARC-AGI benchmark](https://arcprize.org/) website. + + +![ARC example task (Task 00576224)](./images/example.png) + +## Getting Started + +Download the arc-prize-2025 dataset from [Kaggle](https://www.kaggle.com/competitions/arc-prize-2025/data). + +Set the correct dataset root and API key in `examples/arc_benchmark/run_evolution.sh` by editing the lines: +```bash +export OPENAI_API_KEY="your-gemini-api-key" +export DATA_ROOT="../../data/arc-prize-2025" +``` + +If you want to use the 'training' or 'test' ARC tasks instead of the default 'evaluation' tasks, edit the following lines in `examples/arc_benchmark/run_evolution.sh` +```bash +TASK_FILE="evaluation" # Options: training, evaluation, test (default: evaluation) +... +export ARC_TASK_FILE=$TASK_FILE +``` + +To run this example, with default task (Task 0 from arc-agi_evaluation_challenges.json): + +```bash +cd examples/arc_benchmark +chmod +x ./run_evolution.sh +./run_evolution.sh 0 # Replace the 0 with your favorite task number +``` +The order of Task IDs is the same as the order on [this link](https://arcprize.org/tasks/). ('evaluation' set Task 0 = Task ID 0934a4d8) + +## Example Task 0934a4d8 + +![ARC example task (Task 00576224)](./images/Evolved%20task.png) + +Base Gemini-3-Pro fails to solve this task (https://arcprize.org/tasks/0934a4d8/) + +After just 2 iterations of OpenEvolve using `examples/arc_benchmark/initial_program.py` as a seed program, it manages to discover the solution in the following python program: + +```python +# EVOLVE-BLOCK-START + +import numpy as np + +def transform_grid_attempt_1(grid): + """ + Transformation logic: + 1. Identify the bounding box of the '8' values (mask) in the grid. + 2. The output grid has the same dimensions as this bounding box. + 3. For each cell (r, c) in the bounding box: + a. Calculate the vertically symmetric row: target_r = (Height + 1) - r. + If target_r is valid and grid[target_r, c] is not 8, use it. + b. Otherwise, use the diagonally transposed position: grid[c, r]. + """ + arr = _validate_grid(grid) + rows, cols = np.where(arr == 8) + + if len(rows) == 0: + return arr + + min_r, max_r = np.min(rows), np.max(rows) + min_c, max_c = np.min(cols), np.max(cols) + + height = max_r - min_r + 1 + width = max_c - min_c + 1 + + out = np.zeros((height, width), dtype=np.int32) + + N = arr.shape[0] + # Reflection constant determined to be N + 1 (31 for 30x30) + reflection_constant = N + 1 + + for r in range(min_r, max_r + 1): + for c in range(min_c, max_c + 1): + target_r = reflection_constant - r + + val = 8 + if 0 <= target_r < N: + val = arr[target_r, c] + + if val == 8: + # Fallback to diagonal transpose + # Ensure indices are within bounds (though for square grids they should be) + if 0 <= c < N and 0 <= r < arr.shape[1]: + val = arr[c, r] + + out[r - min_r, c - min_c] = val + + return out + +def transform_grid_attempt_2(grid): + """ + Similar to attempt 1 but with an additional fallback strategy. + Strategies: + 1. Vertical reflection: grid[31-r, c] + 2. Diagonal transpose: grid[c, r] + 3. Horizontal reflection: grid[r, 31-c] + """ + arr = _validate_grid(grid) + rows, cols = np.where(arr == 8) + + if len(rows) == 0: + return arr + + min_r, max_r = np.min(rows), np.max(rows) + min_c, max_c = np.min(cols), np.max(cols) + + out = np.zeros((max_r - min_r + 1, max_c - min_c + 1), dtype=np.int32) + N = arr.shape[0] + M = arr.shape[1] + + for r in range(min_r, max_r + 1): + for c in range(min_c, max_c + 1): + val = 8 + + # 1. Vertical reflection + tr = (N + 1) - r + if 0 <= tr < N: + val = arr[tr, c] + + # 2. Diagonal transpose + if val == 8: + if 0 <= c < N and 0 <= r < M: + val = arr[c, r] + + # 3. Horizontal reflection + if val == 8: + tc = (M + 1) - c + if 0 <= tc < M: + val = arr[r, tc] + + out[r - min_r, c - min_c] = val + + return out + +# EVOLVE-BLOCK-END +``` + +Both the attempts of the solution successfully solve all the train examples as well as the test example. The relevant output files are `examples/arc_benchmark/outputs/evaluation_task_0/best/best_program_info.json` and `examples/arc_benchmark/outputs/evaluation_task_0/best/post_evolution_evaluation_result.json`. + +```json +{ + "id": "ce48590c-4448-45b9-83f4-9e0a85424033", + "generation": 1, + "iteration": 2, + "timestamp": 1767790991.5850093, + "parent_id": "90c2a0c2-e3bd-4aa4-9bdc-1ab1b9326f97", + "metrics": { + "runs_successfully": 1.0, + "combined_score": 1.0, + "train_example_0_pass_at_2": 1, + "train_example_0_attempt_0": true, + "train_example_0_attempt_1": true, + "train_example_1_pass_at_2": 1, + "train_example_1_attempt_0": true, + "train_example_1_attempt_1": true, + "train_example_2_pass_at_2": 1, + "train_example_2_attempt_0": true, + "train_example_2_attempt_1": true, + "train_example_3_pass_at_2": 1, + "train_example_3_attempt_0": true, + "train_example_3_attempt_1": true + }, + "language": "python", + "saved_at": 1767791374.6249106 +} + +{ + "metrics": { + "runs_successfully": 1.0, + "combined_score": 1.0, + "test_example_0_pass_at_2": 1, + "test_example_0_attempt_0": true, + "test_example_0_attempt_1": true + }, + "artifacts": {} +} +``` diff --git a/examples/arc_benchmark/base_config.yaml b/examples/arc_benchmark/base_config.yaml new file mode 100644 index 000000000..cda8033dd --- /dev/null +++ b/examples/arc_benchmark/base_config.yaml @@ -0,0 +1,74 @@ +# Configuration for HuggingFace prompt optimization +# Based on optimized settings from config2.yaml + +# General settings +max_iterations: 100 +checkpoint_interval: 10 + +# LLM configuration +llm: + api_base: "https://generativelanguage.googleapis.com/v1beta/openai/" + models: + - name: "gemini-3-pro-preview" + timeout: 3000 + # optional knobs (names depend on the example config) + temperature: 0.7 + max_tokens: 32768 + top_p: 0.95 + +# Prompt Configuration - Optimal settings discovered +prompt: + # System message for prompt evolution + system_message: | + You are participating in a puzzle solving competition. You are an expert at solving puzzles. + + Find the common pattern that transforms each input grid into its corresponding output grid... + + Your task is to write a python function that transforms each input grid into its corresponding output grid. This function must: + - Apply consistently to ALL training examples + - Be general enough to work on new test cases + - Be intuitive and easy to understand + - Apply the pattern without referencing specific example numbers + + You are provided the following training example grids: + In 0 - [[3, 5, 3, 3, 6, 6, 5, 4, 1, 4, 9, 9, 4, 3, 9, 9, 9, 9, 3, 4, 9, 9, 4, 1, 4, 5, 6, 6, 3, 3], [5, 3, 3, 3, 6, 6, 4, 5, 4, 1, 9, 9, 3, 4, 9, 1, 1, 9, 4, 3, 9, 9, 1, 4, 5, 4, 6, 6, 3, 3], [1, 1, 3, 5, 5, 4, 6, 6, 9, 1, 1, 4, 9, 9, 4, 5, 5, 4, 9, 9, 4, 1, 1, 9, 6, 6, 4, 5, 5, 3], [1, 1, 5, 3, 4, 5, 6, 6, 1, 9, 4, 1, 9, 1, 4, 4, 4, 4, 1, 9, 1, 4, 9, 1, 6, 6, 5, 4, 3, 5], [6, 9, 9, 9, 3, 5, 3, 3, 4, 3, 9, 9, 9, 2, 6, 9, 9, 6, 2, 9, 9, 9, 3, 4, 3, 3, 5, 3, 9, 9], [9, 6, 9, 9, 5, 3, 3, 3, 3, 4, 9, 1, 9, 9, 9, 6, 6, 9, 9, 9, 1, 9, 4, 3, 3, 3, 3, 5, 9, 9], [9, 9, 6, 9, 1, 1, 3, 5, 9, 9, 4, 4, 6, 9, 9, 2, 2, 9, 9, 6, 4, 4, 9, 9, 5, 3, 1, 1, 9, 6], [9, 9, 9, 6, 1, 1, 5, 3, 9, 1, 5, 4, 9, 6, 9, 9, 9, 9, 6, 9, 4, 5, 1, 9, 3, 5, 1, 1, 6, 9], [1, 4, 9, 1, 4, 3, 9, 9, 5, 5, 7, 2, 4, 3, 2, 4, 4, 2, 3, 4, 2, 7, 5, 5, 9, 9, 3, 4, 1, 9], [4, 1, 1, 9, 3, 4, 9, 1, 4, 5, 2, 7, 3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 - [[6, 9, 6, 6], [9, 3, 9, 9], [3, 4, 9, 9], [1, 9, 4, 1]] + + You are also provided the test input that you have to succesfully transform into the output using your python code: + In Test 0 - [[4, 4, 1, 3, 5, 7, 7, 9, 6, 1, 6, 6, 4, 4, 7, 7, 7, 7, 4, 4, 6, 6, 1, 6, 9, 7, 7, 5, 3, 1], [4, 4, 3, 3, 7, 5, 9, 7, 6, 6, 6, 6, 4, 4, 7, 2, 2, 7, 4, 4, 6, 6, 6, 6, 7, 9, 5, 7, 3, 3], [3, 4, 4, 4, 7, 9, 5, 7, 5, 1, 6, 1, 7, 7, 9, 9, 9, 9, 7, 7, 1, 6, 1, 5, 7, 5, 9, 7, 4, 4], [4, 3, 4, 4, 9, 7, 7, 5, 1, 5, 6, 6, 7, 2, 1, 9, 9, 1, 2, 7, 6, 6, 5, 1, 5, 7, 7, 9, 4, 4], [9, 7, 7, 4, 4, 4, 3, 3, 4, 4, 7, 7, 9, 7, 3, 2, 2, 3, 7, 9, 7, 7, 4, 4, 3, 3, 4, 4, 4, 7], [7, 9, 4, 7, 4, 4, 3, 1, 4, 4, 7, 2, 7, 9, 2, 3, 3, 2, 9, 7, 2, 7, 4, 4, 1, 3, 4, 4, 7, 4], [7, 4, 9, 7, 3, 4, 4, 4, 7, 7, 9, 1, 7, 4, 9, 7, 7, 9, 4, 7, 1, 9, 7, 7, 4, 4, 4, 3, 7, 9], [4, 7, 7, 9, 4, 3, 4, 4, 7, 2, 9, 9, 4, 7, 7, 9, 9, 7, 7, 4, 9, 9, 2, 7, 4, 4, 3, 4, 9, 7], [6, 6, 5, 1, 4, 4, 7, 7, 7, 2, 2, 6, 4, 6, 2, 2, 2, 2, 6, 4, 6, 2, 2, 7, 7, 7, 4, 4, 1, 5], [1, 6, 1, 5, 4, 4, 7, 2, 3, 7, 6, 6, 6, 4, 2, 2, 2, 2, 4, 6, 6, 6, 7, 3, 2, 7, 4, 4, 5, 1], [6, 6, 6, 6, 7, 7, 9, 9, 9, 1, 7, 2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 9, 9, 9, 7, 7, 6, 6], [8, 8, 8, 5, 4, 4, 7, 2, 3, 7, 6, 6, 6, 4, 2, 2, 2, 2, 4, 6, 6, 6, 7, 3, 2, 7, 4, 4, 5, 1], [6, 6, 5, 1, 4, 4, 7, 7, 7, 2, 2, 6, 4, 6, 2, 2, 2, 2, 6, 4, 6, 2, 2, 7, 7, 7, 4, 4, 1, 5], [4, 7, 7, 9, 4, 3, 4, 4, 7, 2, 9, 9, 4, 7, 7, 9, 9, 7, 7, 4, 9, 9, 2, 7, 4, 4, 3, 4, 9, 7], [7, 4, 9, 7, 3, 4, 4, 4, 7, 7, 9, 1, 7, 4, 9, 7, 7, 9, 4, 7, 1, 9, 7, 7, 4, 4, 4, 3, 7, 9], [7, 9, 4, 7, 4, 4, 3, 1, 4, 4, 7, 2, 7, 9, 2, 3, 3, 2, 9, 7, 2, 7, 4, 4, 1, 3, 4, 4, 7, 4], [9, 7, 7, 4, 4, 4, 3, 3, 4, 4, 7, 7, 9, 7, 3, 2, 2, 3, 7, 9, 7, 7, 4, 4, 3, 3, 4, 4, 4, 7], [4, 3, 4, 4, 9, 7, 7, 5, 1, 5, 6, 6, 7, 2, 1, 9, 9, 1, 2, 7, 6, 6, 5, 1, 5, 7, 7, 9, 4, 4], [3, 4, 4, 4, 7, 9, 5, 7, 5, 1, 6, 1, 7, 7, 9, 9, 9, 9, 7, 7, 1, 6, 1, 5, 7, 5, 9, 7, 4, 4]] + + Looking carefully at the train input-output pairs, understand the transformation and modify PYTHON functions to generate 2 attempts to solve the task. These python functions will sequentially take each input grid as a numpy array and output the transformed grid as a numpy array. Your solution will then be evaluated against the ground truth output grid. + Remember to only output the modified python functions as your solution. + +# Database configuration +database: + population_size: 50 + archive_size: 20 + num_islands: 3 + elite_selection_ratio: 0.2 + exploitation_ratio: 0.7 + + # embedding_model: "text-embedding-3-small" + similarity_threshold: 0.99 + +# Evaluator Configuration +evaluator: + timeout: 180000 + max_retries: 3 + parallel_evaluations: 4 + cascade_evaluation: false + +# Evolution settings +diff_based_evolution: true +max_code_length: 50000 + +# Early stopping settings +early_stopping_patience: -1 # Stop after N iterations without improvement (null = disabled) +convergence_threshold: 1.0 # Minimum improvement required to reset patience counter +early_stopping_metric: "combined_score" # Metric to track for early stopping diff --git a/examples/arc_benchmark/config.yaml b/examples/arc_benchmark/config.yaml new file mode 100644 index 000000000..ddc05bf98 --- /dev/null +++ b/examples/arc_benchmark/config.yaml @@ -0,0 +1,228 @@ +checkpoint_interval: 10 +convergence_threshold: 1.0 +database: + archive_size: 20 + elite_selection_ratio: 0.2 + exploitation_ratio: 0.7 + num_islands: 3 + population_size: 50 + similarity_threshold: 0.99 +diff_based_evolution: true +early_stopping_metric: combined_score +early_stopping_patience: -1 +evaluator: + cascade_evaluation: false + max_retries: 3 + parallel_evaluations: 4 + timeout: 180000 +llm: + api_base: https://generativelanguage.googleapis.com/v1beta/openai/ + max_tokens: 32768 + models: + - name: gemini-3-pro-preview + temperature: 0.7 + timeout: 3000 + top_p: 0.95 +max_code_length: 50000 +max_iterations: 100 +prompt: + system_message: "You are participating in a puzzle solving competition. You are\ + \ an expert at solving puzzles.\nFind the common pattern that transforms each\ + \ input grid into its corresponding output grid...\n\nYour task is to write a\ + \ python function that transforms each input grid into its corresponding output\ + \ grid. This function must:\n- Apply consistently to ALL training examples\n-\ + \ Be general enough to work on new test cases \n- Be intuitive and easy to understand\n\ + - Apply the pattern without referencing specific example numbers\n\nYou are provided\ + \ the following training example grids:\nIn 0 - [[3, 5, 3, 3, 6, 6, 5, 4, 1, 4,\ + \ 9, 9, 4, 3, 9, 9, 9, 9, 3, 4, 9, 9, 4, 1, 4, 5, 6, 6, 3, 3], [5, 3, 3, 3, 6,\ + \ 6, 4, 5, 4, 1, 9, 9, 3, 4, 9, 1, 1, 9, 4, 3, 9, 9, 1, 4, 5, 4, 6, 6, 3, 3],\ + \ [1, 1, 3, 5, 5, 4, 6, 6, 9, 1, 1, 4, 9, 9, 4, 5, 5, 4, 9, 9, 4, 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 1, 9, 3, 1, 6, 7], [6, 6, 6, 7, 3,\ + \ 1, 5, 9, 3, 4, 9, 1, 6, 7, 2, 5, 5, 2, 7, 6, 1, 9, 4, 3, 9, 5, 1, 3, 7, 6],\ + \ [9, 1, 1, 3, 1, 7, 6, 5, 9, 9, 4, 1, 1, 3, 4, 1, 1, 4, 3, 1, 1, 4, 9, 9, 5,\ + \ 6, 7, 1, 3, 1], [6, 9, 3, 1, 7, 1, 5, 6, 9, 9, 1, 4, 9, 1, 1, 4, 4, 1, 1, 9,\ + \ 4, 1, 9, 9, 6, 5, 1, 7, 1, 3]]\nOut 3 - [[6, 9, 6, 6], [9, 3, 9, 9], [3, 4,\ + \ 9, 9], [1, 9, 4, 1]]\n\n\nYou are also provided the test input that you have\ + \ to succesfully transform into the output using your python code:\nIn Test 0\ + \ - [[4, 4, 1, 3, 5, 7, 7, 9, 6, 1, 6, 6, 4, 4, 7, 7, 7, 7, 4, 4, 6, 6, 1, 6,\ + \ 9, 7, 7, 5, 3, 1], [4, 4, 3, 3, 7, 5, 9, 7, 6, 6, 6, 6, 4, 4, 7, 2, 2, 7, 4,\ + \ 4, 6, 6, 6, 6, 7, 9, 5, 7, 3, 3], [3, 4, 4, 4, 7, 9, 5, 7, 5, 1, 6, 1, 7, 7,\ + \ 9, 9, 9, 9, 7, 7, 1, 6, 1, 5, 7, 5, 9, 7, 4, 4], [4, 3, 4, 4, 9, 7, 7, 5, 1,\ + \ 5, 6, 6, 7, 2, 1, 9, 9, 1, 2, 7, 6, 6, 5, 1, 5, 7, 7, 9, 4, 4], [9, 7, 7, 4,\ + \ 4, 4, 3, 3, 4, 4, 7, 7, 9, 7, 3, 2, 2, 3, 7, 9, 7, 7, 4, 4, 3, 3, 4, 4, 4, 7],\ + \ [7, 9, 4, 7, 4, 4, 3, 1, 4, 4, 7, 2, 7, 9, 2, 3, 3, 2, 9, 7, 2, 7, 4, 4, 1,\ + \ 3, 4, 4, 7, 4], [7, 4, 9, 7, 3, 4, 4, 4,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3, 7, 9, 7, 7, 4, 4, 3, 3, 4, 4, 4, 7], [4, 3, 4, 4, 9, 7, 7, 5, 1, 5,\ + \ 6, 6, 7, 2, 1, 9, 9, 1, 2, 7, 6, 6, 5, 1, 5, 7, 7, 9, 4, 4], [3, 4, 4, 4, 7,\ + \ 9, 5, 7, 5, 1, 6, 1, 7, 7, 9, 9, 9, 9, 7, 7, 1, 6, 1, 5, 7, 5, 9, 7, 4, 4]]\n\ + \n\nLooking carefully at the train input-output pairs, understand the transformation\ + \ and modify PYTHON functions to generate 2 attempts to solve the task. These\ + \ python functions will sequentially take each input grid as a numpy array and\ + \ output the transformed grid as a numpy array. Your solution will then be evaluated\ + \ against the ground truth output grid.\nRemember to only output the modified\ + \ python functions as your solution." diff --git a/examples/arc_benchmark/evaluator.py b/examples/arc_benchmark/evaluator.py new file mode 100644 index 000000000..74c5f7922 --- /dev/null +++ b/examples/arc_benchmark/evaluator.py @@ -0,0 +1,220 @@ +import numpy as np +from typing import List, Tuple, Dict, Any +import json +import os + +from openevolve.evaluation_result import EvaluationResult +import importlib.util + +TASK_FILE = os.getenv("ARC_TASK_FILE", "training") +TASK_NUM = os.getenv("TASK_NUM", 0) +DATA_ROOT = os.getenv("DATA_ROOT", "/workspaces/ARC-Evolve/data/arc-prize-2025") + + +def pass_at_2_accuracy_single( + attempts: List[np.ndarray], + gt: np.ndarray +) -> Tuple[int, Dict[int, Any]]: + """ + Compute pass@2 accuracy for a single ARC test case. + + Args: + attempts: List of 2 numpy arrays representing model attempts. + gt: Ground-truth output as a 2D numpy array. + + Returns: + pass_at_2: int (1 if any attempt is perfectly correct, else 0) + diagnostics: dict mapping attempt index -> diagnostic info. + If sizes match, includes indices of incorrect cells. + """ + assert len(attempts) == 2, "Expected exactly 2 attempts for pass@2 evaluation." + + diagnostics = {} + passed = False + + for i, pred in enumerate(attempts): + attempt_info = {} + + # Size check + if pred.shape != gt.shape: + attempt_info["size_match"] = False + attempt_info["pred_shape"] = pred.shape + attempt_info["gt_shape"] = gt.shape + attempt_info["incorrect_indices"] = None + attempt_passed = False + else: + attempt_info["size_match"] = True + + # Find incorrect cells + incorrect_mask = pred != gt + incorrect_indices = np.argwhere(incorrect_mask) + + attempt_info["incorrect_indices"] = incorrect_indices.tolist() + attempt_info["num_incorrect"] = int(incorrect_mask.sum()) + + # Perfect match + if incorrect_mask.sum() == 0: + attempt_passed = True + else: + attempt_passed = False + + attempt_info["perfect_match"] = attempt_passed + passed = attempt_passed or passed + + diagnostics[i] = attempt_info + + pass_at_2 = 1 if passed else 0 + + return pass_at_2, diagnostics + +def pass_at_2_accuracy_multi_test( + all_attempts: List[List[np.ndarray]], + all_gt: List[np.ndarray] +) -> Tuple[List[int], List[Dict[int, Any]]]: + """ + Compute pass@2 accuracy across multiple ARC test cases. + + Args: + all_attempts: List of lists of 2 numpy arrays for each test case. + all_gt: List of ground-truth outputs as 2D numpy arrays. + """ + assert len(all_attempts) == len(all_gt), "Mismatched number of test cases." + + all_diagnostics = [] + all_pass = [] + + for attempts, gt in zip(all_attempts, all_gt): + pass_at_2, diagnostics = pass_at_2_accuracy_single(attempts, gt) + all_pass.append(pass_at_2) + all_diagnostics.append(diagnostics) + + return all_pass, all_diagnostics + +def extract_failure_artifacts(diagnostics): + """ + Extract failure artifacts from diagnostics for a given example. + + Args: + diagnostics: Diagnostics dictionary from pass_at_2_accuracy_single. + ex_name: Name of the example (for artifact labeling). + """ + artifacts = {} + if not diagnostics["size_match"]: + artifacts["error_type"] = "SizeMismatch" + artifacts["error_message"] = f"Size mismatch found in attempt output." + artifacts["suggestion"] = "Review your output size determination." + else: + artifacts["error_type"] = "IncorrectCells" + artifacts["error_message"] = f"{diagnostics['num_incorrect']} incorrect cells found at indices {diagnostics['incorrect_indices']}." + artifacts["suggestion"] = "Review your logic to ensure correct cell values." + + return artifacts + +def evaluate(program_path): + """ + Evaluate the program by running it multiple times and checking how close + it gets to the known global minimum. + + Args: + program_path: Path to the program file + + Returns: + Dictionary of metrics + """ + spec = importlib.util.spec_from_file_location("program_module", program_path) + program_module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(program_module) + + if not hasattr(program_module, 'transform_grid_attempt_1') or not hasattr(program_module, 'transform_grid_attempt_2'): + print(f"Stage 1 validation failed: Program must define 'transform_grid_attempt_1' and 'transform_grid_attempt_2' functions.") + + error_artifacts = { + "error_type": "MissingFunction", + "error_message": "Stage 1: Program is missing required 'transform_grid_attempt_1' and 'transform_grid_attempt_2' functions.", + "suggestion": "Make sure your program includes a functions named 'transform_grid_attempt_1' and 'transform_grid_attempt_2' that take as an argument a 2D numpy array and return a 2D numpy array." + } + + return EvaluationResult( + metrics={ + "runs_successfully": 0.0, + "combined_score": 0.0, + "error": "Missing transform_grid_attempt_1 and transform_grid_attempt_2 functions" + }, + artifacts=error_artifacts + ) + + # Load ARC tasks + challenge_path = os.path.join(DATA_ROOT, f"arc-agi_{TASK_FILE}_challenges.json") + + with open(challenge_path, 'r') as f: + tasks = json.load(f) + + task_id = list(tasks.keys())[int(TASK_NUM)] + task = tasks[task_id] + + train_inputs = [np.array(inp["input"]) for inp in task['train']] + train_gts = [np.array(gt["output"]) for gt in task['train']] + + train_attempts = [] + + # Generate attempts for training data + for inp in train_inputs: + attempt_1 = program_module.transform_grid_attempt_1(inp) + if not isinstance(attempt_1, np.ndarray): + print(f"transform_grid_attempt_1 did not return a numpy array") + + error_artifacts = { + "error_type": "InvalidReturnType", + "error_message": "Stage 1: transform_grid_attempt_1 did not return a numpy array.", + "suggestion": "Make sure your transform_grid_attempt_1 function returns a 2D numpy array." + } + + return EvaluationResult( + metrics={ + "runs_successfully": 0.0, + "combined_score": 0.0, + "error": "transform_grid_attempt_1 did not return a numpy array" + }, + artifacts=error_artifacts + ) + + attempt_2 = program_module.transform_grid_attempt_2(inp) + if not isinstance(attempt_2, np.ndarray): + print(f"transform_grid_attempt_2 did not return a numpy array") + + error_artifacts = { + "error_type": "InvalidReturnType", + "error_message": "Stage 1: transform_grid_attempt_2 did not return a numpy array.", + "suggestion": "Make sure your transform_grid_attempt_2 function returns a 2D numpy array." + } + + return EvaluationResult( + metrics={ + "runs_successfully": 0.0, + "combined_score": 0.0, + "error": "transform_grid_attempt_2 did not return a numpy array" + }, + artifacts=error_artifacts + ) + train_attempts.append([attempt_1, attempt_2]) + + pass_at_2_train, train_diagnostics_list = pass_at_2_accuracy_multi_test(train_attempts, train_gts) + + metrics = { + "runs_successfully": 1.0, + "combined_score": sum(pass_at_2_train) / len(pass_at_2_train), + } + error_artifacts = {} + for i, (train_pass, train_diagnostics) in enumerate(zip(pass_at_2_train, train_diagnostics_list)): + example_name = f"train_example_{i}" + metrics[f"{example_name}_pass_at_2"] = train_pass + for attempt in train_diagnostics: + attempt_pass = train_diagnostics[attempt]["perfect_match"] + metrics[f"{example_name}_attempt_{attempt}"] = attempt_pass + if not attempt_pass: + error_artifacts[f"{example_name}_attempt_{attempt}_diagnostics"] = extract_failure_artifacts(train_diagnostics[attempt]) + + return EvaluationResult( + metrics=metrics, + artifacts=error_artifacts + ) \ No newline at end of file diff --git a/examples/arc_benchmark/generate_config.py b/examples/arc_benchmark/generate_config.py new file mode 100644 index 000000000..737c22ffc --- /dev/null +++ b/examples/arc_benchmark/generate_config.py @@ -0,0 +1,62 @@ +import os +import yaml +import json + + +def load_task_as_prompt(task_json, task_num): + with open(task_json, 'r') as f: + tasks = json.load(f) + + task_id = list(tasks.keys())[int(task_num)] + task = tasks[task_id] + train_inputs = [inp["input"] for inp in task['train']] + train_outputs = [gt["output"] for gt in task['train']] + test_inputs = [inp["input"] for inp in task['test']] + + train_pairs = "" + for i, (inp, out) in enumerate(zip(train_inputs, train_outputs)): + train_pairs += f"In {i} - {inp}\nOut {i} - {out}\n" + + test_input = "" + for i, inp in enumerate(test_inputs): + test_input += f"In Test {i} - {inp}\n" + + prompt = f"""You are participating in a puzzle solving competition. You are an expert at solving puzzles. +Find the common pattern that transforms each input grid into its corresponding output grid... + +Your task is to write a python function that transforms each input grid into its corresponding output grid. This function must: +- Apply consistently to ALL training examples +- Be general enough to work on new test cases +- Be intuitive and easy to understand +- Apply the pattern without referencing specific example numbers + +You are provided the following training example grids: +{train_pairs} + +You are also provided the test input that you have to succesfully transform into the output using your python code: +{test_input} + +Looking carefully at the train input-output pairs, understand the transformation and modify PYTHON functions to generate 2 attempts to solve the task. These python functions will sequentially take each input grid as a numpy array and output the transformed grid as a numpy array. Your solution will then be evaluated against the ground truth output grid. +Remember to only output the modified python functions as your solution.""" + + return prompt + +def generate_config(task_num, task_file, dataset_root="/workspaces/ARC-Evolve/data/arc-prize-2025"): + task_json = os.path.join(dataset_root, f"arc-agi_{task_file}_challenges.json") + prompt = load_task_as_prompt(task_json, task_num) + + cfg_file = "./base_config.yaml" + with open(cfg_file, 'r') as file: + config = yaml.safe_load(file) + + config['prompt']['system_message'] = prompt + + with open('./config.yaml', 'w') as file: + yaml.dump(config, file) + +if __name__ == "__main__": + TASK_FILE = os.getenv("ARC_TASK_FILE", "training") + TASK_NUM = os.getenv("TASK_NUM", 0) + + generate_config(TASK_NUM, TASK_FILE) + \ No newline at end of file diff --git a/examples/arc_benchmark/images/Evolved task.png b/examples/arc_benchmark/images/Evolved task.png new file mode 100644 index 000000000..cf46e9293 Binary files /dev/null and b/examples/arc_benchmark/images/Evolved task.png differ diff --git a/examples/arc_benchmark/images/example.png b/examples/arc_benchmark/images/example.png new file mode 100644 index 000000000..c2ef48c3c Binary files /dev/null and b/examples/arc_benchmark/images/example.png differ diff --git a/examples/arc_benchmark/initial_program.py b/examples/arc_benchmark/initial_program.py new file mode 100644 index 000000000..39f75f7c2 --- /dev/null +++ b/examples/arc_benchmark/initial_program.py @@ -0,0 +1,42 @@ +# EVOLVE-BLOCK-START + +import numpy as np + +def transform_grid_attempt_1(grid): + """ + Example transformation: + - Validate input (2D, integer values 0-9). + - Rotate the grid 90 degrees clockwise. + - Increment every cell by 1 modulo 10 (keeps values 0-9). + Returns a new numpy int array. + """ + arr = _validate_grid(grid) + out = np.rot90(arr, k=-1) # 90 degrees clockwise + out = (out + 1) % 10 + return out.astype(np.int32) + +def transform_grid_attempt_2(grid): + """ + Example transformation: + - Validate input (2D, integer values 0-9). + - Upsample each cell to a 2x2 block (doubling both dimensions). + - Invert colors by mapping v -> 9 - v (keeps values 0-9). + Returns a new numpy int array. + """ + arr = _validate_grid(grid) + out = np.repeat(np.repeat(arr, 2, axis=0), 2, axis=1) + out = 9 - out + return out.astype(np.int32) + +# EVOLVE-BLOCK-END + +def _validate_grid(grid): + arr = np.asarray(grid) + if arr.ndim != 2: + raise ValueError("Input must be a 2D array.") + # cast to integer type for value checks + if not np.issubdtype(arr.dtype, np.integer): + arr = arr.astype(int) + if arr.size and (arr.min() < 0 or arr.max() > 9): + raise ValueError("Array values must be integers in the range 0-9.") + return arr \ No newline at end of file diff --git a/examples/arc_benchmark/outputs/evaluation_task_0/best/best_program.py b/examples/arc_benchmark/outputs/evaluation_task_0/best/best_program.py new file mode 100644 index 000000000..f6c6b8efd --- /dev/null +++ b/examples/arc_benchmark/outputs/evaluation_task_0/best/best_program.py @@ -0,0 +1,107 @@ +# EVOLVE-BLOCK-START + +import numpy as np + +def transform_grid_attempt_1(grid): + """ + Transformation logic: + 1. Identify the bounding box of the '8' values (mask) in the grid. + 2. The output grid has the same dimensions as this bounding box. + 3. For each cell (r, c) in the bounding box: + a. Calculate the vertically symmetric row: target_r = (Height + 1) - r. + If target_r is valid and grid[target_r, c] is not 8, use it. + b. Otherwise, use the diagonally transposed position: grid[c, r]. + """ + arr = _validate_grid(grid) + rows, cols = np.where(arr == 8) + + if len(rows) == 0: + return arr + + min_r, max_r = np.min(rows), np.max(rows) + min_c, max_c = np.min(cols), np.max(cols) + + height = max_r - min_r + 1 + width = max_c - min_c + 1 + + out = np.zeros((height, width), dtype=np.int32) + + N = arr.shape[0] + # Reflection constant determined to be N + 1 (31 for 30x30) + reflection_constant = N + 1 + + for r in range(min_r, max_r + 1): + for c in range(min_c, max_c + 1): + target_r = reflection_constant - r + + val = 8 + if 0 <= target_r < N: + val = arr[target_r, c] + + if val == 8: + # Fallback to diagonal transpose + # Ensure indices are within bounds (though for square grids they should be) + if 0 <= c < N and 0 <= r < arr.shape[1]: + val = arr[c, r] + + out[r - min_r, c - min_c] = val + + return out + +def transform_grid_attempt_2(grid): + """ + Similar to attempt 1 but with an additional fallback strategy. + Strategies: + 1. Vertical reflection: grid[31-r, c] + 2. Diagonal transpose: grid[c, r] + 3. Horizontal reflection: grid[r, 31-c] + """ + arr = _validate_grid(grid) + rows, cols = np.where(arr == 8) + + if len(rows) == 0: + return arr + + min_r, max_r = np.min(rows), np.max(rows) + min_c, max_c = np.min(cols), np.max(cols) + + out = np.zeros((max_r - min_r + 1, max_c - min_c + 1), dtype=np.int32) + N = arr.shape[0] + M = arr.shape[1] + + for r in range(min_r, max_r + 1): + for c in range(min_c, max_c + 1): + val = 8 + + # 1. Vertical reflection + tr = (N + 1) - r + if 0 <= tr < N: + val = arr[tr, c] + + # 2. Diagonal transpose + if val == 8: + if 0 <= c < N and 0 <= r < M: + val = arr[c, r] + + # 3. Horizontal reflection + if val == 8: + tc = (M + 1) - c + if 0 <= tc < M: + val = arr[r, tc] + + out[r - min_r, c - min_c] = val + + return out + +# EVOLVE-BLOCK-END + +def _validate_grid(grid): + arr = np.asarray(grid) + if arr.ndim != 2: + raise ValueError("Input must be a 2D array.") + # cast to integer type for value checks + if not np.issubdtype(arr.dtype, np.integer): + arr = arr.astype(int) + if arr.size and (arr.min() < 0 or arr.max() > 9): + raise ValueError("Array values must be integers in the range 0-9.") + return arr \ No newline at end of file diff --git a/examples/arc_benchmark/outputs/evaluation_task_0/best/best_program_info.json b/examples/arc_benchmark/outputs/evaluation_task_0/best/best_program_info.json new file mode 100644 index 000000000..0aec19c37 --- /dev/null +++ b/examples/arc_benchmark/outputs/evaluation_task_0/best/best_program_info.json @@ -0,0 +1,25 @@ +{ + "id": "ce48590c-4448-45b9-83f4-9e0a85424033", + "generation": 1, + "iteration": 2, + "timestamp": 1767790991.5850093, + "parent_id": "90c2a0c2-e3bd-4aa4-9bdc-1ab1b9326f97", + "metrics": { + "runs_successfully": 1.0, + "combined_score": 1.0, + "train_example_0_pass_at_2": 1, + "train_example_0_attempt_0": true, + "train_example_0_attempt_1": true, + "train_example_1_pass_at_2": 1, + "train_example_1_attempt_0": true, + "train_example_1_attempt_1": true, + "train_example_2_pass_at_2": 1, + "train_example_2_attempt_0": true, + "train_example_2_attempt_1": true, + "train_example_3_pass_at_2": 1, + "train_example_3_attempt_0": true, + "train_example_3_attempt_1": true + }, + "language": "python", + "saved_at": 1767791374.6249106 +} \ No newline at end of file diff --git a/examples/arc_benchmark/outputs/evaluation_task_0/best/post_evolution_evaluation_result.json b/examples/arc_benchmark/outputs/evaluation_task_0/best/post_evolution_evaluation_result.json new file mode 100644 index 000000000..fc30deac8 --- /dev/null +++ b/examples/arc_benchmark/outputs/evaluation_task_0/best/post_evolution_evaluation_result.json @@ -0,0 +1,10 @@ +{ + "metrics": { + "runs_successfully": 1.0, + "combined_score": 1.0, + "test_example_0_pass_at_2": 1, + "test_example_0_attempt_0": true, + "test_example_0_attempt_1": true + }, + "artifacts": {} +} \ No newline at end of file diff --git a/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/best_program.py b/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/best_program.py new file mode 100644 index 000000000..f6c6b8efd --- /dev/null +++ b/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/best_program.py @@ -0,0 +1,107 @@ +# EVOLVE-BLOCK-START + +import numpy as np + +def transform_grid_attempt_1(grid): + """ + Transformation logic: + 1. Identify the bounding box of the '8' values (mask) in the grid. + 2. The output grid has the same dimensions as this bounding box. + 3. For each cell (r, c) in the bounding box: + a. Calculate the vertically symmetric row: target_r = (Height + 1) - r. + If target_r is valid and grid[target_r, c] is not 8, use it. + b. Otherwise, use the diagonally transposed position: grid[c, r]. + """ + arr = _validate_grid(grid) + rows, cols = np.where(arr == 8) + + if len(rows) == 0: + return arr + + min_r, max_r = np.min(rows), np.max(rows) + min_c, max_c = np.min(cols), np.max(cols) + + height = max_r - min_r + 1 + width = max_c - min_c + 1 + + out = np.zeros((height, width), dtype=np.int32) + + N = arr.shape[0] + # Reflection constant determined to be N + 1 (31 for 30x30) + reflection_constant = N + 1 + + for r in range(min_r, max_r + 1): + for c in range(min_c, max_c + 1): + target_r = reflection_constant - r + + val = 8 + if 0 <= target_r < N: + val = arr[target_r, c] + + if val == 8: + # Fallback to diagonal transpose + # Ensure indices are within bounds (though for square grids they should be) + if 0 <= c < N and 0 <= r < arr.shape[1]: + val = arr[c, r] + + out[r - min_r, c - min_c] = val + + return out + +def transform_grid_attempt_2(grid): + """ + Similar to attempt 1 but with an additional fallback strategy. + Strategies: + 1. Vertical reflection: grid[31-r, c] + 2. Diagonal transpose: grid[c, r] + 3. Horizontal reflection: grid[r, 31-c] + """ + arr = _validate_grid(grid) + rows, cols = np.where(arr == 8) + + if len(rows) == 0: + return arr + + min_r, max_r = np.min(rows), np.max(rows) + min_c, max_c = np.min(cols), np.max(cols) + + out = np.zeros((max_r - min_r + 1, max_c - min_c + 1), dtype=np.int32) + N = arr.shape[0] + M = arr.shape[1] + + for r in range(min_r, max_r + 1): + for c in range(min_c, max_c + 1): + val = 8 + + # 1. Vertical reflection + tr = (N + 1) - r + if 0 <= tr < N: + val = arr[tr, c] + + # 2. Diagonal transpose + if val == 8: + if 0 <= c < N and 0 <= r < M: + val = arr[c, r] + + # 3. Horizontal reflection + if val == 8: + tc = (M + 1) - c + if 0 <= tc < M: + val = arr[r, tc] + + out[r - min_r, c - min_c] = val + + return out + +# EVOLVE-BLOCK-END + +def _validate_grid(grid): + arr = np.asarray(grid) + if arr.ndim != 2: + raise ValueError("Input must be a 2D array.") + # cast to integer type for value checks + if not np.issubdtype(arr.dtype, np.integer): + arr = arr.astype(int) + if arr.size and (arr.min() < 0 or arr.max() > 9): + raise ValueError("Array values must be integers in the range 0-9.") + return arr \ No newline at end of file diff --git a/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/best_program_info.json b/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/best_program_info.json new file mode 100644 index 000000000..c71ebcdbf --- /dev/null +++ b/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/best_program_info.json @@ -0,0 +1,25 @@ +{ + "id": "ce48590c-4448-45b9-83f4-9e0a85424033", + "generation": 1, + "iteration": 2, + "current_iteration": 100, + "metrics": { + "runs_successfully": 1.0, + "combined_score": 1.0, + "train_example_0_pass_at_2": 1, + "train_example_0_attempt_0": true, + "train_example_0_attempt_1": true, + "train_example_1_pass_at_2": 1, + "train_example_1_attempt_0": true, + "train_example_1_attempt_1": true, + "train_example_2_pass_at_2": 1, + "train_example_2_attempt_0": true, + "train_example_2_attempt_1": true, + "train_example_3_pass_at_2": 1, + "train_example_3_attempt_0": true, + "train_example_3_attempt_1": true + }, + "language": "python", + "timestamp": 1767790991.5850093, + "saved_at": 1767790991.5910103 +} \ No newline at end of file diff --git a/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/metadata.json b/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/metadata.json new file mode 100644 index 000000000..16c76d04a --- /dev/null +++ b/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/metadata.json @@ -0,0 +1 @@ +{"island_feature_maps": [{"5-0": "90c2a0c2-e3bd-4aa4-9bdc-1ab1b9326f97", "9-5": "ce48590c-4448-45b9-83f4-9e0a85424033"}, {}, {}], "islands": [["90c2a0c2-e3bd-4aa4-9bdc-1ab1b9326f97", "ce48590c-4448-45b9-83f4-9e0a85424033"], [], []], "archive": ["90c2a0c2-e3bd-4aa4-9bdc-1ab1b9326f97", "ce48590c-4448-45b9-83f4-9e0a85424033"], "best_program_id": "ce48590c-4448-45b9-83f4-9e0a85424033", "island_best_programs": ["ce48590c-4448-45b9-83f4-9e0a85424033", null, null], "last_iteration": 100, "current_island": 0, "island_generations": [1, 0, 0], "last_migration_generation": 0, "feature_stats": {"complexity": {"min": 1301.0, "max": 3274.0, "values": [1301.0, 3274.0]}, "diversity": {"min": 852.3, "max": 852.3, "values": [852.3]}}} \ No newline at end of file diff --git a/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/programs/90c2a0c2-e3bd-4aa4-9bdc-1ab1b9326f97.json b/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/programs/90c2a0c2-e3bd-4aa4-9bdc-1ab1b9326f97.json new file mode 100644 index 000000000..b029819a0 --- /dev/null +++ b/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/programs/90c2a0c2-e3bd-4aa4-9bdc-1ab1b9326f97.json @@ -0,0 +1 @@ +{"id": "90c2a0c2-e3bd-4aa4-9bdc-1ab1b9326f97", "code": "# EVOLVE-BLOCK-START\n\nimport numpy as np\n\ndef transform_grid_attempt_1(grid):\n \"\"\"\n Example transformation:\n - Validate input (2D, integer values 0-9).\n - Rotate the grid 90 degrees clockwise.\n - Increment every cell by 1 modulo 10 (keeps values 0-9).\n Returns a new numpy int array.\n \"\"\"\n arr = _validate_grid(grid)\n out = np.rot90(arr, k=-1) # 90 degrees clockwise\n out = (out + 1) % 10\n return out.astype(np.int32)\n\ndef transform_grid_attempt_2(grid):\n \"\"\"\n Example transformation:\n - Validate input (2D, integer values 0-9).\n - Upsample each cell to a 2x2 block (doubling both dimensions).\n - Invert colors by mapping v -> 9 - v (keeps values 0-9).\n Returns a new numpy int array.\n \"\"\"\n arr = _validate_grid(grid)\n out = np.repeat(np.repeat(arr, 2, axis=0), 2, axis=1)\n out = 9 - out\n return out.astype(np.int32)\n\n# EVOLVE-BLOCK-END\n\ndef _validate_grid(grid):\n arr = np.asarray(grid)\n if arr.ndim != 2:\n raise ValueError(\"Input must be a 2D array.\")\n # cast to integer type for value checks\n if not np.issubdtype(arr.dtype, np.integer):\n arr = arr.astype(int)\n if arr.size and (arr.min() < 0 or arr.max() > 9):\n raise ValueError(\"Array values must be integers in the range 0-9.\")\n return arr", "language": "python", "parent_id": null, "generation": 0, "timestamp": 1767790721.002828, "iteration_found": 0, "metrics": {"runs_successfully": 1.0, "combined_score": 0.0, "train_example_0_pass_at_2": 0, "train_example_0_attempt_0": false, "train_example_0_attempt_1": false, "train_example_1_pass_at_2": 0, "train_example_1_attempt_0": false, "train_example_1_attempt_1": false, "train_example_2_pass_at_2": 0, "train_example_2_attempt_0": false, "train_example_2_attempt_1": false, "train_example_3_pass_at_2": 0, "train_example_3_attempt_0": false, "train_example_3_attempt_1": false}, "complexity": 0.0, "diversity": 0.0, "metadata": {"island": 0}, "prompts": null, "artifacts_json": null, "artifact_dir": null, "embedding": null} \ No newline at end of file diff --git a/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/programs/ce48590c-4448-45b9-83f4-9e0a85424033.json b/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/programs/ce48590c-4448-45b9-83f4-9e0a85424033.json new file mode 100644 index 000000000..726dd9e08 --- /dev/null +++ b/examples/arc_benchmark/outputs/evaluation_task_0/checkpoints/checkpoint_100/programs/ce48590c-4448-45b9-83f4-9e0a85424033.json @@ -0,0 +1 @@ +{"id": "ce48590c-4448-45b9-83f4-9e0a85424033", "code": "# EVOLVE-BLOCK-START\n\nimport numpy as np\n\ndef transform_grid_attempt_1(grid):\n \"\"\"\n Transformation logic:\n 1. Identify the bounding box of the '8' values (mask) in the grid.\n 2. The output grid has the same dimensions as this bounding box.\n 3. For each cell (r, c) in the bounding box:\n a. Calculate the vertically symmetric row: target_r = (Height + 1) - r.\n If target_r is valid and grid[target_r, c] is not 8, use it.\n b. Otherwise, use the diagonally transposed position: grid[c, r].\n \"\"\"\n arr = _validate_grid(grid)\n rows, cols = np.where(arr == 8)\n \n if len(rows) == 0:\n return arr\n \n min_r, max_r = np.min(rows), np.max(rows)\n min_c, max_c = np.min(cols), np.max(cols)\n \n height = max_r - min_r + 1\n width = max_c - min_c + 1\n \n out = np.zeros((height, width), dtype=np.int32)\n \n N = arr.shape[0]\n # Reflection constant determined to be N + 1 (31 for 30x30)\n reflection_constant = N + 1\n \n for r in range(min_r, max_r + 1):\n for c in range(min_c, max_c + 1):\n target_r = reflection_constant - r\n \n val = 8\n if 0 <= target_r < N:\n val = arr[target_r, c]\n \n if val == 8:\n # Fallback to diagonal transpose\n # Ensure indices are within bounds (though for square grids they should be)\n if 0 <= c < N and 0 <= r < arr.shape[1]:\n val = arr[c, r]\n \n out[r - min_r, c - min_c] = val\n \n return out\n\ndef transform_grid_attempt_2(grid):\n \"\"\"\n Similar to attempt 1 but with an additional fallback strategy.\n Strategies:\n 1. Vertical reflection: grid[31-r, c]\n 2. Diagonal transpose: grid[c, r]\n 3. Horizontal reflection: grid[r, 31-c]\n \"\"\"\n arr = _validate_grid(grid)\n rows, cols = np.where(arr == 8)\n \n if len(rows) == 0:\n return arr\n \n min_r, max_r = np.min(rows), np.max(rows)\n min_c, max_c = np.min(cols), np.max(cols)\n \n out = np.zeros((max_r - min_r + 1, max_c - min_c + 1), dtype=np.int32)\n N = arr.shape[0]\n M = arr.shape[1]\n \n for r in range(min_r, max_r + 1):\n for c in range(min_c, max_c + 1):\n val = 8\n \n # 1. Vertical reflection\n tr = (N + 1) - r\n if 0 <= tr < N:\n val = arr[tr, c]\n \n # 2. Diagonal transpose\n if val == 8:\n if 0 <= c < N and 0 <= r < M:\n val = arr[c, r]\n \n # 3. Horizontal reflection\n if val == 8:\n tc = (M + 1) - c\n if 0 <= tc < M:\n val = arr[r, tc]\n \n out[r - min_r, c - min_c] = val\n \n return out\n\n# EVOLVE-BLOCK-END\n\ndef _validate_grid(grid):\n arr = np.asarray(grid)\n if arr.ndim != 2:\n raise ValueError(\"Input must be a 2D array.\")\n # cast to integer type for value checks\n if not np.issubdtype(arr.dtype, np.integer):\n arr = arr.astype(int)\n if arr.size and (arr.min() < 0 or arr.max() > 9):\n raise ValueError(\"Array values must be integers in the range 0-9.\")\n return arr", "language": "python", "parent_id": "90c2a0c2-e3bd-4aa4-9bdc-1ab1b9326f97", "generation": 1, "timestamp": 1767790991.5850093, "iteration_found": 2, "metrics": {"runs_successfully": 1.0, "combined_score": 1.0, "train_example_0_pass_at_2": 1, "train_example_0_attempt_0": true, "train_example_0_attempt_1": true, "train_example_1_pass_at_2": 1, "train_example_1_attempt_0": true, "train_example_1_attempt_1": true, "train_example_2_pass_at_2": 1, "train_example_2_attempt_0": true, "train_example_2_attempt_1": true, "train_example_3_pass_at_2": 1, "train_example_3_attempt_0": true, "train_example_3_attempt_1": true}, "complexity": 0.0, "diversity": 0.0, "metadata": {"changes": "Change 1: Replace 31 lines with 96 lines", "parent_metrics": {"runs_successfully": 1.0, "combined_score": 0.0, "train_example_0_pass_at_2": 0, "train_example_0_attempt_0": false, "train_example_0_attempt_1": false, "train_example_1_pass_at_2": 0, "train_example_1_attempt_0": false, "train_example_1_attempt_1": false, "train_example_2_pass_at_2": 0, "train_example_2_attempt_0": false, "train_example_2_attempt_1": false, "train_example_3_pass_at_2": 0, "train_example_3_attempt_0": false, "train_example_3_attempt_1": false}, "island": 0}, "prompts": {"diff_user": {"system": "You are participating in a puzzle solving competition. You are an expert at solving puzzles.\nFind the common pattern that transforms each input grid into its corresponding output grid...\n\nYour task is to write a python function that transforms each input grid into its corresponding output grid. This function must:\n- Apply consistently to ALL training examples\n- Be general enough to work on new test cases \n- Be intuitive and easy to understand\n- Apply the pattern without referencing specific example numbers\n\nYou are provided the following training example grids:\nIn 0 - [[3, 5, 3, 3, 6, 6, 5, 4, 1, 4, 9, 9, 4, 3, 9, 9, 9, 9, 3, 4, 9, 9, 4, 1, 4, 5, 6, 6, 3, 3], [5, 3, 3, 3, 6, 6, 4, 5, 4, 1, 9, 9, 3, 4, 9, 1, 1, 9, 4, 3, 9, 9, 1, 4, 5, 4, 6, 6, 3, 3], [1, 1, 3, 5, 5, 4, 6, 6, 9, 1, 1, 4, 9, 9,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1, 4, 9, 9, 3, 9, 9, 1, 1, 1, 6, 1, 5, 2, 5, 5, 5, 5, 2, 5, 1, 6, 1, 1, 1, 9, 9, 3, 9, 9], [7, 6, 6, 6, 9, 6, 1, 3, 1, 3, 4, 1, 9, 6, 7, 6, 6, 7, 6, 9, 1, 4, 3, 1, 3, 1, 6, 9, 6, 6], [6, 7, 6, 6, 1, 9, 3, 1, 9, 1, 1, 4, 6, 9, 6, 7, 7, 6, 9, 6, 4, 1, 1, 9, 1, 3, 9, 1, 6, 6], [6, 6, 7, 6, 1, 3, 9, 1, 9, 3, 1, 3, 7, 6, 5, 2, 2, 5, 6, 7, 3, 1, 3, 9, 1, 9, 3, 1, 6, 7], [6, 6, 6, 7, 3, 1, 5, 9, 3, 4, 9, 1, 6, 7, 2, 5, 5, 2, 7, 6, 1, 9, 4, 3, 9, 5, 1, 3, 7, 6], [9, 1, 1, 3, 1, 7, 6, 5, 9, 9, 4, 1, 1, 3, 4, 1, 1, 4, 3, 1, 1, 4, 9, 9, 5, 6, 7, 1, 3, 1], [6, 9, 3, 1, 7, 1, 5, 6, 9, 9, 1, 4, 9, 1, 1, 4, 4, 1, 1, 9, 4, 1, 9, 9, 6, 5, 1, 7, 1, 3]]\nOut 3 - [[6, 9, 6, 6], [9, 3, 9, 9], [3, 4, 9, 9], [1, 9, 4, 1]]\n\n\nYou are also provided the test input that you have to succesfully transform into the output using your python code:\nIn Test 0 - [[4, 4, 1, 3, 5, 7, 7, 9, 6, 1, 6, 6, 4, 4, 7, 7, 7, 7, 4, 4, 6, 6, 1, 6, 9, 7, 7, 5, 3, 1], [4, 4, 3, 3, 7, 5, 9, 7, 6, 6, 6, 6, 4, 4, 7, 2, 2, 7, 4, 4, 6, 6, 6, 6, 7, 9, 5, 7, 3, 3], [3, 4, 4, 4, 7, 9, 5, 7, 5, 1, 6, 1, 7, 7, 9, 9, 9, 9, 7, 7, 1, 6, 1, 5, 7, 5, 9, 7, 4, 4], [4, 3, 4, 4, 9, 7, 7, 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[7, 9, 4, 7, 4, 4, 3, 1, 4, 4, 7, 2, 7, 9, 2, 3, 3, 2, 9, 7, 2, 7, 4, 4, 1, 3, 4, 4, 7, 4], [9, 7, 7, 4, 4, 4, 3, 3, 4, 4, 7, 7, 9, 7, 3, 2, 2, 3, 7, 9, 7, 7, 4, 4, 3, 3, 4, 4, 4, 7], [4, 3, 4, 4, 9, 7, 7, 5, 1, 5, 6, 6, 7, 2, 1, 9, 9, 1, 2, 7, 6, 6, 5, 1, 5, 7, 7, 9, 4, 4], [3, 4, 4, 4, 7, 9, 5, 7, 5, 1, 6, 1, 7, 7, 9, 9, 9, 9, 7, 7, 1, 6, 1, 5, 7, 5, 9, 7, 4, 4]]\n\n\nLooking carefully at the train input-output pairs, understand the transformation and modify PYTHON functions to generate 2 attempts to solve the task. These python functions will sequentially take each input grid as a numpy array and output the transformed grid as a numpy array. Your solution will then be evaluated against the ground truth output grid.\nRemember to only output the modified python functions as your solution.", "user": "# Current Program Information\n- Fitness: 0.0000\n- Feature coordinates: \n- Focus areas: - Fitness unchanged at 0.0000\n- No feature coordinates\n- Consider simplifying - code length exceeds 500 characters\n\n\n\n# Program Evolution History\n## Previous Attempts\n\n### Attempt 1\n- Changes: Unknown changes\n- Metrics: runs_successfully: 1.0000, combined_score: 0.0000, train_example_0_pass_at_2: 0.0000, train_example_0_attempt_0: 0.0000, train_example_0_attempt_1: 0.0000, train_example_1_pass_at_2: 0.0000, train_example_1_attempt_0: 0.0000, train_example_1_attempt_1: 0.0000, train_example_2_pass_at_2: 0.0000, train_example_2_attempt_0: 0.0000, train_example_2_attempt_1: 0.0000, train_example_3_pass_at_2: 0.0000, train_example_3_attempt_0: 0.0000, train_example_3_attempt_1: 0.0000\n- Outcome: Mixed results\n\n## Top Performing Programs\n\n### Program 1 (Score: 0.0000)\n```python\n# EVOLVE-BLOCK-START\n\nimport numpy as np\n\ndef transform_grid_attempt_1(grid):\n \"\"\"\n Example transformation:\n - Validate input (2D, integer values 0-9).\n - Rotate the grid 90 degrees clockwise.\n - Increment every cell by 1 modulo 10 (keeps values 0-9).\n Returns a new numpy int array.\n \"\"\"\n arr = _validate_grid(grid)\n out = np.rot90(arr, k=-1) # 90 degrees clockwise\n out = (out + 1) % 10\n return out.astype(np.int32)\n\ndef transform_grid_attempt_2(grid):\n \"\"\"\n Example transformation:\n - Validate input (2D, integer values 0-9).\n - Upsample each cell to a 2x2 block (doubling both dimensions).\n - Invert colors by mapping v -> 9 - v (keeps values 0-9).\n Returns a new numpy int array.\n \"\"\"\n arr = _validate_grid(grid)\n out = np.repeat(np.repeat(arr, 2, axis=0), 2, axis=1)\n out = 9 - out\n return out.astype(np.int32)\n\n# EVOLVE-BLOCK-END\n\ndef _validate_grid(grid):\n arr = np.asarray(grid)\n if arr.ndim != 2:\n raise ValueError(\"Input must be a 2D array.\")\n # cast to integer type for value checks\n if not np.issubdtype(arr.dtype, np.integer):\n arr = arr.astype(int)\n if arr.size and (arr.min() < 0 or arr.max() > 9):\n raise ValueError(\"Array values must be integers in the range 0-9.\")\n return arr\n```\nKey features: Performs well on runs_successfully (1.0000), Performs well on combined_score (0.0000), Performs well on train_example_0_pass_at_2 (0.0000), Performs well on train_example_0_attempt_0 (0.0000), Performs well on train_example_0_attempt_1 (0.0000), Performs well on train_example_1_pass_at_2 (0.0000), Performs well on train_example_1_attempt_0 (0.0000), Performs well on train_example_1_attempt_1 (0.0000), Performs well on train_example_2_pass_at_2 (0.0000), Performs well on train_example_2_attempt_0 (0.0000), Performs well on train_example_2_attempt_1 (0.0000), Performs well on train_example_3_pass_at_2 (0.0000), Performs well on train_example_3_attempt_0 (0.0000), Performs well on train_example_3_attempt_1 (0.0000)\n\n\n\n# Current Program\n```python\n# EVOLVE-BLOCK-START\n\nimport numpy as np\n\ndef transform_grid_attempt_1(grid):\n \"\"\"\n Example transformation:\n - Validate input (2D, integer values 0-9).\n - Rotate the grid 90 degrees clockwise.\n - Increment every cell by 1 modulo 10 (keeps values 0-9).\n Returns a new numpy int array.\n \"\"\"\n arr = _validate_grid(grid)\n out = np.rot90(arr, k=-1) # 90 degrees clockwise\n out = (out + 1) % 10\n return out.astype(np.int32)\n\ndef transform_grid_attempt_2(grid):\n \"\"\"\n Example transformation:\n - Validate input (2D, integer values 0-9).\n - Upsample each cell to a 2x2 block (doubling both dimensions).\n - Invert colors by mapping v -> 9 - v (keeps values 0-9).\n Returns a new numpy int array.\n \"\"\"\n arr = _validate_grid(grid)\n out = np.repeat(np.repeat(arr, 2, axis=0), 2, axis=1)\n out = 9 - out\n return out.astype(np.int32)\n\n# EVOLVE-BLOCK-END\n\ndef _validate_grid(grid):\n arr = np.asarray(grid)\n if arr.ndim != 2:\n raise ValueError(\"Input must be a 2D array.\")\n # cast to integer type for value checks\n if not np.issubdtype(arr.dtype, np.integer):\n arr = arr.astype(int)\n if arr.size and (arr.min() < 0 or arr.max() > 9):\n raise ValueError(\"Array values must be integers in the range 0-9.\")\n return arr\n```\n\n# Task\nSuggest improvements to the program that will improve its FITNESS SCORE.\nThe system maintains diversity across these dimensions: complexity, diversity\nDifferent solutions with similar fitness but different features are valuable.\n\nYou MUST use the exact SEARCH/REPLACE diff format shown below to indicate changes:\n\n<<<<<<< SEARCH\n# Original code to find and replace (must match exactly)\n=======\n# New replacement code\n>>>>>>> REPLACE\n\nExample of valid diff format:\n<<<<<<< SEARCH\nfor i in range(m):\n for j in range(p):\n for k in range(n):\n C[i, j] += A[i, k] * B[k, j]\n=======\n# Reorder loops for better memory access pattern\nfor i in range(m):\n for k in range(n):\n for j in range(p):\n C[i, j] += A[i, k] * B[k, j]\n>>>>>>> REPLACE\n\nYou can suggest multiple changes. Each SEARCH section must exactly match code in the current program.\nBe thoughtful about your changes and explain your reasoning thoroughly.\n\nIMPORTANT: Do not rewrite the entire program - focus on targeted improvements.", "responses": ["<<<<<<< SEARCH\n# EVOLVE-BLOCK-START\n\nimport numpy as np\n\ndef transform_grid_attempt_1(grid):\n \"\"\"\n Example transformation:\n - Validate input (2D, integer values 0-9).\n - Rotate the grid 90 degrees clockwise.\n - Increment every cell by 1 modulo 10 (keeps values 0-9).\n Returns a new numpy int array.\n \"\"\"\n arr = _validate_grid(grid)\n out = np.rot90(arr, k=-1) # 90 degrees clockwise\n out = (out + 1) % 10\n return out.astype(np.int32)\n\ndef transform_grid_attempt_2(grid):\n \"\"\"\n Example transformation:\n - Validate input (2D, integer values 0-9).\n - Upsample each cell to a 2x2 block (doubling both dimensions).\n - Invert colors by mapping v -> 9 - v (keeps values 0-9).\n Returns a new numpy int array.\n \"\"\"\n arr = _validate_grid(grid)\n out = np.repeat(np.repeat(arr, 2, axis=0), 2, axis=1)\n out = 9 - out\n return out.astype(np.int32)\n\n# EVOLVE-BLOCK-END\n=======\n# EVOLVE-BLOCK-START\n\nimport numpy as np\n\ndef transform_grid_attempt_1(grid):\n \"\"\"\n Transformation logic:\n 1. Identify the bounding box of the '8' values (mask) in the grid.\n 2. The output grid has the same dimensions as this bounding box.\n 3. For each cell (r, c) in the bounding box:\n a. Calculate the vertically symmetric row: target_r = (Height + 1) - r.\n If target_r is valid and grid[target_r, c] is not 8, use it.\n b. Otherwise, use the diagonally transposed position: grid[c, r].\n \"\"\"\n arr = _validate_grid(grid)\n rows, cols = np.where(arr == 8)\n \n if len(rows) == 0:\n return arr\n \n min_r, max_r = np.min(rows), np.max(rows)\n min_c, max_c = np.min(cols), np.max(cols)\n \n height = max_r - min_r + 1\n width = max_c - min_c + 1\n \n out = np.zeros((height, width), dtype=np.int32)\n \n N = arr.shape[0]\n # Reflection constant determined to be N + 1 (31 for 30x30)\n reflection_constant = N + 1\n \n for r in range(min_r, max_r + 1):\n for c in range(min_c, max_c + 1):\n target_r = reflection_constant - r\n \n val = 8\n if 0 <= target_r < N:\n val = arr[target_r, c]\n \n if val == 8:\n # Fallback to diagonal transpose\n # Ensure indices are within bounds (though for square grids they should be)\n if 0 <= c < N and 0 <= r < arr.shape[1]:\n val = arr[c, r]\n \n out[r - min_r, c - min_c] = val\n \n return out\n\ndef transform_grid_attempt_2(grid):\n \"\"\"\n Similar to attempt 1 but with an additional fallback strategy.\n Strategies:\n 1. Vertical reflection: grid[31-r, c]\n 2. Diagonal transpose: grid[c, r]\n 3. Horizontal reflection: grid[r, 31-c]\n \"\"\"\n arr = _validate_grid(grid)\n rows, cols = np.where(arr == 8)\n \n if len(rows) == 0:\n return arr\n \n min_r, max_r = np.min(rows), np.max(rows)\n min_c, max_c = np.min(cols), np.max(cols)\n \n out = np.zeros((max_r - min_r + 1, max_c - min_c + 1), dtype=np.int32)\n N = arr.shape[0]\n M = arr.shape[1]\n \n for r in range(min_r, max_r + 1):\n for c in range(min_c, max_c + 1):\n val = 8\n \n # 1. Vertical reflection\n tr = (N + 1) - r\n if 0 <= tr < N:\n val = arr[tr, c]\n \n # 2. Diagonal transpose\n if val == 8:\n if 0 <= c < N and 0 <= r < M:\n val = arr[c, r]\n \n # 3. Horizontal reflection\n if val == 8:\n tc = (M + 1) - c\n if 0 <= tc < M:\n val = arr[r, tc]\n \n out[r - min_r, c - min_c] = val\n \n return out\n\n# EVOLVE-BLOCK-END\n>>>>>>> REPLACE"]}}, "artifacts_json": null, "artifact_dir": null, "embedding": null} \ No newline at end of file diff --git a/examples/arc_benchmark/post_evolution_eval.py b/examples/arc_benchmark/post_evolution_eval.py new file mode 100644 index 000000000..f75c1ac85 --- /dev/null +++ b/examples/arc_benchmark/post_evolution_eval.py @@ -0,0 +1,119 @@ +import importlib.util +import os +import json +import numpy as np +from evaluator import pass_at_2_accuracy_multi_test, extract_failure_artifacts + +TASK_FILE = os.getenv("ARC_TASK_FILE", "training") +TASK_NUM = os.getenv("TASK_NUM", 0) +OUTS_DIR = os.getenv("OUTS_DIR", "") + + +def load_program_module(): + """Dynamically load the best_program.py module from the specified directory.""" + spec = importlib.util.spec_from_file_location("program_module", os.path.join(OUTS_DIR, "best/best_program.py")) + program_module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(program_module) + + return program_module + +def evaluate(): + """Evaluate the program module located in the specified directory.""" + program_module = load_program_module() + if not hasattr(program_module, 'transform_grid_attempt_1') or not hasattr(program_module, 'transform_grid_attempt_2'): + print(f"Stage 1 validation failed: Program must define 'transform_grid_attempt_1' and 'transform_grid_attempt_2' functions.") + + error_artifacts = { + "error_type": "MissingFunction", + "error_message": "Stage 1: Program is missing required 'transform_grid_attempt_1' and 'transform_grid_attempt_2' functions.", + "suggestion": "Make sure your program includes a functions named 'transform_grid_attempt_1' and 'transform_grid_attempt_2' that take as an argument a 2D numpy array and return a 2D numpy array." + } + + return dict( + metrics={ + "runs_successfully": 0.0, + "combined_score": 0.0, + "error": "Missing transform_grid_attempt_1 and transform_grid_attempt_2 functions" + }, + artifacts=error_artifacts + ) + # Load ARC tasks + challenge_path = f"/workspaces/ARC-Evolve/data/arc-prize-2025/arc-agi_{TASK_FILE}_challenges.json" + solution_path = f"/workspaces/ARC-Evolve/data/arc-prize-2025/arc-agi_{TASK_FILE}_solutions.json" + + with open(challenge_path, 'r') as f: + tasks = json.load(f) + with open(solution_path, 'r') as f: + solutions = json.load(f) + + task_id = list(tasks.keys())[int(TASK_NUM)] + solution = solutions[task_id] + task = tasks[task_id] + + test_inputs = [np.array(inp["input"]) for inp in task['test']] + test_gts = [np.array(gt) for gt in solution] + + test_attempts = [] + for inp in test_inputs: + attempt_1 = program_module.transform_grid_attempt_1(inp) + if not isinstance(attempt_1, np.ndarray): + print(f"transform_grid_attempt_1 did not return a numpy array") + + error_artifacts = { + "error_type": "InvalidReturnType", + "error_message": "Stage 1: transform_grid_attempt_1 did not return a numpy array.", + "suggestion": "Make sure your transform_grid_attempt_1 function returns a 2D numpy array." + } + + return dict( + metrics={ + "runs_successfully": 0.0, + "combined_score": 0.0, + "error": "transform_grid_attempt_1 did not return a numpy array" + }, + artifacts=error_artifacts + ) + + attempt_2 = program_module.transform_grid_attempt_2(inp) + if not isinstance(attempt_2, np.ndarray): + print(f"transform_grid_attempt_2 did not return a numpy array") + + error_artifacts = { + "error_type": "InvalidReturnType", + "error_message": "Stage 1: transform_grid_attempt_2 did not return a numpy array.", + "suggestion": "Make sure your transform_grid_attempt_2 function returns a 2D numpy array." + } + + return dict( + metrics={ + "runs_successfully": 0.0, + "combined_score": 0.0, + "error": "transform_grid_attempt_2 did not return a numpy array" + }, + artifacts=error_artifacts + ) + test_attempts.append([attempt_1, attempt_2]) + + pass_at_2_test, test_diagnostics_list = pass_at_2_accuracy_multi_test(test_attempts, test_gts) + metrics = { + "runs_successfully": 1.0, + "combined_score": sum(pass_at_2_test) / len(pass_at_2_test), + } + error_artifacts = {} + for i, (test_pass, test_diagnostics) in enumerate(zip(pass_at_2_test, test_diagnostics_list)): + example_name = f"test_example_{i}" + metrics[f"{example_name}_pass_at_2"] = test_pass + for attempt in test_diagnostics: + metrics[f"{example_name}_attempt_{attempt}"] = test_diagnostics[attempt]["perfect_match"] + if test_pass == 0: + error_artifacts = extract_failure_artifacts(test_diagnostics) + + return dict( + metrics=metrics, + artifacts=error_artifacts + ) + +if __name__ == "__main__": + evaluation_result = evaluate() + with open(os.path.join(OUTS_DIR, "best", "post_evolution_evaluation_result.json"), 'w') as f: + json.dump(evaluation_result, f, indent=4) \ No newline at end of file diff --git a/examples/arc_benchmark/run_evolution.sh b/examples/arc_benchmark/run_evolution.sh new file mode 100755 index 000000000..9ad98c706 --- /dev/null +++ b/examples/arc_benchmark/run_evolution.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +TASK_ID=${1:-0} # Task number to solve (default: 0) +shift # Remove first argument +TASK_FILE="evaluation" # Options: training, evaluation, test (default: evaluation) + +export OPENAI_API_KEY="your-gemini-api-key" +export ARC_TASK_FILE=$TASK_FILE +export TASK_NUM=$TASK_ID +export DATA_ROOT="../../data/arc-prize-2025" + +OUTPUT_DIR="outputs/${TASK_FILE}_task_${TASK_ID}" +export OUTS_DIR=$OUTPUT_DIR + +python generate_config.py +python ../../openevolve-run.py initial_program.py evaluator.py --config config.yaml --output $OUTPUT_DIR "$@" +python post_evolution_eval.py diff --git a/openevolve/process_parallel.py b/openevolve/process_parallel.py index 59a4a6b68..58cf80e29 100644 --- a/openevolve/process_parallel.py +++ b/openevolve/process_parallel.py @@ -450,11 +450,17 @@ async def run_evolution( if early_stopping_enabled: best_score = float("-inf") iterations_without_improvement = 0 - logger.info( - f"Early stopping enabled: patience={self.config.early_stopping_patience}, " - f"threshold={self.config.convergence_threshold}, " - f"metric={self.config.early_stopping_metric}" - ) + if self.config.early_stopping_patience < 0: + logger.info( + f"Early stopping patience is set to a negative value, running event-based early-stopping, " + f"Early stop when metric '{self.config.early_stopping_metric}' reaches {self.config.convergence_threshold}" + ) + else: + logger.info( + f"Early stopping enabled: patience={self.config.early_stopping_patience}, " + f"threshold={self.config.convergence_threshold}, " + f"metric={self.config.early_stopping_metric}" + ) else: logger.info("Early stopping disabled") @@ -633,31 +639,43 @@ async def run_evolution( if current_score is not None and isinstance(current_score, (int, float)): # Check for improvement - improvement = current_score - best_score - if improvement >= self.config.convergence_threshold: - best_score = current_score - iterations_without_improvement = 0 - logger.debug( - f"New best score: {best_score:.4f} (improvement: {improvement:+.4f})" - ) + if self.config.early_stopping_patience > 0: + improvement = current_score - best_score + if improvement >= self.config.convergence_threshold: + best_score = current_score + iterations_without_improvement = 0 + logger.debug( + f"New best score: {best_score:.4f} (improvement: {improvement:+.4f})" + ) + else: + iterations_without_improvement += 1 + logger.debug( + f"No improvement: {iterations_without_improvement}/{self.config.early_stopping_patience}" + ) + + # Check if we should stop + if ( + iterations_without_improvement + >= self.config.early_stopping_patience + ): + self.early_stopping_triggered = True + logger.info( + f"🛑 Early stopping triggered at iteration {completed_iteration}: " + f"No improvement for {iterations_without_improvement} iterations " + f"(best score: {best_score:.4f})" + ) + break + else: - iterations_without_improvement += 1 - logger.debug( - f"No improvement: {iterations_without_improvement}/{self.config.early_stopping_patience}" - ) - - # Check if we should stop - if ( - iterations_without_improvement - >= self.config.early_stopping_patience - ): - self.early_stopping_triggered = True - logger.info( - f"🛑 Early stopping triggered at iteration {completed_iteration}: " - f"No improvement for {iterations_without_improvement} iterations " - f"(best score: {best_score:.4f})" - ) - break + # Event-based early stopping + if current_score == self.config.convergence_threshold: + best_score = current_score + logger.info( + f"🛑 Early stopping (event-based) triggered at iteration {completed_iteration}: " + f"Task successfully solved with score {best_score:.4f}." + ) + self.early_stopping_triggered = True + break except FutureTimeoutError: logger.error(