Skip to main content

Crate fugue_evo

Crate fugue_evo 

Source
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

§Examples

See the examples/ directory for complete examples:

  • sphere_optimization.rs: Basic continuous optimization
  • rastrigin_benchmark.rs: Multimodal function optimization
  • cma_es_example.rs: CMA-ES algorithm usage
  • island_model.rs: Parallel island evolution
  • hyperparameter_learning.rs: Bayesian parameter adaptation
  • symbolic_regression.rs: Genetic programming
  • checkpointing.rs: Save/restore evolution state
  • interactive_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