Accord.Genetic.PermutationChromosome.Mutate C# (CSharp) Method

Mutate() public method

Mutation operator.

The method performs chromosome's mutation, swapping two randomly chosen genes (array elements).

public Mutate ( ) : void
return void
        public override void Mutate()
        {
            var rand = Generator.Random;

            ushort t;
            int j1 = rand.Next(length);
            int j2 = rand.Next(length);

            // swap values
            t = val[j1];
            val[j1] = val[j2];
            val[j2] = t;
        }