pub trait FitnessValue:
PartialOrd
+ Clone
+ Send
+ Sync
+ Debug
+ Serialize
+ DeserializeOwned
+ 'static {
// Required methods
fn to_f64(&self) -> f64;
fn is_better_than(&self, other: &Self) -> bool;
// Provided methods
fn is_worse_than(&self, other: &Self) -> bool { ... }
fn cmp_by_quality(&self, other: &Self) -> Ordering { ... }
}Expand description
Trait bound for fitness values
Fitness values must be comparable and convertible to f64 for probabilistic selection operations. They must also be serializable for checkpointing.
Required Methods§
Sourcefn is_better_than(&self, other: &Self) -> bool
fn is_better_than(&self, other: &Self) -> bool
Check if this fitness is better than another
Provided Methods§
Sourcefn is_worse_than(&self, other: &Self) -> bool
fn is_worse_than(&self, other: &Self) -> bool
Check if this fitness is worse than another
Sourcefn cmp_by_quality(&self, other: &Self) -> Ordering
fn cmp_by_quality(&self, other: &Self) -> Ordering
Total ordering by quality, where Ordering::Greater means self is
the better individual.
This delegates to is_better_than for
the quality comparison (never to a to_f64()-derived scalar, which can
disagree with the true ordering — see the ParetoFitness case where
infinite crowding distances collapse every rank to +inf). Any value
whose to_f64() is NaN is ranked strictly worst, so the result is a
genuine total order usable with max_by/min_by/sort_by even if a
NaN fitness slips past Individual::set_fitness’s guard (defense in
depth).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".