Mutate a binary population by flipping bits with probability pmut.
Details
Mutation is applied independently to each bit (gene). For each position, a Bernoulli trial with success probability pmut determines whether the bit is flipped (0 becomes 1, 1 becomes 0).
Examples
children.cross <- matrix(sample(0:1, 120, replace = TRUE), nrow = 10)
ga.mutation(children.cross, pmut = 0.1)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
#> [1,] 0 1 1 0 0 0 1 1 1 1 0 1
#> [2,] 1 1 1 0 1 0 0 0 1 0 1 1
#> [3,] 1 0 0 1 0 0 0 0 0 0 1 1
#> [4,] 1 1 0 1 1 1 1 0 1 0 1 0
#> [5,] 1 1 1 1 0 0 1 1 0 0 0 0
#> [6,] 1 1 1 1 1 0 0 0 1 1 0 1
#> [7,] 0 0 1 1 1 0 1 0 0 0 1 0
#> [8,] 0 1 0 0 1 1 0 1 1 1 1 0
#> [9,] 1 1 1 1 1 1 1 1 0 1 1 1
#> [10,] 1 1 1 1 1 1 0 0 1 1 0 0