EvoX
Co-evolves the search strategy with the solutions: the parent/context selection policy is itself LLM-written code, scored by windowed improvement and hot-swapped on stagnation.
"""EvoX seed search strategy S0 — uniform-random parent + uniform-random inspirations.
This module is the GENOME of the meta-loop: the scaffold reads this file as TEXT (the meta-LLM
rewrites its source) AND executes it (the class becomes the active search strategy). Port of
SkyDiscover's ``search/evox/database/initial_search_strategy.py`` translated to galapagos Genomes.
It must import only from galapagos and the Python standard library, and everything evolvable lives
inside the EVOLVE-BLOCK markers.
"""
# EVOLVE-BLOCK-START
from galapagos.records import Genome
from galapagos.scaffolds.evox.strategy import StrategyBase
class EvolvedStrategy(StrategyBase):
"""Initial search strategy: plain insert + uniform-random parent and inspirations."""
def add(self, genome: Genome, iteration=None, **kwargs) -> str:
"""Add a genome to the population."""
self.genomes[genome.id] = genome
self._update_best(genome)
return genome.id
def sample(self, num_context_programs=4, **kwargs):
"""Pick a random parent and a set of random context genomes (free-form label)."""
candidates = list(self.genomes.values())
if len(candidates) == 0:
raise ValueError("No candidates available for sampling")
parent = self.rng.choice(candidates)
sample_size = min(num_context_programs + 1, len(candidates))
examples = self.rng.sample(candidates, sample_size)
examples = [g for g in examples if g.id != parent.id][:num_context_programs]
return {"": parent}, {"": examples}
# EVOLVE-BLOCK-END