Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
216b300
Add another example
codelion May 24, 2025
486d9e7
Update README.md
codelion May 24, 2025
dcf37b1
Update config.yaml
codelion May 24, 2025
044cfc0
it
codelion May 24, 2025
cea7b81
Update initial_program.py
codelion May 24, 2025
a78e27f
Update config.yaml
codelion May 24, 2025
2f2ae23
Update config.yaml
codelion May 24, 2025
7e9b419
c
codelion May 24, 2025
5191dab
use google api
codelion May 24, 2025
673610e
Update config.yaml
codelion May 24, 2025
53ff9ae
Update config.yaml
codelion May 24, 2025
b428b9a
i
codelion May 24, 2025
54dde41
fixes
codelion May 25, 2025
03c543f
fixes
codelion May 25, 2025
50bee94
Update config.yaml
codelion May 25, 2025
979b4a7
Update evaluator.py
codelion May 25, 2025
2c2e0aa
i
codelion May 25, 2025
f3174f9
init
codelion May 25, 2025
6ab66ed
t
codelion May 25, 2025
d548c97
Update config.yaml
codelion May 25, 2025
9fc0ae1
Merge branch 'main' into feat/MLX-kernel-optimization
codelion May 25, 2025
5921bd1
remove old example
codelion May 27, 2025
4a217ff
new example
codelion May 27, 2025
6364092
add the best program
codelion May 27, 2025
48a953a
Update README.md
codelion May 27, 2025
87c449a
Merge branch 'main' into feat/MLX-kernel-optimization
codelion May 27, 2025
3b115d2
Update README.md
codelion May 27, 2025
dba614c
fix
codelion May 27, 2025
a42bfd3
Update evaluator.py
codelion May 27, 2025
cea4d7b
Update config.yaml
codelion May 27, 2025
bf73e00
fix
codelion May 27, 2025
f430c1a
fix erward hacking
codelion May 27, 2025
b99dfea
Update config.yaml
codelion May 27, 2025
93336c1
Update config.yaml
codelion May 27, 2025
6ec75d7
Update config.yaml
codelion May 27, 2025
3188b0f
Update config.yaml
codelion May 27, 2025
bb9ee2c
Update config.yaml
codelion May 27, 2025
8d5fdb2
fix simpler version
codelion May 27, 2025
8155993
Update config.yaml
codelion May 27, 2025
0d7fc35
Update evaluator.py
codelion May 27, 2025
e4a1706
Update config.yaml
codelion May 27, 2025
6b01219
f
codelion May 27, 2025
21149e2
Update evaluator.py
codelion May 27, 2025
a1fad2d
f
codelion May 27, 2025
588fa0c
Update initial_program.py
codelion May 27, 2025
fc317e6
remove
codelion May 28, 2025
5119c95
Update README.md
codelion May 28, 2025
6e321b5
fix liner
codelion May 28, 2025
9f99f63
f
codelion May 30, 2025
bd0ee98
as
codelion May 31, 2025
957f4a7
remove
codelion May 31, 2025
233b098
fxies
codelion Jun 2, 2025
81bc809
formatting
codelion Jun 2, 2025
1b8441d
Merge branch 'main' into feat/MLX-kernel-optimization
codelion Jun 2, 2025
86e5bcf
g
codelion Jun 2, 2025
bc47e1e
Update database.py
codelion Jun 2, 2025
258f44b
fixes
codelion Jun 2, 2025
cf20743
Update database.py
codelion Jun 2, 2025
0471ec2
Update config.yaml
codelion Jun 3, 2025
42e5f82
Delete initial_program_backup_before_metal_kernels.py
codelion Jun 3, 2025
a2ceebc
initial implementation for the block digagonal implementation evolution
codelion Jun 3, 2025
1ad2c09
Merge branch 'main' into feat/MLX-kernel-optimization
codelion Jun 3, 2025
f91995b
as
codelion Jun 3, 2025
2baea9f
Update initial_program.py
codelion Jun 3, 2025
09a7160
Update evaluator.py
codelion Jun 3, 2025
d8f1e58
Update evaluator.py
codelion Jun 3, 2025
625e2d8
Update evaluator.py
codelion Jun 3, 2025
bac2975
Update config.yaml
codelion Jun 3, 2025
49ca77a
Update evaluator.py
codelion Jun 3, 2025
f02c217
Update evaluator.py
codelion Jun 3, 2025
0eae54e
Update evaluator.py
codelion Jun 3, 2025
d88aebb
as
codelion Jun 4, 2025
33e4e7d
Merge branch 'main' into feat/MLX-kernel-optimization
codelion Jun 4, 2025
fd76977
Delete test_fix.py
codelion Jun 4, 2025
7d9934b
Merge branch 'main' into feat/MLX-kernel-optimization
codelion Jun 4, 2025
fdc659e
fxies
codelion Jun 4, 2025
dc078bc
fixes
codelion Jun 4, 2025
274da13
linting
codelion Jun 4, 2025
04f5b0c
fix
codelion Jun 5, 2025
7856769
Update evaluator.py
codelion Jun 5, 2025
cc2b4c6
Update test_evolved.py
codelion Jun 5, 2025
6407304
Update test_evolved.py
codelion Jun 5, 2025
b04dd7f
Update test_evolved.py
codelion Jun 5, 2025
e606a49
f
codelion Jun 5, 2025
9a3aa19
as
codelion Jun 5, 2025
e24bc87
Update config.yaml
codelion Jun 5, 2025
e261832
g
codelion Jun 5, 2025
8ee2659
Update evaluator.py
codelion Jun 5, 2025
b392c3c
f
codelion Jun 5, 2025
37b5847
Update evaluator.py
codelion Jun 5, 2025
ef2d25d
f
codelion Jun 5, 2025
91b0586
a
codelion Jun 6, 2025
76881de
f
codelion Jun 6, 2025
f5ae7bf
Update config.yaml
codelion Jun 6, 2025
f2199bc
Update test_evolved.py
codelion Jun 6, 2025
19a656f
f
codelion Jun 7, 2025
6bea22d
d
codelion Jun 7, 2025
72b88ed
j
codelion Jun 7, 2025
1cd5006
Update controller.py
codelion Jun 8, 2025
187472e
Update database.py
codelion Jun 8, 2025
b8448c2
f
codelion Jun 8, 2025
ad11ce0
another attempt
codelion Jun 8, 2025
3c833f0
Update evaluator.py
codelion Jun 8, 2025
b00f3cf
Update initial_program.py
codelion Jun 8, 2025
42e760c
Update config.yaml
codelion Jun 8, 2025
eac05b8
Update evaluator.py
codelion Jun 9, 2025
ad13d3e
h
codelion Jun 9, 2025
cf5e451
f
codelion Jun 9, 2025
ee8f175
linter
codelion Jun 9, 2025
8fadaf5
Merge branch 'main' into feat/MLX-kernel-optimization
codelion Jun 9, 2025
70e2421
g
codelion Jun 9, 2025
6294b31
Update config.yaml
codelion Jun 9, 2025
9c32c43
f
codelion Jun 9, 2025
f34f2e2
Merge branch 'main' into feat/MLX-kernel-optimization
codelion Jun 9, 2025
ea2a091
d
codelion Jun 10, 2025
ee28e38
it
codelion Jun 10, 2025
5cf3fa1
Update config.yaml
codelion Jun 10, 2025
a8ee79a
Update config.yaml
codelion Jun 10, 2025
7f1d6ad
Update evaluator.py
codelion Jun 10, 2025
2999e13
a
codelion Jun 10, 2025
af8919d
Update evaluator.py
codelion Jun 10, 2025
3f0e7be
f
codelion Jun 11, 2025
0167b88
as
codelion Jun 11, 2025
f6f6ecd
s
codelion Jun 11, 2025
8c6aaf6
i
codelion Jun 11, 2025
1dd7f4e
j
codelion Jun 13, 2025
a6df90e
Update initial_program.py
codelion Jun 13, 2025
5dd6177
f
codelion Jun 13, 2025
9b90c69
Update evaluator.py
codelion Jun 13, 2025
4f4a500
Update evaluator.py
codelion Jun 13, 2025
a1b74e1
f
codelion Jun 14, 2025
64f909b
Merge branch 'main' into feat/MLX-kernel-optimization
codelion Jun 14, 2025
6481157
f
codelion Jun 15, 2025
83284e8
Update qwen3_benchmark_suite.py
codelion Jun 15, 2025
9191687
Update evaluator.py
codelion Jun 15, 2025
6750f6b
Update quick_benchmark_test.py
codelion Jun 15, 2025
dd688f8
k
codelion Jun 15, 2025
17ee9f1
d
codelion Jun 15, 2025
1247bf2
Update evaluator.py
codelion Jun 15, 2025
747c9ea
g
codelion Jun 15, 2025
ca90538
s
codelion Jun 15, 2025
569143c
Update evaluator.py
codelion Jun 15, 2025
f8bc941
Update evaluator.py
codelion Jun 15, 2025
ef0fde9
f
codelion Jun 16, 2025
31716cd
Update run_benchmarks.py
codelion Jun 16, 2025
e1dff83
Update config.yaml
codelion Jun 16, 2025
0a9f073
Update initial_program.py
codelion Jun 16, 2025
f9de81c
Update initial_program.py
codelion Jun 16, 2025
77e1093
Update config.yaml
codelion Jun 16, 2025
ad1ec74
Update evaluator.py
codelion Jun 16, 2025
089518e
Update evaluator.py
codelion Jun 17, 2025
23b0495
Update evaluator.py
codelion Jun 17, 2025
086b349
Create release.yml
codelion Jun 17, 2025
ab72ae4
Update evaluator.py
codelion Jun 17, 2025
ebdecd4
a
codelion Jun 17, 2025
9778bb1
Update run_benchmarks.py
codelion Jun 17, 2025
475f8d0
d
codelion Jun 17, 2025
356ece2
Update best_program.py
codelion Jun 17, 2025
9c8e371
d
codelion Jun 17, 2025
94d148c
d
codelion Jun 18, 2025
f9a8f0f
f
codelion Jun 18, 2025
cecdee8
Update initial_program.py
codelion Jun 18, 2025
7e5336b
Update config.yaml
codelion Jun 18, 2025
753cb5b
Delete best_program.py
codelion Jun 18, 2025
35e6cdc
Update run_benchmarks.py
codelion Jun 18, 2025
b860d10
d
codelion Jun 19, 2025
82c2796
Adding the best program for reference
codelion Jun 19, 2025
c1e9a02
s
codelion Jun 19, 2025
fa5116c
added the best_prgoram for reference
codelion Jun 19, 2025
a4e0107
linter
codelion Jun 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Upload Python Package and Docker Image on Release
on:
release:
types: [created]

