Expand description
§fugue-evo
A Probabilistic Genetic Algorithm Library for Rust.
This library implements genetic algorithms through the lens of probabilistic programming, treating evolution as Bayesian inference over solution spaces. It integrates with fugue-ppl for trace-based evolutionary operators.
§Features
- Multiple Algorithms: SimpleGA, CMA-ES, NSGA-II, Island Model, EDA, Interactive GA
- Flexible Genomes: RealVector, BitString, Permutation, TreeGenome
- Modular Operators: Pluggable selection, crossover, and mutation operators
- Adaptive Hyperparameters: Bayesian learning of mutation rates and other parameters
- Production Ready: Checkpointing, parallel evaluation, WASM support
§Core Concepts
- Fitness as Likelihood: Selection pressure maps directly to Bayesian conditioning
- Learnable Operators: Automatic inference of optimal hyperparameters using conjugate priors
- Trace-Based Evolution: Deep Fugue integration enables novel probabilistic operators
- Type Safety: Compile-time guarantees via Rust’s type system
§Quick Start
Add to your Cargo.toml:
[dependencies]
fugue-evo = "0.1"
rand = "0.8"Basic optimization example:
ⓘ
use fugue_evo::prelude::*;
use rand::rngs::StdRng;
use rand::SeedableRng;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut rng = StdRng::seed_from_u64(42);
// Define search bounds: 10 dimensions in [-5.12, 5.12]
let bounds = MultiBounds::symmetric(5.12, 10);
// Run optimization
let result = SimpleGABuilder::<RealVector, f64, _, _, _, _, _>::new()
.population_size(100)
.bounds(bounds)
.selection(TournamentSelection::new(3))
.crossover(SbxCrossover::new(20.0))
.mutation(PolynomialMutation::new(20.0))
.fitness(Sphere::new(10))
.max_generations(200)
.build()?
.run(&mut rng)?;
println!("Best fitness: {:.6}", result.best_fitness);
Ok(())
}§Module Overview
algorithms: Optimization algorithms (SimpleGA, CMA-ES, NSGA-II, Island Model)genome: Genome types and theEvolutionaryGenometraitoperators: Selection, crossover, and mutation operatorsfitness: Fitness traits and benchmark functionspopulation: Population management and individual typestermination: Stopping criteria (max generations, target fitness, stagnation)hyperparameter: Adaptive and Bayesian hyperparameter tuninginteractive: Human-in-the-loop evolutionary optimizationcheckpoint: State serialization for pause/resumefugue_integration: Trace operators and effect handlers
§Examples
See the examples/ directory for complete examples:
sphere_optimization.rs: Basic continuous optimizationrastrigin_benchmark.rs: Multimodal function optimizationcma_es_example.rs: CMA-ES algorithm usageisland_model.rs: Parallel island evolutionhyperparameter_learning.rs: Bayesian parameter adaptationsymbolic_regression.rs: Genetic programmingcheckpointing.rs: Save/restore evolution stateinteractive_evolution.rs: Human-in-the-loop optimization
Modules§
- algorithms
- Evolutionary algorithms
- checkpoint
- Checkpointing support for evolution state persistence
- diagnostics
- Diagnostics and statistics
- error
- Error types for fugue-evo
- fitness
- Fitness evaluation and benchmarks
- fugue_
integration - Fugue PPL Integration
- genome
- Genome abstractions and implementations
- hyperparameter
- Hyperparameter adaptation mechanisms
- interactive
- Interactive Genetic Algorithm (IGA) module
- operators
- Genetic operators
- population
- Population management
- prelude
- Prelude module for convenient imports
- termination
- Termination criteria