Skip to main content

cut_and_splice

Function cut_and_splice 

Source
pub fn cut_and_splice<R: Rng>(
    parent1: &DynamicRealVector,
    parent2: &DynamicRealVector,
    rng: &mut R,
) -> Result<(DynamicRealVector, DynamicRealVector), GenomeError>
Expand description

Cut-and-splice crossover for variable-length real vectors.

Each parent is cut at an independent, uniformly chosen point; the head of one parent is spliced with the tail of the other (and vice versa), producing two children whose lengths may differ from both parents. Children are then repaired into the shared length window [min_length, max_length].

The children’s length constraints are the intersection of the parents’ constraints (max(min_length) .. min(max_length)); if that window is empty this returns GenomeError::InvalidStructure.