jobs:
pypi-publish:
name: Publish release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/openevolve
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: |
python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

docker-publish:
name: Publish Docker image
runs-on: ubuntu-22.04
needs: pypi-publish
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4

# Add aggressive cleanup before any Docker operations
- name: Free disk space
run: |
# Clean Docker
docker system prune -af
docker image prune -af
docker builder prune -af

df -h

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:buildx-stable-1
network=host
buildkitd-flags: --debug

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata for Docker image
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest

# Build and push Docker image for AMD64
- name: Build and push Docker image AMD64
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=openevolve-amd64
cache-to: type=gha,scope=openevolve-amd64,mode=max
outputs: type=registry,compression=zstd,compression-level=5

# Cleanup after AMD64 build
- name: Cleanup after AMD64 build
run: |
docker system prune -af
docker builder prune -af
df -h

# Build and push Docker image for ARM64
- name: Build and push Docker image ARM64
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
platforms: linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=openevolve-arm64
cache-to: type=gha,scope=openevolve-arm64,mode=max
outputs: type=registry,compression=zstd,compression-level=5

# Final cleanup
- name: Final cleanup
run: |
docker system prune -af
docker builder prune -af
find /tmp -type f -user $(id -u) -exec rm -f {} + 2>/dev/null || true
df -h
151 changes: 151 additions & 0 deletions examples/circle_packing/best_program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# EVOLVE-BLOCK-START
"""Advanced circle packing for n=26 circles in a unit square"""
import numpy as np
from scipy.optimize import minimize


