rlevo_evolution/algorithms/gep/mod.rs
1//! Gene Expression Programming (GEP).
2//!
3//! GEP (Ferreira, 2001) evolves programs encoded as **fixed-length linear
4//! chromosomes** that decode into expression trees. Each chromosome is a `head`
5//! (whose loci may hold any symbol) followed by a `tail` (terminals only),
6//! sized so that *every* chromosome respecting that split decodes to a complete
7//! tree — no repair pass is ever needed. This makes the genetic operators
8//! simple, position-aligned array edits, which is GEP's headline advantage over
9//! tree-based GP.
10//!
11//! # Module map
12//!
13//! - [`config`] — [`GepConfig`]: runtime head/tail/population parameters; the
14//! tail length is derived and the head/tail constraint asserted at construction.
15//! - [`alphabet`] — [`Alphabet`] and [`SymbolKind`]: the function set plus the
16//! variable/constant terminal layer, with the contiguous id-space and the
17//! tail [`terminal_range`](Alphabet::terminal_range).
18//! - [`tree`] — [`ExpressionTree`]: the level-order decoded phenotype with
19//! `eval`/`depth`/`node_count`.
20//! - [`decode`] — [`GenotypePhenotypeMap`] and [`GepDecoder`]: the deterministic
21//! ORF-scan + BFS decoder.
22//! - [`operators`] — point mutation (locus-class aware), IS/RIS transposition,
23//! and one-/two-point crossover, all valid by construction.
24//! - [`strategy`] — [`GepStrategy`], [`GepState`], and the [`GepSymRegression`]
25//! fitness function.
26//!
27//! Genotype storage is a `Tensor<B, 2, Int>` of shape `(pop_size, head_len +
28//! tail_len)`; decoding and evaluation run host-side, per chromosome, because
29//! the decode is an inherently sequential ORF scan that does not vectorise.
30//!
31//! # Reference
32//!
33//! - Ferreira (2001), *Gene Expression Programming: a New Adaptive Algorithm
34//! for Solving Problems*, Complex Systems 13(2).
35
36pub mod alphabet;
37pub mod config;
38pub mod decode;
39pub mod operators;
40pub mod strategy;
41pub mod tree;
42
43pub use alphabet::{Alphabet, SymbolKind};
44pub use config::GepConfig;
45pub use decode::{GenotypePhenotypeMap, GepDecoder};
46pub use strategy::{GepState, GepStrategy, GepSymRegression};
47pub use tree::ExpressionTree;