Trait Specimen

Source
pub trait Specimen {
    // Required methods
    fn params(&self) -> &[f64];
    fn cmp_cost(&self, other: &Self) -> Ordering;

    // Provided method
    fn params_dist(&self, other: &Self) -> f64 { ... }
}
Expand description

Specimen in evolutionary process.

Two methods are required to be implemented:

  • The params method needs to return the parameters originally used to create the specimen (see constructor argument to function Solver::new).
  • The cmp_cost method compares specimen by their fitness (lower cost values are better).

For most cases, the module provides a BasicSpecimen which is an implementation only storing the params and cost values.

Required Methods§

Source

fn params(&self) -> &[f64]

Parameters used for creation.

Source

fn cmp_cost(&self, other: &Self) -> Ordering

Compare specimen’s fitness (Less means better).

Provided Methods§

Source

fn params_dist(&self, other: &Self) -> f64

Euclidean distance between two specimens’ parameters

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§