def construct_packing():
"""
Construct an optimized arrangement of 26 circles in a unit square
using mathematical principles and optimization techniques.

Returns:
Tuple of (centers, radii, sum_of_radii)
centers: np.array of shape (26, 2) with (x, y) coordinates
radii: np.array of shape (26) with radius of each circle
sum_of_radii: Sum of all radii
"""
n = 26

# Initial guess: Strategic placement with some randomness
centers = np.zeros((n, 2))
radii = np.zeros(n)

# Heuristic placement for better initial guess: place larger circles in center
radii[:] = np.linspace(0.12, 0.05, n) # Linear distribution of radii

# Initial placement: approximate hexagonal grid
grid_x = int(np.sqrt(n))
grid_y = int(n / grid_x)

x_coords = np.linspace(0.15, 0.85, grid_x)
y_coords = np.linspace(0.15, 0.85, grid_y)

count = 0
for i in range(grid_x):
for j in range(grid_y):
if count < n:
centers[count] = [x_coords[i] + 0.05 * (j % 2), y_coords[j]]
count += 1

# Place remaining circles randomly
while count < n:
centers[count] = np.random.rand(2) * 0.7 + 0.15
count += 1

# Objective function: Negative sum of radii (to maximize)
def objective(x):
centers = x[: 2 * n].reshape(n, 2)
radii = x[2 * n :]
return -np.sum(radii)

