Skip to content

Commit a88da1d

Browse files
committed
- Make top_k optional. Certain Anthropic models throw an error if both temperature and top_k are passed.
- Added alternative configurations for circle packing example
1 parent 75bc298 commit a88da1d

3 files changed

Lines changed: 129 additions & 5 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Configuration for circle packing constructor evolution (n=26)
2+
max_iterations: 100 # Increased iterations
3+
checkpoint_interval: 10
4+
log_level: "INFO"
5+
6+
# LLM configuration
7+
llm:
8+
primary_model: "claude-sonnet-4-5-20250929"
9+
primary_model_weight: 0.8
10+
secondary_model: "claude-opus-4-5-20251101"
11+
secondary_model_weight: 0.2
12+
api_base: "https://api.anthropic.com/v1"
13+
api_key: "${ANTHROPIC_API_KEY}"
14+
temperature: 0.7
15+
max_tokens: 8192
16+
timeout: 600
17+
18+
# Prompt configuration
19+
prompt:
20+
system_message: |
21+
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.
22+
23+
Key geometric insights:
24+
- Circle packings often follow hexagonal patterns in the densest regions
25+
- Maximum density for infinite circle packing is pi/(2*sqrt(3)) ≈ 0.9069
26+
- Edge effects make square container packing harder than infinite packing
27+
- Circles can be placed in layers or shells when confined to a square
28+
- Similar radius circles often form regular patterns, while varied radii allow better space utilization
29+
- Perfect symmetry may not yield the optimal packing due to edge effects
30+
31+
Focus on designing an explicit constructor that places each circle in a specific position, rather than an iterative search algorithm.
32+
num_top_programs: 3
33+
use_template_stochasticity: true
34+
35+
# Database configuration
36+
database:
37+
population_size: 60 # Increased population for more diversity
38+
archive_size: 25
39+
num_islands: 4
40+
elite_selection_ratio: 0.3
41+
exploitation_ratio: 0.7
42+
43+
# Evaluator configuration
44+
evaluator:
45+
timeout: 60
46+
cascade_evaluation: true
47+
cascade_thresholds: [0.5, 0.75]
48+
parallel_evaluations: 4
49+
use_llm_feedback: false
50+
51+
# Evolution settings
52+
diff_based_evolution: false # Use full rewrites instead of diffs
53+
allow_full_rewrites: true # Allow full rewrites for constructor functions
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Configuration for breaking through the circle packing plateau
2+
max_iterations: 100
3+
checkpoint_interval: 10
4+
log_level: "INFO"
5+
6+
# LLM configuration
7+
llm:
8+
primary_model: "claude-sonnet-4-5-20250929"
9+
primary_model_weight: 0.8
10+
secondary_model: "claude-opus-4-5-20251101"
11+
secondary_model_weight: 0.2
12+
api_base: "https://api.anthropic.com/v1"
13+
api_key: "${ANTHROPIC_API_KEY}"
14+
temperature: 0.7
15+
top_p: null
16+
max_tokens: 8192
17+
timeout: 600
18+
19+
# Prompt configuration
20+
prompt:
21+
system_message: |
22+
You are an expert mathematician specializing in circle packing problems and computational geometry. We're trying to reach the AlphaEvolve target of 2.635 for the sum of radii when packing 26 circles in a unit square. The current implementation has plateaued at 2.377, so we need significant improvements.
23+
24+
Key insights to explore:
25+
1. The optimal arrangement likely involves variable-sized circles
26+
2. A pure hexagonal arrangement may not be optimal due to edge effects
27+
3. The densest known circle packings often use a hybrid approach
28+
4. STRONGLY RECOMMENDED: Formulate this as a constrained optimization problem.
29+
- Use `scipy.optimize.minimize` with the 'SLSQP' method.
30+
- Define the objective function as minimizing the negative sum of radii.
31+
- Define constraints to ensure no circle overlaps and all circles stay within bounds.
32+
- This approach is mathematically superior to custom physics simulations for this specific problem.
33+
5. Consider strategic placement of circles at square corners and edges
34+
6. Adjusting the pattern to place larger circles at the center and smaller at the edges
35+
7. The math literature suggests special arrangements for specific values of n
36+
37+
Focus on breaking through the plateau by using numerical optimization libraries like scipy rather than writing custom solvers.
38+
num_top_programs: 4
39+
use_template_stochasticity: true
40+
41+
# Database configuration
42+
database:
43+
population_size: 70 # Larger population for more diversity
44+
archive_size: 30
45+
num_islands: 5
46+
elite_selection_ratio: 0.3
47+
exploitation_ratio: 0.6 # Slightly lower to encourage exploration
48+
49+
# Evaluator configuration
50+
evaluator:
51+
timeout: 90 # Extended timeout to allow for more complex optimization
52+
cascade_evaluation: true
53+
cascade_thresholds: [0.5, 0.8]
54+
parallel_evaluations: 4
55+
use_llm_feedback: false
56+
57+
# Evolution settings
58+
diff_based_evolution: false
59+
allow_full_rewrites: true # Definitely allow full rewrites
60+
max_code_length: 100000

openevolve/config.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class LLMModelConfig:
6464

6565
# Generation parameters
6666
system_message: Optional[str] = None
67-
temperature: float = None
68-
top_p: float = None
67+
temperature: float | None = None
68+
top_p: float | None = None
6969
max_tokens: int = None
7070

7171
# Request parameters
@@ -93,8 +93,8 @@ class LLMConfig(LLMModelConfig):
9393

9494
# Generation parameters
9595
system_message: Optional[str] = "system_message"
96-
temperature: float = 0.7
97-
top_p: float = 0.95
96+
temperature: float | None = 0.7
97+
top_p: float | None = None
9898
max_tokens: int = 4096
9999

100100
# Request parameters
@@ -425,10 +425,21 @@ def from_dict(cls, config_dict: Dict[str, Any]) -> "Config":
425425
except re.error as e:
426426
raise ValueError(f"Invalid regex pattern in diff_pattern: {e}")
427427

428+
# Remove None values for temperature and top_p to avoid dacite type errors;
429+
# alternatively, pass check_types=False to dacite.from_dict, but that can hide other issues
430+
if "llm" in config_dict:
431+
if "temperature" in config_dict["llm"] and config_dict["llm"]["temperature"] is None:
432+
del config_dict["llm"]["temperature"]
433+
if "top_p" in config_dict["llm"] and config_dict["llm"]["top_p"] is None:
434+
del config_dict["llm"]["top_p"]
435+
428436
config: Config = dacite.from_dict(
429437
data_class=cls,
430438
data=config_dict,
431-
config=dacite.Config(cast=[List, Union], forward_references={"LLMInterface": Any}),
439+
config=dacite.Config(
440+
cast=[List, Union],
441+
forward_references={"LLMInterface": Any},
442+
),
432443
)
433444

434445
if config.database.random_seed is None and config.random_seed is not None:

0 commit comments

Comments
 (0)