Generates an initial population for a genetic algorithm (GA). Each individual is a binary chromosome represented by a numeric vector containing 0 and 1.
Value
A numeric matrix with npop rows and nbits columns containing only 0 and 1. Each row corresponds to one chromosome.
Examples
create.pop(npop = 10, nbits = 12)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
#> [1,] 1 1 0 0 1 1 1 1 0 0 0 1
#> [2,] 1 0 1 0 1 0 0 1 1 0 0 0
#> [3,] 0 0 0 1 1 0 1 0 0 1 1 1
#> [4,] 0 0 1 0 0 0 0 1 1 0 1 1
#> [5,] 1 1 0 0 1 1 0 0 0 1 1 1
#> [6,] 1 1 1 1 1 0 1 0 1 1 1 1
#> [7,] 0 1 0 1 1 0 0 0 0 1 1 1
#> [8,] 0 0 0 1 0 0 1 0 1 0 0 1
#> [9,] 0 0 1 1 1 0 1 1 1 1 1 1
#> [10,] 1 1 0 0 0 0 0 0 0 1 0 1