Skip to main content

EvolutionaryGenome

Trait EvolutionaryGenome 

Source
pub trait EvolutionaryGenome:
    Clone
    + Send
    + Sync
    + Serialize
    + DeserializeOwned
    + 'static {
    type Allele: Clone + Send;
    type Phenotype;

    // Required methods
    fn to_trace(&self) -> Trace;
    fn from_trace(trace: &Trace) -> Result<Self, GenomeError>;
    fn decode(&self) -> Self::Phenotype;
    fn dimension(&self) -> usize;
    fn generate<R: Rng>(rng: &mut R, bounds: &MultiBounds) -> Self;

    // Provided methods
    fn as_slice(&self) -> Option<&[Self::Allele]> { ... }
    fn as_mut_slice(&mut self) -> Option<&mut [Self::Allele]> { ... }
    fn distance(&self, _other: &Self) -> f64 { ... }
    fn trace_prefix() -> &'static str { ... }
}
Expand description

Core genome abstraction with Fugue integration for evolutionary algorithms.

This trait defines the interface for evolvable solution representations, with explicit Fugue trace integration for probabilistic operations. Genomes must be cloneable, serializable, and thread-safe.

§Fugue Integration

The key insight is that Fugue’s traces can represent genomes. Each gene is stored at an indexed address, enabling:

  • Trace-based mutation (selective resampling)
  • Trace-based crossover (merging parent traces)
  • Probabilistic interpretation of genetic operators

Required Associated Types§

Source

type Allele: Clone + Send

The allele type for individual genes

Source

type Phenotype

The phenotype or decoded solution type

Required Methods§

Source

fn to_trace(&self) -> Trace

Convert genome to Fugue trace for probabilistic operations.

Each gene is stored at an indexed address (e.g., “gene#0”, “gene#1”, …), enabling trace-based evolutionary operators.

Source

fn from_trace(trace: &Trace) -> Result<Self, GenomeError>

Reconstruct genome from Fugue trace after evolutionary operations.

This is the inverse of to_trace(), extracting gene values from the trace’s choice map.

Source

fn decode(&self) -> Self::Phenotype

Decode genome into phenotype for fitness evaluation

Source

fn dimension(&self) -> usize

Compute dimensionality for adaptive operators

Source

fn generate<R: Rng>(rng: &mut R, bounds: &MultiBounds) -> Self

Generate a random genome within the given bounds

Provided Methods§

Source

fn as_slice(&self) -> Option<&[Self::Allele]>

Get the genome’s genes as a slice (for numeric genomes)

Source

fn as_mut_slice(&mut self) -> Option<&mut [Self::Allele]>

Get the genome’s genes as a mutable slice (for numeric genomes)

Source

fn distance(&self, _other: &Self) -> f64

Distance metric between two genomes (default: 0.0)

Source

fn trace_prefix() -> &'static str

Get the address prefix used for trace storage (default: “gene”)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§