1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Fugue PPL integration: evolution as inference over the Boltzmann posterior
//!
//! This module makes the "evolution as Bayesian inference" story load-bearing
//! rather than ornamental. Given a fitness function `f` and a prior `p` over
//! genomes, it targets the **Boltzmann / Gibbs posterior**
//!
//! ```text
//! π_β(x) ∝ p(x) · exp(β · f(x))
//! ```
//!
//! with real Fugue machinery:
//!
//! - [`evolution_model::EvolutionModel`] samples the prior by running a genuine
//! `fugue::Model` under a `PriorHandler`, and injects fitness as a likelihood
//! by running `factor(β·f(x))` through the [`effect_handlers::TraceScoringHandler`]
//! so the trace's `total_log_weight()` equals `β·f(x)`.
//! - [`evolution_model::EvolutionStep`] is a Metropolis–Hastings kernel invariant
//! for `π_β` (the prior's support — e.g. bounds — is honoured in the
//! acceptance ratio).
//! - [`evolution_model::EvolutionarySMC`] is a valid tempered Sequential Monte
//! Carlo sampler over a `β` ladder from `0` (prior) to `1` (posterior), using
//! incremental importance weights, ESS-triggered resampling, and MH
//! mutation/crossover rejuvenation.
//! - [`bayesian_ga::BayesianAdaptiveGA`] adapts its mutation operators with
//! genuine conjugate `Beta`/`Gamma` posteriors and Thompson sampling.
//!
//! # Effect handlers
//!
//! [`effect_handlers`] provides genuine `fugue::Handler` implementations
//! ([`effect_handlers::TraceScoringHandler`], [`effect_handlers::RecordingHandler`])
//! plus plain operation hooks for the trace-based operators. See that module for
//! the distinction.
//!
//! See `examples/bayesian_evolution.rs` for an end-to-end pipeline.