Evolve Python algorithms and programs using LLMs as mutation operators combined with MAP-Elites quality-diversity search, achieving competitive results on geometric optimization and algorithmic problems by iteratively mutating code informed by historical performance and lineage context.
Evolve Python algorithms and programs using LLMs as mutation operators combined with MAP-Elites quality-diversity search, achieving competitive results on geometric optimization and algorithmic problems by iteratively mutating code informed by historical performance and lineage context.
GigaEvo: LLM-Driven Evolutionary Optimization
Rather than optimizing neural network weights, this skill demonstrates how to evolve entire programs and algorithms using large language models as intelligent mutation operators. GigaEvo combines evolutionary computation (MAP-Elites quality-diversity algorithm) with LLM-based code generation, enabling discovery of novel algorithms for geometric optimization, combinatorial problems, and other domains where explicit algorithms may outperform learned models.
The core innovation is using LLMs not for inference, but as mutation operators that generate improved algorithm variants by analyzing parent code, performance metrics, and historical context about what changes succeeded.
Core Concept
GigaEvo implements an evolutionary framework where:
Population Management: Python programs stored with their metrics and lineage information in a database
Evolutionary Engine: MAP-Elites algorithm maps solutions to a behavior space based on fitness and behavioral features
Mutation via LLM: LLMs generate offspring code by analyzing parent implementations, metrics, and historical mutations
Fitness Evaluation: Programs are executed and evaluated on benchmark tasks (geometric optimization, bin packing, etc.)
The system tracks bidirectional lineage (parent→offspring and offspring→parent) to enable context-aware code generation.
Architecture Overview
Redis Database: Stores evolutionary units with code, metrics, fitness scores, and lineage pointers
DAG Execution Engine: Asynchronously processes programs through validation, complexity analysis, and evaluation stages
MAP-Elites Quality-Diversity: Maintains diverse, high-performing solutions across behavior space dimensions
LangGraph Mutation Agent: Constructs rich context from parent code and generates improved variants
Metrics Tracking: Historical performance data to guide evolution direction
Implementation Steps
The evolutionary process cycles through population initialization, evaluation, and mutation stages.
1. Initialize Population and Behavior Space
Create initial population of random programs and define the behavior space dimensions.
definitialize_giga_evo(task_domain, population_size=100):
"""
Initialize the evolutionary population with random programs.
Sets up the behavior space for quality-diversity optimization.
"""
population = []
idx (population_size):
task_domain == :
program = generate_random_geometric_algorithm()
task_domain == :
program = generate_random_packing_algorithm()
individual = {
: ,
: program,
: ,
: ,
: {: [], : []},
: {}
}
population.append(individual)
behavior_space = {
: (, ),
: (, ),
: (, )
}
population, behavior_space
# Generate random initial programs
for
in
range
if
"geometric"
elif
"bin_packing"
'id'
f'ind_{idx}'
'code'
'fitness'
None
'behavior'
None
'lineage'
'ancestors'
'descendants'
'metrics'
# Define behavior space dimensions (e.g., runtime, solution quality)
'fitness_dim'
0
100
# Quality score
'efficiency_dim'
0
1
# Normalized runtime
'complexity_dim'
0
50
# Code complexity
return
2. Execute and Evaluate Programs
Run each program on benchmark tasks and collect fitness, behavior, and metric data.
Domains where interpretability is not a goal (gradient descent may be simpler)
Key Hyperparameters:
mutation_prompt_quality: Richer context → better mutations, but higher latency
population_size: Larger population enables better quality-diversity tradeoff (100-500 typical)
num_generations: Usually 30-100 generations sufficient for convergence
task_timeout: Prevent infinite loops; 5-10 seconds typical for small instances
Cost Optimization:
Use smaller LLM models for mutations (70-80% of large model quality at 1/10 cost)
Batch-evaluate programs in parallel using executor DAG
Cache successfully mutated patterns to reduce redundant LLM calls
Integration with RL:
Evolved algorithms can be evaluated in multi-agent benchmarks or used as baseline policies in environments. Combine with imitation learning to distill evolved algorithms into neural policies.