This project demonstrates a novel application of ShinkaEvolve to the meta-problem of evolving evolutionary algorithms themselves. Specifically, we use ShinkaEvolve's LLM-driven evolution to discover novel and effective selection strategies and diversity maintenance mechanisms for evolutionary algorithms.
- Meta-Level Evolution: Using evolution to improve evolution itself - a fascinating recursive application
- Novel Application Domain: Extends ShinkaEvolve beyond ML and optimization to algorithmic discovery
- Practical Value: Could discover selection strategies that outperform classical methods
- Scientific Insight: Reveals what makes evolutionary algorithms effective through automated discovery
Evolutionary algorithms (EAs) rely heavily on their selection mechanism - how they choose which solutions become parents of the next generation. Classical selection strategies include:
- Fitness-proportionate (roulette wheel)
- Tournament selection
- Rank-based selection
- Truncation selection
Each has trade-offs between:
- Exploitation (focusing on best solutions)
- Exploration (maintaining diversity)
- Convergence speed vs solution quality
- Generalization across different problem types
The challenge: Can we discover novel selection strategies that perform better than these classical approaches?
We evolve two key functions in initial.py:
-
select_parents(): The selection strategy that chooses which solutions reproduce- Input: population, fitness values, generation info
- Output: selected parent solutions
- Baseline: Simple fitness-proportionate selection
-
apply_diversity_mechanism(): Diversity maintenance strategy- Input: population, fitness values, generation info
- Output: modified population (with diversity adjustments)
- Baseline: No diversity mechanism (passthrough)
The evolved EA is evaluated on multiple benchmark optimization functions:
| Function | Characteristics | Difficulty |
|---|---|---|
| Sphere | Simple, unimodal, smooth | Easy |
| Rosenbrock | Narrow valley, curved ridge | Medium |
| Rastrigin | Many local optima, highly multimodal | Hard |
| Ackley | Many local minima, deep global minimum | Hard |
Each evolved strategy is tested across:
- Multiple problem dimensions (5D, 8D, 10D, 15D)
- Different population sizes (30-60 individuals)
- Various generation budgets (50-120 generations)
- Multiple random seeds for statistical robustness
Performance is measured by a combined score that balances multiple objectives:
Combined Score =
1.0 × mean_fitness (primary: solution quality)
+ 0.3 × convergence_bonus (faster is better)
+ 0.1 × diversity_bonus (maintain diversity)
- 0.05 × consistency_penalty (penalize high variance)
examples/evolve_ea/
├── README.md # This file
├── initial.py # Baseline EA with evolvable selection
├── evaluate.py # Evaluation script (integrates with ShinkaEvolve)
├── run_evo.py # Launch script for evolution
├── standalone_test.py # Test without full ShinkaEvolve install
├── test_initial.py # Basic functionality tests
└── improved_example.py # Example of a manually improved strategy
- Python 3.10+ (required by ShinkaEvolve)
- ShinkaEvolve installed (
pip install -e .from project root) - API keys for LLM providers (OpenAI, Anthropic, etc.)
Test the baseline implementation:
cd examples/evolve_ea
python3 standalone_test.pyThis runs the baseline EA on 3 benchmark functions and shows performance metrics.
cd examples/evolve_ea
python3 run_evo.py# From project root
shinka_launch variant=evolve_ea_experimentshinka_launch \
task=evolve_ea \
database=island_small \
evolution=small_budget \
evo_config.num_generations=30 \
evo_config.llm_models='["gpt-4-turbo-preview"]'The experiment can be customized via configs/variant/evolve_ea_experiment.yaml:
Evolution Parameters:
num_generations: Total evolution cycles (default: 30)max_parallel_jobs: Parallel evaluations (default: 2)patch_types: ["diff", "full"] - mutation strategiesllm_models: LLM models to use for code generation
Population Management:
num_islands: Parallel subpopulations (default: 2)archive_size: Elite programs per island (default: 20)parent_selection_strategy: "power_law", "weighted", or "beam_search"exploitation_ratio: Balance explore/exploit (default: 0.3)
Diversity Mechanisms:
code_embed_sim_threshold: Reject similar code (default: 0.85)max_novelty_attempts: Rejection sampling tries (default: 2)migration_interval: Cross-island migration frequency (default: 10)
After running, you'll find:
outputs/
└── shinka_evolve_ea_ea_evolution/
├── evolution_database.db # SQLite database with all programs
├── programs/ # Generated program files
│ ├── gen_0_prog_0.py
│ ├── gen_1_prog_0.py
│ └── ...
├── results/ # Evaluation results
│ ├── gen_0_prog_0/
│ │ ├── results.json
│ │ └── metrics.pkl
│ └── ...
└── meta_recommendations/ # High-level insights from LLM
- Best Program: Check
evolution_database.dbfor highest scoring program - Fitness History: Track improvement over generations
- Code Diff: Compare evolved code to baseline
- Performance Metrics: See
results.jsonfor detailed metrics
Use ShinkaEvolve's WebUI:
shinka_visualize --port 8888 --openFeatures:
- Real-time fitness tracking
- Genealogy tree of programs
- Code diff viewer
- Population diversity plots
The simple fitness-proportionate selection baseline achieves:
Mean Best Fitness: -29.81 (±28.93)
Mean Convergence: 97.92% of generations needed
Mean Diversity: 0.338
Combined Score: -31.22
Strengths:
- Simple and interpretable
- Works reasonably on easy problems (Sphere)
Weaknesses:
- Slow convergence (uses nearly all generations)
- High variance across problems
- Struggles with multimodal landscapes (Rastrigin)
- No explicit diversity maintenance
ShinkaEvolve-evolved strategies could discover:
-
Adaptive Selection Pressure
- Start with exploration (low pressure)
- Gradually increase exploitation
- Based on generation progress or convergence indicators
-
Hybrid Strategies
- Combine tournament and fitness-proportionate
- Switch based on problem characteristics
- Use fitness distribution statistics
-
Diversity-Aware Selection
- Penalize similar solutions
- Maintain population spread
- Balance fitness and novelty
-
Problem-Adaptive Mechanisms
- Detect landscape type (multimodal vs unimodal)
- Adjust strategy dynamically
- Use convergence rate as feedback
The code between # EVOLVE-BLOCK-START and # EVOLVE-BLOCK-END markers is evolved:
# EVOLVE-BLOCK-START
def select_parents(population, fitness, num_parents, generation, max_generations):
# This code will be modified by LLMs
# ...
return selected_parents
def apply_diversity_mechanism(population, fitness, generation, max_generations):
# This code will be modified by LLMs
# ...
return population, fitness
# EVOLVE-BLOCK-ENDEverything else remains fixed, ensuring:
- Consistent evaluation framework
- Fair comparison across strategies
- No changes to mutation/crossover operators
ShinkaEvolve uses two types of code mutations:
-
Diff Patches (60%):
- Small, targeted modifications
- Search-and-replace format
- Good for refining existing strategies
-
Full Rewrites (40%):
- Complete algorithm redesigns
- 5 prompt variants (different, motivated, structural, parametric)
- Good for exploration
The system prompt provides:
- Domain knowledge about evolutionary computation
- Successful selection strategies to consider
- Information about benchmark functions
- Guidelines for creating effective strategies
This enables the LLM to make informed, theoretically sound modifications.
Every 8 programs, ShinkaEvolve generates high-level insights:
Meta-Recommendation Example:
"Strategies using adaptive selection pressure (increasing over generations)
show 23% better performance on multimodal problems. Consider exploring
tournament selection variants with dynamic tournament size."
The population is divided into 2 islands that evolve independently:
- Prevents premature convergence to local optima
- Different islands explore different strategies
- Best programs migrate between islands every 10 generations
Code similarity checking prevents generating near-duplicates:
- Embeddings computed for all code blocks
- New code rejected if >85% similar to existing
- Encourages exploration of diverse strategies
-
Co-evolve Multiple Components
- Selection + mutation rate
- Selection + crossover strategy
- Full EA pipeline evolution
-
Multi-Objective Optimization
- Optimize for both speed and quality
- Pareto front of EA strategies
- User-selectable trade-offs
-
Transfer Learning
- Train on simple problems
- Test on complex real-world problems
- Measure generalization ability
-
Meta-Learning
- Learn to select EA strategy based on problem features
- Automatic algorithm configuration
- Portfolio of specialized strategies
-
Beyond Function Optimization
- Combinatorial problems (TSP, scheduling)
- Evolutionary robotics
- Neural architecture search
To test on different problems:
-
Add new benchmark functions in
initial.py:def my_function(x): return -complex_calculation(x)
-
Update test configs in
evaluate.py:{ 'benchmark_name': 'my_function', 'dim': 20, 'seed': 42, 'pop_size': 100, 'num_generations': 200, } -
Adjust fitness aggregation if needed
- Rich Search Space: Selection strategies have many design choices
- Clear Objective: Performance on benchmarks is unambiguous
- Fast Evaluation: Each EA run takes seconds to minutes
- Generalization: Multiple test problems ensure robustness
- LLM Knowledge: GPT-4 knows evolutionary computation theory
- Evaluation Cost: Each strategy requires multiple EA runs
- Variance: Stochastic algorithms need many seeds
- Overfitting: Risk of specializing to specific benchmarks
- Complexity: Selection interacts with other EA components
- Why fitness-proportionate baseline?: Simple, interpretable, room for improvement
- Why these benchmarks?: Standard in EC literature, diverse landscapes
- Why 6 test runs?: Balance between robustness and evaluation cost
- Why evolve selection separately?: Focused problem, clearer attribution
- Automated algorithm configuration (SMAC, irace)
- Hyper-heuristics: Evolving heuristics for optimization
- Meta-evolutionary algorithms: EAs that evolve EA parameters
- AlphaEvolve: Google's Gemini-powered algorithm evolution
- FunSearch: Discovering mathematical algorithms with LLMs
- AI Scientist v1/v2: Automated scientific discovery
- Open-source and accessible: Uses ShinkaEvolve framework
- Focuses on selection mechanisms: Often overlooked in AutoML
- Rigorous evaluation: Multiple benchmarks, statistical testing
- Transferable methodology: Can apply to other EA components
If you use this work, please cite:
@misc{evolve_ea_shinka2025,
title={Evolving Evolutionary Algorithms with ShinkaEvolve},
author={[Your Name]},
year={2025},
note={Extension of ShinkaEvolve framework for EA strategy discovery}
}
@article{lange2025shinka,
title={ShinkaEvolve: Towards Open-Ended And Sample-Efficient Program Evolution},
author={Lange, Robert Tjarko and Imajuku, Yuki and Cetin, Edoardo},
journal={arXiv preprint arXiv:2509.19349},
year={2025}
}This project builds on:
- ShinkaEvolve by Sakana AI
- Classical evolutionary computation research
- The broader AutoML and meta-learning communities
For questions, suggestions, or contributions:
- Open an issue on GitHub
- Submit a pull request
- Contact: [your contact info]
Note: This is a research prototype. Evolved strategies should be validated on additional problems before production use.