Skip to main content

Crate fugue_evo

Crate fugue_evo 

Source
Expand description

§fugue-evo

Evolutionary computation for Rust, in two layers:

  1. Classic EC (classic feature; standalone, no fugue dependency). SimpleGA, CMA-ES, NSGA-II, Island Model, Evolution Strategy, EDA/UMDA, SteadyState, the interactive GA, all operators, checkpointing, and the WASM surface. Compiles with --no-default-features --features std,parallel,checkpoint,classic with no probabilistic-programming dependency at all. Conversely, --features std,ppl builds the inference layer with no classic code.
  2. Evolutionary inference (ppl feature, on by default): evolutionary algorithms as probabilistic programs. The prior over genomes is a user-written fugue Model (a GenomePrior), fitness enters as factor(β·f(x)), so the Boltzmann posterior π_β(x) ∝ p(x)·exp(β·f(x)) is a fugue program — and every sampler is fugue’s own inference machinery: EvolutionChain (typed single-site MH), EvolutionSMC (adaptive tempered SMC with a population-coupled crossover kernel and a log-evidence estimate), ArithmeticGrammarPrior (genetic programming over a probabilistic grammar, where subtree mutation/crossover are generic trace moves), GenomeLikelihood (likelihoods as observation programs, with latent nuisance parameters jointly inferred), annealed optimizer mode (EvolutionSMC::anneal), and the Pareto posterior (ParetoScalarization — multi-objective optimization as inference).

The boundary between the layers is the TraceGenome extension trait: classic algorithms require only EvolutionaryGenome; genomes that also implement TraceGenome can be driven by the inference layer.

§Features

  • Multiple Algorithms: SimpleGA, CMA-ES, NSGA-II, Island Model, EDA, Interactive GA (standalone EC)
  • Flexible Genomes: RealVector, BitString, Permutation, TreeGenome
  • Modular Operators: Pluggable selection, crossover, and mutation operators
  • Adaptive Hyperparameters: opt-in Thompson-sampling tuning of operator parameters
  • Evolutionary inference (ppl): priors as programs, tempered SMC over the Boltzmann posterior, MH with typed proposals, symbolic regression as exact Bayesian inference
  • Production Ready: Checkpointing (bit-identical resume), parallel evaluation, WASM support

§Quick Start (classic optimization)

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);
    let bounds = MultiBounds::symmetric(5.12, 10);
    let result = SimpleGABuilder::real_valued()
        .population_size(100)
        .bounds(bounds)
        .fitness(Sphere::new(10))
        .max_generations(200)
        .build()?
        .run(&mut rng)?;
    println!("Best fitness: {:.6}", result.best_fitness);
    Ok(())
}

§Quick Start (evolution as inference, ppl)

use fugue_evo::prelude::*;

// Prior as a program; fitness as a likelihood factor; posterior by SMC.
let model = EvolutionModel::new(GaussianPrior::new(0.0, 2.0, DIM), fitness);
let posterior = EvolutionSMC::run(&mut rng, &model, EvoSmcConfig::default());
println!("posterior mean: {}", posterior.weighted_mean(0));
println!("log evidence:   {}", posterior.log_evidence);

§Module Overview

§Examples

  • sphere_optimization.rs, rastrigin_benchmark.rs, cma_es_example.rs, island_model.rs, symbolic_regression.rs (classic GP), checkpointing.rs, interactive_evolution.rs: the classic layer
  • bayesian_evolution.rs: the inference layer end-to-end (SMC + MH + adaptive GA)
  • symbolic_regression_inference.rs: flagship — symbolic regression as exact Bayesian inference over a probabilistic grammar

Re-exports§

pub use inference as fugue_integration;

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
genome
Genome abstractions and implementations
hyperparameter
Hyperparameter adaptation mechanisms
inference
Evolution as inference: the PPL-native layer (requires the ppl feature)
interactive
Interactive Genetic Algorithm (IGA) module
operators
Genetic operators
population
Population management
prelude
Prelude module for convenient imports
termination
Termination criteria