pub trait CrossoverOperator<T, Q = f64>: Operator{
// Required method
fn execute(
&self,
parent1: &Solution<T, Q>,
parent2: &Solution<T, Q>,
bounds: Option<&RealBounds>,
rng: &mut Random,
) -> Vec<Solution<T, Q>>;
// Provided methods
fn execute_several(
&self,
parents: Vec<Solution<T, Q>>,
bounds: Option<&RealBounds>,
_rng: &mut Random,
) -> Vec<Solution<T, Q>> { ... }
fn number_of_offspring(&self) -> usize { ... }
}Expand description
Trait for crossover operators that combine two parent solutions.
§Type Parameters
T- Type of the solution variables
Required Methods§
Sourcefn execute(
&self,
parent1: &Solution<T, Q>,
parent2: &Solution<T, Q>,
bounds: Option<&RealBounds>,
rng: &mut Random,
) -> Vec<Solution<T, Q>>
fn execute( &self, parent1: &Solution<T, Q>, parent2: &Solution<T, Q>, bounds: Option<&RealBounds>, rng: &mut Random, ) -> Vec<Solution<T, Q>>
Applies crossover to two parent solutions and returns offspring.
§Arguments
parent1- First parent solutionparent2- Second parent solutionbounds- Optional solution-space bounds for bounded real-valued operatorsrng- Random generator provided by the algorithm
§Returns
A vector of offspring solutions (typically 1 or 2)
Provided Methods§
Sourcefn execute_several(
&self,
parents: Vec<Solution<T, Q>>,
bounds: Option<&RealBounds>,
_rng: &mut Random,
) -> Vec<Solution<T, Q>>
fn execute_several( &self, parents: Vec<Solution<T, Q>>, bounds: Option<&RealBounds>, _rng: &mut Random, ) -> Vec<Solution<T, Q>>
Sourcefn number_of_offspring(&self) -> usize
fn number_of_offspring(&self) -> usize
Returns the expected number of offspring produced by this operator
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".