fugue_evo/inference/mod.rs
1//! Evolution as inference: the PPL-native layer (requires the `ppl` feature)
2//!
3//! This module makes "evolutionary algorithms as probabilistic programs"
4//! literal. Given a fitness `f` and a prior *program* `p(x)` over genomes
5//! (a [`prior::GenomePrior`] — any fugue `Model<G>`), the Boltzmann/Gibbs
6//! posterior
7//!
8//! ```text
9//! π_β(x) ∝ p(x) · exp(β · f(x))
10//! ```
11//!
12//! is itself a fugue program (`prior.model().bind(|g| factor(β·f(g)))`), and
13//! every sampler here is fugue's own inference machinery run against it:
14//!
15//! - [`model::EvolutionModel`] assembles the target program; all densities are
16//! obtained by running/replaying it (no hand-written density code).
17//! - [`mh::EvolutionChain`] delegates to `fugue::adaptive_single_site_mh` —
18//! typed proposals move every site kind (Bool/U64/Usize/I64/F64), fixing the
19//! historical F64-only dead-chain bug.
20//! - [`smc::EvolutionSMC`] delegates to `fugue::adaptive_smc_with_kernel`:
21//! adaptive likelihood-tempering (β applied exactly once), ESS-driven
22//! resampling, per-particle MH rejuvenation, an optional population-coupled
23//! crossover kernel, and an unbiased log-evidence estimate.
24//! - [`bayesian_ga::BayesianAdaptiveGA`] keeps the Thompson-sampling operator
25//! selection (conjugate Beta/Gamma posteriors, now backed by `rand_distr`).
26//!
27//! [`effect_handlers`] retains the genuine `fugue::Handler` implementations
28//! (`TraceScoringHandler`, `RecordingHandler`) and the operator observation
29//! hooks; [`trace_operators`] retains the value-level trace operators.
30//!
31//! See `examples/bayesian_evolution.rs` for an end-to-end pipeline.
32
33pub mod bayesian_ga;
34pub mod effect_handlers;
35pub mod grammar;
36pub mod likelihood;
37pub mod mh;
38pub mod model;
39pub mod pareto;
40pub mod prior;
41pub mod smc;
42pub mod trace_operators;
43
44pub mod prelude {
45 pub use super::bayesian_ga::*;
46 pub use super::effect_handlers::*;
47 pub use super::grammar::*;
48 pub use super::likelihood::*;
49 pub use super::mh::*;
50 pub use super::model::*;
51 pub use super::pareto::*;
52 pub use super::prior::*;
53 pub use super::smc::*;
54 pub use super::trace_operators::*;
55}