Skip to main content

CrossoverOperator

Trait CrossoverOperator 

Source
pub trait CrossoverOperator<T, Q = f64>: Operator
where T: Clone, Q: Clone,
{ // 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§

Source

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 solution
  • parent2 - Second parent solution
  • bounds - Optional solution-space bounds for bounded real-valued operators
  • rng - Random generator provided by the algorithm
§Returns

A vector of offspring solutions (typically 1 or 2)

Provided Methods§

Source

fn execute_several( &self, parents: Vec<Solution<T, Q>>, bounds: Option<&RealBounds>, _rng: &mut Random, ) -> Vec<Solution<T, Q>>

Applies crossover to several parent solutions and returns offspring.

§Arguments
  • parents - Vector of parent solutions
  • rng - Random generator provided by the algorithm
§Returns

A vector of offspring solutions (typically 1 or 2)

Source

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".

Implementors§