Module: Algorithm::Genetic::Mutation::Swap
- Defined in:
- lib/algorithm/genetic/mutation/swap.rb
Instance Method Summary collapse
Instance Method Details
#mutate(code) ⇒ Object
4 5 6 7 8 |
# File 'lib/algorithm/genetic/mutation/swap.rb', line 4 def mutate(code) i1, i2 = (rand * code.length).to_i, (rand * code.length).to_i code[i1], code[i2] = code[i2], code[i1] return code end |