@ Override protected MutatorResult < Chromosome < G > > mutate ( final Chromosome < G > chromosome , final double p , final Random random ) { final MutatorResult < Chromosome < G > > result ; if ( chromosome . length ( ) > 1 ) { final MSeq < G > genes = chromosome . toSeq ( ) . copy ( ) ; final int mutations = ( int ) indexes ( random , genes . length ( ) , p ) . peek ( i -> genes . swap ( i , random . nextInt ( genes . length ( ) ) ) ) . count ( ) ; result = MutatorResult . of ( chromosome . newInstance ( genes . toISeq ( ) ) , mutations ) ; } else { result = MutatorResult . of ( chromosome ) ; } return result ; }
Swaps the genes in the given array with the mutation probability of this mutation .