Module PermutationCrossover
In: lib/charlie/permutation/permutation.rb
  • One point partial preservation crossover for PermutationGenotype
  • Also known as partial recombination crossover (PRX).
  • Child 1 is identical to parent 1 up to the cross point, and contains the remaining elements in the same order as parent 2.

Methods

cross  

Public Instance methods

[Source]

    # File lib/charlie/permutation/permutation.rb, line 82
82:   def cross(parent1,parent2)
83:     p1, p2 = parent1.genes, parent2.genes
84:     cross_pt = rand(p1.size+1)
85:     st1, st2 =  p1[0...cross_pt],  p2[0...cross_pt]
86: 
87:     [ st1 + (p2 - st1), st2 + (p1 - st2) ].map{|x| from_genes(x) }
88:   end

[Validate]