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
47
48
49
50
51
52
53
54
55
//! Evolution as inference: the PPL-native layer (requires the `ppl` feature)
//!
//! This module makes "evolutionary algorithms as probabilistic programs"
//! literal. Given a fitness `f` and a prior *program* `p(x)` over genomes
//! (a [`prior::GenomePrior`] — any fugue `Model<G>`), the Boltzmann/Gibbs
//! posterior
//!
//! ```text
//! π_β(x) ∝ p(x) · exp(β · f(x))
//! ```
//!
//! is itself a fugue program (`prior.model().bind(|g| factor(β·f(g)))`), and
//! every sampler here is fugue's own inference machinery run against it:
//!
//! - [`model::EvolutionModel`] assembles the target program; all densities are
//! obtained by running/replaying it (no hand-written density code).
//! - [`mh::EvolutionChain`] delegates to `fugue::adaptive_single_site_mh` —
//! typed proposals move every site kind (Bool/U64/Usize/I64/F64), fixing the
//! historical F64-only dead-chain bug.
//! - [`smc::EvolutionSMC`] delegates to `fugue::adaptive_smc_with_kernel`:
//! adaptive likelihood-tempering (β applied exactly once), ESS-driven
//! resampling, per-particle MH rejuvenation, an optional population-coupled
//! crossover kernel, and an unbiased log-evidence estimate.
//! - [`bayesian_ga::BayesianAdaptiveGA`] keeps the Thompson-sampling operator
//! selection (conjugate Beta/Gamma posteriors, now backed by `rand_distr`).
//!
//! [`effect_handlers`] retains the genuine `fugue::Handler` implementations
//! (`TraceScoringHandler`, `RecordingHandler`) and the operator observation
//! hooks; [`trace_operators`] retains the value-level trace operators.
//!
//! See `examples/bayesian_evolution.rs` for an end-to-end pipeline.