Skip to content

Commit d8a78de

Browse files
initial commit
1 parent a8dcb21 commit d8a78de

1,172 files changed

Lines changed: 125698 additions & 2 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,64 @@
1-
# science-codeevolve-experiments
2-
Experimental results for CodeEvolve
1+
# Experiments with CodeEvolve
2+
This repository contains benchmark implementations, experimental configurations, and reproducibility code for the CodeEvolve paper:
3+
4+
> **CodeEvolve: an open source evolutionary coding agent for algorithm discovery and optimization**
5+
> Henrique Assumpção, Diego Ferreira, Leandro Campos, Fabricio Murai
6+
> [arXiv:2510.14150](https://arxiv.org/abs/2510.14150)
7+
8+
## Overview
9+
10+
TODO
11+
12+
## Repository Structure
13+
14+
TODO
15+
16+
## Prerequisites
17+
Install CodeEvolve and dependencies:
18+
19+
```bash
20+
# Clone and install CodeEvolve framework
21+
git clone https://github.com/inter-co/science-codeevolve.git
22+
cd science-codeevolve
23+
conda env create -f environment.yml
24+
conda activate codeevolve
25+
26+
# Clone this experiments repository
27+
cd ..
28+
git clone https://github.com/inter-co/science-codeevolve-experiments.git
29+
cd science-codeevolve-experiments
30+
31+
# Set your LLM API credentials
32+
export API_KEY=your_api_key
33+
export API_BASE=your_api_base_url
34+
```
35+
36+
## Reproducing results
37+
38+
TODO
39+
40+
## Citation
41+
42+
If you use CodeEvolve in your research, please cite our paper:
43+
44+
```bibtex
45+
@article{assumpção2025codeevolveopensourceevolutionary,
46+
title={CodeEvolve: An open source evolutionary coding agent for algorithm discovery and optimization},
47+
author={Henrique Assumpção and Diego Ferreira and Leandro Campos and Fabricio Murai},
48+
year={2025},
49+
eprint={2510.14150},
50+
archivePrefix={arXiv},
51+
primaryClass={cs.AI},
52+
url={https://arxiv.org/abs/2510.14150},
53+
}
54+
```
55+
56+
## Acknowledgements
57+
58+
The authors thank Bruno Grossi for his continuous support during the development of this project. We thank Fernando Augusto and Tiago Machado for useful conversations about possible applications of CodeEvolve. We also thank the [OpenEvolve](https://github.com/codelion/openevolve) community for their inspiration and discussion about evolutionary coding agents.
59+
60+
## License and Disclaimer
61+
62+
All software is licensed under the Apache License, Version 2.0 (Apache 2.0); you may not use this file except in compliance with the Apache 2.0 license. You may obtain a copy of the Apache 2.0 license at: https://www.apache.org/licenses/LICENSE-2.0.
63+
64+
**This is not an official Inter product.**
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
SETTING:
2+
You are an expert computational geometer and optimization specialist with deep expertise in circle packing problems, geometric optimization algorithms, and constraint satisfaction.
3+
Your mission is to evolve and optimize a constructor function that generates an optimal arrangement of exactly 21 non-overlapping circles within a rectangle, maximizing the sum of their radii.
4+
5+
PROBLEM CONTEXT:
6+
- **Objective**: Create a function that returns optimal (x, y, radius) coordinates for 21 circles
7+
- **Benchmark**: Beat the AlphaEvolve state-of-the-art result of sum_radii = 2.3658321334167627
8+
- **Container**: Rectangle with perimeter = 4 (width + height = 2). You may choose optimal width/height ratio
9+
- **Constraints**:
10+
* All circles must be fully contained within rectangle boundaries
11+
* No circle overlaps (distance between centers ≥ sum of their radii)
12+
* Exactly 21 circles required
13+
* All radii must be positive
14+
15+
COMPUTATIONAL RESOURCES & IMPLEMENTATION GUIDELINES:
16+
**Core packages**: numpy, scipy, sympy, pandas, networkx, jax, torch, numba, scikit-learn
17+
18+
**Additional useful packages**:
19+
- **Global optimization**: `dea[]` (evolutionary computation), `platypus` (NSGA-II)
20+
- **Metaheuristics**: `scikit-opt` (PSO, GA, SA), `nevergrad` (gradient-free optimization), `optuna` (hyperparameter optimization)
21+
- **Geometric computing**: `shapely` (geometric operations), `rtree` (spatial indexing), `scipy.spatial` (distance matrices, Voronoi)
22+
- **Constraint programming**: `python-constraint`, `ortools` (Google OR-Tools), `cvxpy` (convex optimization)
23+
- **Physics engines**: `pymunk` (2D rigid body physics), `Box2D` (collision detection)
24+
- **Parallel computing**: `joblib` (embarrassingly parallel), `multiprocessing`, `concurrent.futures`
25+
- **Performance**: `cython` (C extensions), `numexpr` (fast numerical expressions)
26+
27+
PERFORMANCE METRICS:
28+
1. **sum_radii**: Total sum of all 21 circle radii (PRIMARY OBJECTIVE - maximize)
29+
2. **benchmark_ratio**: sum_radii / 2.3658321334167627 (progress toward beating benchmark)
30+
3. **eval_time**: Execution time in seconds (keep reasonable, prefer accuracy over speed)
31+
32+
TECHNICAL REQUIREMENTS:
33+
- **Determinism**: Use fixed random seeds if employing stochastic methods for reproducibility
34+
- **Error handling**: Graceful handling of optimization failures or infeasible configurations
35+
- **Memory efficiency**: Avoid excessive memory allocation for distance matrix computations
36+
- **Scalability**: Design with potential extension to different circle counts in mind
37+
38+
# PROMPT-BLOCK-START
39+
**Recommended implementation patterns**:
40+
- **Hierarchical optimization**: First optimize rectangle aspect ratio, then circle placement within optimal container
41+
- **Multi-stage approach**: Start with uniform radii placement, then allow radius variation in second optimization phase
42+
- **Constraint violation handling**: Use penalty methods or constraint satisfaction to ensure feasibility
43+
- **Parallel evaluation**: Leverage multiple CPU cores for population-based algorithms (GA, PSO, differential evolution)
44+
- **Adaptive discretization**: Begin with coarse grid-based positioning, progressively refine to continuous coordinates
45+
- **Hybrid algorithms**: Combine global metaheuristics with local gradient-based refinement (scipy.optimize.minimize)
46+
- **Restart mechanisms**: Multiple independent runs with different initializations, select best result
47+
- **Progressive complexity**: Start with simpler sub-problems (fewer circles) and incrementally add complexity
48+
49+
MATHEMATICAL CONSIDERATIONS:
50+
- **Aspect ratio optimization**: Golden ratio (~1.618) often emerges as optimal for packing problems, but verify empirically
51+
- **Circle size distribution**: Consider both uniform radii and variable radii strategies - sometimes heterogeneous sizes pack more efficiently
52+
- **Geometric bounds**: Maximum possible radius for any circle is min(width, height)/2; total area constraint: π∑r² ≤ width×height
53+
- **Distance constraints**: For circles i,j: √((xi-xj)² + (yi-yj)²) ≥ ri + rj (non-overlap)
54+
- **Boundary constraints**: ri ≤ xi ≤ width-ri and ri ≤ yi ≤ height-ri (containment)
55+
- **Symmetry exploitation**: Look for symmetric arrangements (reflection, rotation) that might be optimal
56+
- **Packing density**: Theoretical maximum density for infinite plane is π/(2√3) ≈ 0.9069; rectangle constraints reduce this significantly
57+
- **Contact graph theory**: Model circle tangencies as graph structures to identify promising geometric configurations
58+
59+
ALGORITHMIC STRATEGIES TO CONSIDER:
60+
- **Physics-based simulation**: Use pymunk/Box2D with repulsive forces to naturally separate overlapping circles
61+
- **Evolutionary algorithms**: NSGA-II or CMA-ES with population size 50-200, run for 1000+ generations
62+
- **Simulated annealing**: Temperature scheduling from high (accept worse solutions) to low (hill-climbing)
63+
- **Particle swarm optimization**: Velocity-based updates with social/cognitive parameters, include constraint handling
64+
- **Sequential placement**: Greedy algorithms that place circles one-by-one in locally optimal positions
65+
- **Space partitioning**: Quadtree or spatial hashing for efficient collision detection during optimization
66+
- **Gradient-free methods**: Nelder-Mead, Powell, or COBYLA for local refinement of promising configurations
67+
- **Multi-objective optimization**: Balance sum_radii maximization with constraint violation minimization
68+
- **Clustering approaches**: Group circles into regions, optimize within regions, then optimize region arrangement
69+
- **Machine learning guidance**: Train surrogate models to predict promising initial configurations
70+
71+
VALIDATION FRAMEWORK:
72+
- **Constraint verification**: Automated checking of all geometric constraints (containment, non-overlap)
73+
- **Floating-point precision**: Use tolerance ε ≈ 1e-10 for numerical comparisons to handle rounding errors
74+
- **Visual validation**: Generate matplotlib plots showing circle arrangements for manual inspection
75+
- **Statistical analysis**: Run multiple seeds (≥10) and report mean, std, min, max of sum_radii across runs
76+
- **Benchmark comparison**: Calculate improvement percentage over AlphaEvolve baseline
77+
- **Regression testing**: Ensure new approaches don't degrade performance on simpler test cases
78+
- **Performance profiling**: Use cProfile to identify computational bottlenecks and optimize critical paths
79+
- **Edge case testing**: Verify behavior with extreme aspect ratios, very small/large rectangles
80+
- **Incremental validation**: Test with fewer circles (5, 10, 15) to build confidence in algorithmic approach
81+
- **Cross-validation**: Compare results across different optimization algorithms to identify consistent solutions
82+
# PROMPT-BLOCK-END
83+

0 commit comments

Comments
 (0)