A population is a collection of candidate solutions maintained together during evolutionary optimization. Its value lies not only in fitness, but also in preserving diversity so evolution can adapt to change. section 2.4.4
A simple genetic-algorithm population uses a NumPy tensor: each row is an individual represented by an n-dimensional gene vector, while tensor dimensions specify population and gene counts. section 2.5.3
Listing 2.14 EDL_2_5_Genetic_Algorithms.ipynb: Creating the population
population = 100 #1 genes = 100 #2 generations = 100 #3 pop = np.random.randint(0,2, size=(population,genes)) #4 print(pop) ======================== [[0 1 1 ... 1 0 0] #5 [1 1 0 ... 1 1 0] [1 0 0 ... 1 0 1] ... [1 0 1 ... 0 0 1] [1 0 0 ... 0 1 0] [1 0 0 ... 0 0 1]]
Inspect the executable construction of a 100-by-100 binary population and the row-wise individual representation. section 2.5.3
A population participates in the genetic-algorithm cycle by:
- Calculating fitness for every individual. section 2.5.8
- Selecting parents, producing children through crossover, and applying mutation. section 2.5.8
- Replacing the current generation and inspecting maximum, minimum, mean, and standard-deviation fitness across the population. section 2.5.8
One-max evolution
A binary population evolves for 100 generations while histograms and fitness statistics track collective progress; one run reaches maximum fitness 98, with mean fitness 93.21. section 2.5.8








