class PermutationMutationStrategy

Public Instance Methods

perform_mutation(solution) click to toggle source
# File lib/gimuby/genetic/solution/mutation_strategy/permutation_mutation_strategy.rb, line 5
def perform_mutation(solution)
  permutation = solution.get_solution_representation
  begin
    index1 = rand(permutation.length)
    index2 = rand(permutation.length)
  end while index1 == index2
  tmp = permutation[index1]
  permutation[index1] = permutation[index2]
  permutation[index2] = tmp
  solution.set_solution_representation(permutation)
end