You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This example attempts to replicate one of the specific results from the AlphaEvolve paper (Section B.12): packing 26 circles inside a unit square to maximize the sum of their radii.
4
4
@@ -8,35 +8,47 @@ The problem is to pack 26 disjoint circles inside a unit square so as to maximiz
8
8
- Lie entirely within the unit square [0,1] × [0,1]
9
9
- Not overlap with each other
10
10
11
-
This is a well-studied problem in computational geometry with applications in various fields including material science, facility location, and computer graphics.
11
+
According to the paper, AlphaEvolve improved the state of the art for n=26 from 2.634 to 2.635.
12
12
13
-
## AlphaEvolve Result
13
+
## Constructor-Based Approach
14
14
15
-
According to the paper, AlphaEvolve improved the state of the art for n=26 from 2.634 to 2.635.
15
+
Following insights from the AlphaEvolve paper, we use a constructor-based approach rather than a search algorithm:
16
+
17
+
> "For problems with highly symmetric solutions it is advantageous to evolve constructor functions as these tend to be more concise." - AlphaEvolve paper, Section 2.1
18
+
19
+
Instead of evolving a search algorithm that tries different configurations, we evolve a function that directly constructs a specific packing arrangement. This approach:
20
+
21
+
1. Is more deterministic (produces the same output each time)
22
+
2. Can leverage geometric knowledge about optimal packings
23
+
3. Tends to be more concise and easier to evolve
24
+
4. Works well for problems with inherent structure or symmetry
The evolution might discover various pattern-based approaches:
35
+
36
+
1.**Concentric rings**: Placing circles in concentric rings around a central circle
37
+
2.**Hexagonal patterns**: Portions of a hexagonal lattice (theoretically optimal for infinite packings)
38
+
3.**Mixed-size arrangements**: Varying circle sizes to better utilize space near the boundaries
39
+
4.**Specialized patterns**: Custom arrangements specific to n=26
40
+
23
41
## Evaluation Metrics
24
42
25
43
The evaluator calculates several metrics:
26
-
-`sum_radii`: The best sum of radii achieved across all trials
27
-
-`avg_sum_radii`: Average sum of radii across successful trials
44
+
-`sum_radii`: The sum of radii achieved by the constructor
28
45
-`target_ratio`: Ratio of achieved sum to target (2.635)
29
-
-`reliability`: Fraction of trials that produced valid solutions
30
-
-`avg_time`: Average execution time
31
-
-`combined_score`: A weighted combination of the above metrics (main fitness metric)
32
-
33
-
## Expected Results
34
-
35
-
A successful run should find a packing arrangement with sum of radii approaching or exceeding the value reported in the AlphaEvolve paper: 2.635 for n=26.
46
+
-`validity`: Confirms circles don't overlap and stay within bounds
47
+
-`combined_score`: A weighted combination of metrics (main fitness metric)
36
48
37
49
## Visualization
38
50
39
-
The initial program includes a visualization function that you can use to see the packing arrangement:
51
+
The program includes a visualization function to see the constructed packing:
40
52
41
53
```python
42
54
# Add this to the end of the best program
@@ -45,3 +57,9 @@ if __name__ == "__main__":
45
57
print(f"Sum of radii: {sum_radii}")
46
58
visualize(centers, radii)
47
59
```
60
+
61
+
## What to Expect
62
+
63
+
The evolution process should discover increasingly better constructor functions, with several possible patterns emerging. Given enough iterations, it should approach or exceed the 2.635 value achieved in the paper.
64
+
65
+
Different runs may converge to different packing strategies, as multiple near-optimal arrangements are possible for this problem.
Copy file name to clipboardExpand all lines: examples/circle_packing/config.yaml
+20-10Lines changed: 20 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,7 @@
1
-
# Configuration for circle packing example
2
-
max_iterations: 100
1
+
# Configuration for circle packing constructor evolution (n=26)
2
+
max_iterations: 100# Increased iterations
3
3
checkpoint_interval: 10
4
4
log_level: "INFO"
5
-
max_code_length: 100000
6
5
7
6
# LLM configuration
8
7
llm:
@@ -21,16 +20,27 @@ llm:
21
20
22
21
# Prompt configuration
23
22
prompt:
24
-
system_message: "You are an expert programmer specializing in optimization algorithms and computational geometry. Your task is to improve a circle packing algorithm to maximize the sum of radii when packing 26 circles in a unit square without overlaps. The AlphaEvolve paper achieved a sum of 2.635 for n=26, which is the target value to reach or exceed. Focus on finding better optimization strategies, leveraging geometric insights about optimal packing arrangements, and developing more effective search techniques."
23
+
system_message: |
24
+
You are an expert mathematician specializing in circle packing problems and computational geometry. Your task is to improve a constructor function that directly produces a specific arrangement of 26 circles in a unit square, maximizing the sum of their radii. The AlphaEvolve paper achieved a sum of 2.635 for n=26.
25
+
26
+
Key geometric insights:
27
+
- Circle packings often follow hexagonal patterns in the densest regions
28
+
- Maximum density for infinite circle packing is pi/(2*sqrt(3)) ≈ 0.9069
29
+
- Edge effects make square container packing harder than infinite packing
30
+
- Circles can be placed in layers or shells when confined to a square
31
+
- Similar radius circles often form regular patterns, while varied radii allow better space utilization
32
+
- Perfect symmetry may not yield the optimal packing due to edge effects
33
+
34
+
Focus on designing an explicit constructor that places each circle in a specific position, rather than an iterative search algorithm.
25
35
num_top_programs: 3
26
36
use_template_stochasticity: true
27
37
28
38
# Database configuration
29
39
database:
30
-
population_size: 50
31
-
archive_size: 20
32
-
num_islands: 3
33
-
elite_selection_ratio: 0.2
40
+
population_size: 60# Increased population for more diversity
41
+
archive_size: 25
42
+
num_islands: 4
43
+
elite_selection_ratio: 0.3
34
44
exploitation_ratio: 0.7
35
45
36
46
# Evaluator configuration
@@ -42,5 +52,5 @@ evaluator:
42
52
use_llm_feedback: false
43
53
44
54
# Evolution settings
45
-
diff_based_evolution: true
46
-
allow_full_rewrites: false
55
+
diff_based_evolution: false # Use full rewrites instead of diffs
56
+
allow_full_rewrites: true # Allow full rewrites for constructor functions
0 commit comments