# Constraint: No overlaps and circles stay within the unit square
def constraint(x):
centers = x[: 2 * n].reshape(n, 2)
radii = x[2 * n :]

# Overlap constraint
overlap_constraints = []
for i in range(n):
for j in range(i + 1, n):
dist = np.sqrt(np.sum((centers[i] - centers[j]) ** 2))
overlap_constraints.append(dist - (radii[i] + radii[j]))

# Boundary constraints
boundary_constraints = []
for i in range(n):
boundary_constraints.append(centers[i, 0] - radii[i]) # x >= radius
boundary_constraints.append(1 - centers[i, 0] - radii[i]) # x <= 1 - radius
boundary_constraints.append(centers[i, 1] - radii[i]) # y >= radius
boundary_constraints.append(1 - centers[i, 1] - radii[i]) # y <= 1 - radius

return np.array(overlap_constraints + boundary_constraints)

# Initial guess vector
x0 = np.concatenate([centers.flatten(), radii])

# Bounds: Circles stay within the unit square and radii are positive
bounds = [(0, 1)] * (2 * n) + [(0.03, 0.2)] * n # radii are positive, up to 0.2

# Constraints dictionary
constraints = {"type": "ineq", "fun": constraint}

# Optimization using SLSQP
result = minimize(
objective,
x0,
method="SLSQP",
bounds=bounds,
constraints=constraints,
options={"maxiter": 1000, "ftol": 1e-8},
)

# Extract optimized centers and radii
optimized_centers = result.x[: 2 * n].reshape(n, 2)
optimized_radii = result.x[2 * n :]

# Ensure radii are not negative (numerical stability)
optimized_radii = np.maximum(optimized_radii, 0.001)

# Calculate the sum of radii
sum_radii = np.sum(optimized_radii)

return optimized_centers, optimized_radii, sum_radii


# EVOLVE-BLOCK-END


# This part remains fixed (not evolved)
def run_packing():
"""Run the circle packing constructor for n=26"""
centers, radii, sum_radii = construct_packing()
return centers, radii, sum_radii


def visualize(centers, radii):
"""
Visualize the circle packing

Args:
centers: np.array of shape (n, 2) with (x, y) coordinates
radii: np.array of shape (n) with radius of each circle
"""
import matplotlib.pyplot as plt
from matplotlib.patches import Circle

fig, ax = plt.subplots(figsize=(8, 8))

# Draw unit square
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)
ax.set_aspect("equal")
ax.grid(True)

# Draw circles
for i, (center, radius) in enumerate(zip(centers, radii)):
circle = Circle(center, radius, alpha=0.5)
ax.add_patch(circle)
ax.text(center[0], center[1], str(i), ha="center", va="center")

plt.title(f"Circle Packing (n={len(centers)}, sum={sum(radii):.6f})")
plt.show()


if __name__ == "__main__":
centers, radii, sum_radii = run_packing()
print(f"Sum of radii: {sum_radii}")
# AlphaEvolve improved this to 2.635

# Uncomment to visualize:
# visualize(centers, radii)
16 changes: 16 additions & 0 deletions examples/circle_packing/best_program_info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"id": "f6cbff44-9b16-4e6c-af58-b10b6625621a",
"generation": 10,
"iteration": 0,
"timestamp": 1747709506.546607,
"parent_id": "b7f51a09-7ba5-4cdb-bc15-9c431ec8885f",
"metrics": {
"validity": 1.0,
"sum_radii": 2.634292402141039,
"target_ratio": 0.9997314619131079,
"combined_score": 0.9997314619131079,
"eval_time": 0.6134955883026123
},
"language": "python",
"saved_at": 1748016967.553278
}
Loading