openevolve 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openevolve-0.0.1/LICENSE +201 -0
- openevolve-0.0.1/PKG-INFO +325 -0
- openevolve-0.0.1/README.md +304 -0
- openevolve-0.0.1/openevolve/__init__.py +9 -0
- openevolve-0.0.1/openevolve/cli.py +179 -0
- openevolve-0.0.1/openevolve/config.py +354 -0
- openevolve-0.0.1/openevolve/controller.py +568 -0
- openevolve-0.0.1/openevolve/database.py +1290 -0
- openevolve-0.0.1/openevolve/evaluation_result.py +54 -0
- openevolve-0.0.1/openevolve/evaluator.py +506 -0
- openevolve-0.0.1/openevolve/llm/__init__.py +9 -0
- openevolve-0.0.1/openevolve/llm/base.py +22 -0
- openevolve-0.0.1/openevolve/llm/ensemble.py +73 -0
- openevolve-0.0.1/openevolve/llm/openai.py +114 -0
- openevolve-0.0.1/openevolve/prompt/__init__.py +8 -0
- openevolve-0.0.1/openevolve/prompt/sampler.py +494 -0
- openevolve-0.0.1/openevolve/prompt/templates.py +176 -0
- openevolve-0.0.1/openevolve/utils/__init__.py +45 -0
- openevolve-0.0.1/openevolve/utils/async_utils.py +165 -0
- openevolve-0.0.1/openevolve/utils/code_utils.py +207 -0
- openevolve-0.0.1/openevolve/utils/format_utils.py +65 -0
- openevolve-0.0.1/openevolve/utils/metrics_utils.py +66 -0
- openevolve-0.0.1/openevolve.egg-info/PKG-INFO +325 -0
- openevolve-0.0.1/openevolve.egg-info/SOURCES.txt +37 -0
- openevolve-0.0.1/openevolve.egg-info/dependency_links.txt +1 -0
- openevolve-0.0.1/openevolve.egg-info/entry_points.txt +2 -0
- openevolve-0.0.1/openevolve.egg-info/requires.txt +11 -0
- openevolve-0.0.1/openevolve.egg-info/top_level.txt +1 -0
- openevolve-0.0.1/pyproject.toml +48 -0
- openevolve-0.0.1/setup.cfg +4 -0
- openevolve-0.0.1/setup.py +8 -0
- openevolve-0.0.1/tests/test_artifacts.py +325 -0
- openevolve-0.0.1/tests/test_artifacts_integration.py +317 -0
- openevolve-0.0.1/tests/test_checkpoint_resume.py +304 -0
- openevolve-0.0.1/tests/test_code_utils.py +93 -0
- openevolve-0.0.1/tests/test_database.py +85 -0
- openevolve-0.0.1/tests/test_llm_ensemble.py +38 -0
- openevolve-0.0.1/tests/test_prompt_sampler.py +53 -0
- openevolve-0.0.1/tests/test_valid_configs.py +40 -0
openevolve-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openevolve
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Open-source implementation of AlphaEvolve
|
|
5
|
+
Author: codelion
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: openai>=1.0.0
|
|
11
|
+
Requires-Dist: pyyaml>=6.0
|
|
12
|
+
Requires-Dist: numpy>=1.22.0
|
|
13
|
+
Requires-Dist: tqdm>=4.64.0
|
|
14
|
+
Requires-Dist: flask
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
17
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
18
|
+
Requires-Dist: isort>=5.10.0; extra == "dev"
|
|
19
|
+
Requires-Dist: mypy>=0.950; extra == "dev"
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# OpenEvolve
|
|
23
|
+
|
|
24
|
+
An open-source implementation of the AlphaEvolve system described in the Google DeepMind paper "AlphaEvolve: A coding agent for scientific and algorithmic discovery" (2025).
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
## Overview
|
|
29
|
+
|
|
30
|
+
OpenEvolve is an evolutionary coding agent that uses Large Language Models to optimize code through an iterative process. It orchestrates a pipeline of LLM-based code generation, evaluation, and selection to continuously improve programs for a variety of tasks.
|
|
31
|
+
|
|
32
|
+
Key features:
|
|
33
|
+
- Evolution of entire code files, not just single functions
|
|
34
|
+
- Support for multiple programming languages
|
|
35
|
+
- Supports OpenAI-compatible APIs for any LLM
|
|
36
|
+
- Multi-objective optimization
|
|
37
|
+
- Flexible prompt engineering
|
|
38
|
+
- Distributed evaluation
|
|
39
|
+
|
|
40
|
+
## How It Works
|
|
41
|
+
|
|
42
|
+
OpenEvolve follows an evolutionary approach with the following components:
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
1. **Prompt Sampler**: Creates context-rich prompts containing past programs, their scores, and problem descriptions
|
|
47
|
+
2. **LLM Ensemble**: Generates code modifications via an ensemble of language models
|
|
48
|
+
3. **Evaluator Pool**: Tests generated programs and assigns scores
|
|
49
|
+
4. **Program Database**: Stores programs and their evaluation metrics, guiding future evolution
|
|
50
|
+
|
|
51
|
+
The controller orchestrates interactions between these components in an asynchronous pipeline, maximizing throughput to evaluate as many candidate solutions as possible.
|
|
52
|
+
|
|
53
|
+
## Getting Started
|
|
54
|
+
|
|
55
|
+
### Installation
|
|
56
|
+
|
|
57
|
+
To install natively, use:
|
|
58
|
+
```bash
|
|
59
|
+
git clone https://github.com/codelion/openevolve.git
|
|
60
|
+
cd openevolve
|
|
61
|
+
pip install -e .
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Quick Start
|
|
65
|
+
|
|
66
|
+
We use the OpenAI SDK, so you can use any LLM or provider that supports an OpenAI compatible API. Just set the `OPENAI_API_KEY` environment variable
|
|
67
|
+
and update the `api_base` in config.yaml if you are using a provider other than OpenAI. For local models, you can use
|
|
68
|
+
an inference server like [optillm](https://github.com/codelion/optillm).
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from openevolve import OpenEvolve
|
|
72
|
+
|
|
73
|
+
# Initialize the system
|
|
74
|
+
evolve = OpenEvolve(
|
|
75
|
+
initial_program_path="path/to/initial_program.py",
|
|
76
|
+
evaluation_file="path/to/evaluator.py",
|
|
77
|
+
config_path="path/to/config.yaml"
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# Run the evolution
|
|
81
|
+
best_program = await evolve.run(iterations=1000)
|
|
82
|
+
print(f"Best program metrics:")
|
|
83
|
+
for name, value in best_program.metrics.items():
|
|
84
|
+
print(f" {name}: {value:.4f}")
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Command-Line Usage
|
|
88
|
+
|
|
89
|
+
OpenEvolve can also be run from the command line:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
python openevolve-run.py path/to/initial_program.py path/to/evaluator.py --config path/to/config.yaml --iterations 1000
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Resuming from Checkpoints
|
|
96
|
+
|
|
97
|
+
OpenEvolve automatically saves checkpoints at intervals specified by the `checkpoint_interval` config parameter (default is 10 iterations). You can resume an evolution run from a saved checkpoint:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
python openevolve-run.py path/to/initial_program.py path/to/evaluator.py \
|
|
101
|
+
--config path/to/config.yaml \
|
|
102
|
+
--checkpoint path/to/checkpoint_directory \
|
|
103
|
+
--iterations 50
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
When resuming from a checkpoint:
|
|
107
|
+
- The system loads all previously evolved programs and their metrics
|
|
108
|
+
- Checkpoint numbering continues from where it left off (e.g., if loaded from checkpoint_50, the next checkpoint will be checkpoint_60)
|
|
109
|
+
- All evolution state is preserved (best programs, feature maps, archives, etc.)
|
|
110
|
+
- Each checkpoint directory contains a copy of the best program at that point in time
|
|
111
|
+
|
|
112
|
+
Example workflow with checkpoints:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Run for 50 iterations (creates checkpoints at iterations 10, 20, 30, 40, 50)
|
|
116
|
+
python openevolve-run.py examples/function_minimization/initial_program.py \
|
|
117
|
+
examples/function_minimization/evaluator.py \
|
|
118
|
+
--iterations 50
|
|
119
|
+
|
|
120
|
+
# Resume from checkpoint 50 for another 50 iterations (creates checkpoints at 60, 70, 80, 90, 100)
|
|
121
|
+
python openevolve-run.py examples/function_minimization/initial_program.py \
|
|
122
|
+
examples/function_minimization/evaluator.py \
|
|
123
|
+
--checkpoint examples/function_minimization/openevolve_output/checkpoints/checkpoint_50 \
|
|
124
|
+
--iterations 50
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Comparing Results Across Checkpoints
|
|
128
|
+
|
|
129
|
+
Each checkpoint directory contains the best program found up to that point, making it easy to compare solutions over time:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
checkpoints/
|
|
133
|
+
checkpoint_10/
|
|
134
|
+
best_program.py # Best program at iteration 10
|
|
135
|
+
best_program_info.json # Metrics and details
|
|
136
|
+
programs/ # All programs evaluated so far
|
|
137
|
+
metadata.json # Database state
|
|
138
|
+
checkpoint_20/
|
|
139
|
+
best_program.py # Best program at iteration 20
|
|
140
|
+
...
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
You can compare the evolution of solutions by examining the best programs at different checkpoints:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Compare best programs at different checkpoints
|
|
147
|
+
diff -u checkpoints/checkpoint_10/best_program.py checkpoints/checkpoint_20/best_program.py
|
|
148
|
+
|
|
149
|
+
# Compare metrics
|
|
150
|
+
cat checkpoints/checkpoint_*/best_program_info.json | grep -A 10 metrics
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Visualizing the evolution tree
|
|
154
|
+
|
|
155
|
+
The script in `scripts/visualize.py` allows you to visualize the evolution tree and display it in your webbrowser. The script watches live for the newest checkpoint directory in the examples/ folder structure and updates the graph. Alternatively, you can also provide a specific checkpoint folder with the `--path` parameter.
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Install requirements
|
|
159
|
+
pip install -r scripts/requirements.txt
|
|
160
|
+
|
|
161
|
+
# Start the visualization web server and have it watch the examples/ folder
|
|
162
|
+
python scripts/visualizer.py
|
|
163
|
+
|
|
164
|
+
# Start the visualization web server with a specific checkpoint
|
|
165
|
+
python scripts/visualizer.py --path examples/function_minimization/openevolve_output/checkpoints/checkpoint_100/
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
In the visualization UI, you can
|
|
169
|
+
- see the branching of your program evolution in a network visualization, with node radius chosen by the program fitness (= the currently selected metric),
|
|
170
|
+
- see the parent-child relationship of nodes and click through them in the sidebar (use the yellow locator icon in the sidebar to center the node in the graph),
|
|
171
|
+
- select the metric of interest (with the available metric choices depending on your data set),
|
|
172
|
+
- highlight nodes, for example the top score (for the chosen metric) or the MAP-elites members,
|
|
173
|
+
- click nodes to see their code and prompts (if available from the checkpoint data) in a sidebar,
|
|
174
|
+
- in the "Performance" tab, see their selected metric score vs generation in a graph
|
|
175
|
+
|
|
176
|
+

|
|
177
|
+
|
|
178
|
+
### Docker
|
|
179
|
+
|
|
180
|
+
You can also install and execute via Docker:
|
|
181
|
+
```bash
|
|
182
|
+
docker build -t openevolve .
|
|
183
|
+
docker run --rm -v $(pwd):/app --network="host" openevolve examples/function_minimization/initial_program.py examples/function_minimization/evaluator.py --config examples/function_minimization/config.yaml --iterations 1000
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Configuration
|
|
187
|
+
|
|
188
|
+
OpenEvolve is highly configurable. You can specify configuration options in a YAML file:
|
|
189
|
+
|
|
190
|
+
```yaml
|
|
191
|
+
# Example configuration
|
|
192
|
+
max_iterations: 1000
|
|
193
|
+
llm:
|
|
194
|
+
primary_model: "gemini-2.0-flash-lite"
|
|
195
|
+
secondary_model: "gemini-2.0-flash"
|
|
196
|
+
temperature: 0.7
|
|
197
|
+
database:
|
|
198
|
+
population_size: 500
|
|
199
|
+
num_islands: 5
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Sample configuration files are available in the `configs/` directory:
|
|
203
|
+
- `default_config.yaml`: Comprehensive configuration with all available options
|
|
204
|
+
|
|
205
|
+
See the [Configuration Guide](configs/default_config.yaml) for a full list of options.
|
|
206
|
+
|
|
207
|
+
## Artifacts Channel
|
|
208
|
+
|
|
209
|
+
OpenEvolve includes a **artifacts side-channel** that allows evaluators to capture build errors, profiling results, etc. to provide better feedback to the LLM in subsequent generations. This feature enhances the evolution process by giving the LLM context about what went wrong and how to fix it.
|
|
210
|
+
|
|
211
|
+
The artifacts channel operates alongside the traditional fitness metrics.
|
|
212
|
+
|
|
213
|
+
### Example: Compilation Failure Feedback
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
from openevolve.evaluation_result import EvaluationResult
|
|
217
|
+
|
|
218
|
+
return EvaluationResult(
|
|
219
|
+
metrics={"compile_ok": 0.0, "score": 0.0},
|
|
220
|
+
artifacts={
|
|
221
|
+
"stderr": "SyntaxError: invalid syntax (line 15)",
|
|
222
|
+
"traceback": "...",
|
|
223
|
+
"failure_stage": "compilation"
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
The next generation prompt will include:
|
|
229
|
+
```
|
|
230
|
+
## Last Execution Output
|
|
231
|
+
### Stderr
|
|
232
|
+
```
|
|
233
|
+
SyntaxError: invalid syntax (line 15)
|
|
234
|
+
```
|
|
235
|
+
### Traceback
|
|
236
|
+
```
|
|
237
|
+
...
|
|
238
|
+
```
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Configuration
|
|
242
|
+
|
|
243
|
+
Artifacts can be controlled via configuration and environment variables:
|
|
244
|
+
|
|
245
|
+
```yaml
|
|
246
|
+
# config.yaml
|
|
247
|
+
evaluator:
|
|
248
|
+
enable_artifacts: true
|
|
249
|
+
|
|
250
|
+
prompt:
|
|
251
|
+
include_artifacts: true
|
|
252
|
+
max_artifact_bytes: 4096 # 4KB limit in prompts
|
|
253
|
+
artifact_security_filter: true
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# Environment variable to disable artifacts
|
|
258
|
+
export ENABLE_ARTIFACTS=false
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Benefits
|
|
262
|
+
|
|
263
|
+
- **Faster convergence** - LLMs can see what went wrong and fix it directly
|
|
264
|
+
- **Better error handling** - Compilation and runtime failures become learning opportunities
|
|
265
|
+
- **Rich debugging context** - Full stack traces and error messages guide improvements
|
|
266
|
+
- **Zero overhead** - When disabled, no performance impact on evaluation
|
|
267
|
+
|
|
268
|
+
## Examples
|
|
269
|
+
|
|
270
|
+
See the `examples/` directory for complete examples of using OpenEvolve on various problems:
|
|
271
|
+
|
|
272
|
+
### Symbolic Regression
|
|
273
|
+
|
|
274
|
+
A comprehensive example demonstrating OpenEvolve's application to symbolic regression tasks using the LLM-SRBench benchmark. This example shows how OpenEvolve can evolve simple mathematical expressions (like linear models) into complex symbolic formulas that accurately fit scientific datasets.
|
|
275
|
+
|
|
276
|
+
[Explore the Symbolic Regression Example](examples/symbolic_regression/)
|
|
277
|
+
|
|
278
|
+
Key features:
|
|
279
|
+
- Automatic generation of initial programs from benchmark tasks
|
|
280
|
+
- Evolution from simple linear models to complex mathematical expressions
|
|
281
|
+
- Evaluation on physics, chemistry, biology, and material science datasets
|
|
282
|
+
- Competitive results compared to state-of-the-art symbolic regression methods
|
|
283
|
+
|
|
284
|
+
### Circle Packing
|
|
285
|
+
|
|
286
|
+
Our implementation of the circle packing problem from the AlphaEvolve paper. For the n=26 case, where one needs to pack 26 circles in a unit square we also obtain SOTA results.
|
|
287
|
+
|
|
288
|
+
[Explore the Circle Packing Example](examples/circle_packing/)
|
|
289
|
+
|
|
290
|
+
We have sucessfully replicated the results from the AlphaEvolve paper, below is the packing found by OpenEvolve after 800 iterations
|
|
291
|
+
|
|
292
|
+

|
|
293
|
+
|
|
294
|
+
This is exactly the packing reported by AlphaEvolve in their paper (Figure 14):
|
|
295
|
+
|
|
296
|
+

|
|
297
|
+
|
|
298
|
+
### Function Minimization
|
|
299
|
+
|
|
300
|
+
An example showing how OpenEvolve can transform a simple random search algorithm into a sophisticated simulated annealing approach.
|
|
301
|
+
|
|
302
|
+
[Explore the Function Minimization Example](examples/function_minimization/)
|
|
303
|
+
|
|
304
|
+
## Preparing Your Own Problems
|
|
305
|
+
|
|
306
|
+
To use OpenEvolve for your own problems:
|
|
307
|
+
|
|
308
|
+
1. **Mark code sections** to evolve with `# EVOLVE-BLOCK-START` and `# EVOLVE-BLOCK-END` comments
|
|
309
|
+
2. **Create an evaluation function** that returns a dictionary of metrics
|
|
310
|
+
3. **Configure OpenEvolve** with appropriate parameters
|
|
311
|
+
4. **Run the evolution** process
|
|
312
|
+
|
|
313
|
+
## Citation
|
|
314
|
+
|
|
315
|
+
If you use OpenEvolve in your research, please cite:
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
@software{openevolve,
|
|
319
|
+
title = {OpenEvolve: Open-source implementation of AlphaEvolve},
|
|
320
|
+
author = {Asankhaya Sharma},
|
|
321
|
+
year = {2025},
|
|
322
|
+
publisher = {GitHub},
|
|
323
|
+
url = {https://github.com/codelion/openevolve}
|
|
324
|
+
}
|
|
325
|
+
```
|