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§
Required Methods§
Sourcefn to_trace(&self) -> Trace
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.
Sourcefn from_trace(trace: &Trace) -> Result<Self, GenomeError>
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.
Sourcefn generate<R: Rng>(rng: &mut R, bounds: &MultiBounds) -> Self
fn generate<R: Rng>(rng: &mut R, bounds: &MultiBounds) -> Self
Generate a random genome within the given bounds
Provided Methods§
Sourcefn as_slice(&self) -> Option<&[Self::Allele]>
fn as_slice(&self) -> Option<&[Self::Allele]>
Get the genome’s genes as a slice (for numeric genomes)
Sourcefn as_mut_slice(&mut self) -> Option<&mut [Self::Allele]>
fn as_mut_slice(&mut self) -> Option<&mut [Self::Allele]>
Get the genome’s genes as a mutable slice (for numeric genomes)
Sourcefn trace_prefix() -> &'static str
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.