pub trait Terminal:
Clone
+ Send
+ Sync
+ PartialEq
+ Debug
+ Serialize
+ for<'de> Deserialize<'de>
+ 'static {
// Required methods
fn random<R: Rng>(rng: &mut R) -> Self;
fn terminals() -> &'static [Self];
fn evaluate(&self, variables: &[f64]) -> f64;
fn to_string(&self) -> String;
fn encode(&self) -> (f64, f64);
fn decode(type_code: f64, payload: f64) -> Self;
}Expand description
Trait for terminal nodes in GP trees
Required Methods§
Sourcefn evaluate(&self, variables: &[f64]) -> f64
fn evaluate(&self, variables: &[f64]) -> f64
Evaluate this terminal with the given variable bindings
Sourcefn encode(&self) -> (f64, f64)
fn encode(&self) -> (f64, f64)
Encode this terminal as a (type_code, payload) pair for lossless trace
round-tripping.
type_code identifies the terminal variant (a discriminant) and
payload carries its associated value. The pair must satisfy the
inverse relationship Self::decode(self.encode()) == *self so that
TreeGenome::from_trace
reproduces the exact terminal that
TreeGenome::to_trace
serialized.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".