pub trait ReplacementStrategy<C: Chromosome>: Send + Sync {
// Required method
fn replace(
&self,
population: &Population<C>,
encoder: Arc<dyn Fn() -> Genotype<C> + Send + Sync>,
) -> Genotype<C>;
}Expand description
Trait for replacement strategies in the algorithms.
This trait defines a method for replacing a member of the Population with a new individual after the current individual has been determined to be invalid. Typically, this is done by replacing the individual with a new one generated by the encoder. But in some cases, it may be desirable to replace the individual in a different way, such as by sampling from the Population.
Required Methods§
fn replace( &self, population: &Population<C>, encoder: Arc<dyn Fn() -> Genotype<C> + Send + Sync>, ) -> Genotype<C>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".