Class: Wallace::Operators::ReverseSequenceMutationOperator
- Inherits:
-
Wallace::Operator
- Object
- Wallace::Operator
- Wallace::Operators::ReverseSequenceMutationOperator
- Defined in:
- lib/operators/reverse_sequence_mutation_operation.rb
Overview
The reverse sequence mutation operator takes an individual and reverses the order of all its genes between two loci i and j, where i < j.
Instance Method Summary collapse
Methods inherited from Wallace::Operator
Constructor Details
This class inherits a constructor from Wallace::Operator
Instance Method Details
#operate(rng, inputs) ⇒ Object
7 8 9 10 11 |
# File 'lib/operators/reverse_sequence_mutation_operation.rb', line 7 def operate(rng, inputs) i, j = (0...inputs[0].length).to_a.sample(2).sort inputs[0][i..j] = inputs[0][i..j].reverse return inputs end |