Fitness is the numerical score assigned to an individual candidate to express how well it survives, performs, or solves the target problem. In evolutionary computation, this score is the basis for judging a population's success and deciding which individuals are preferable for reproduction. section 1.1.1 section 2.6
A fitness function turns the goal into a calculation. It may maximize a desirable quantity, minimize a cost, or transform a measured result so that the evolutionary setup can rank candidates consistently. The choice of direction matters: a genetic algorithm can maximize the count of desired genes, while another setup minimizes path distance or uses inverse accuracy as fitness. section 2.5.4 section 3.3.1 section 7.5
A practical evaluation loop has three parts:
- Represent each candidate with the traits, genes, path indices, network architecture, or program that evolution will vary. section 2.4.1 section 3.3.1
- Evaluate the candidate against a concrete target and return its numerical fitness. section 2.6 section 10.2
- Use the resulting scores during selection, then reevaluate offspring after crossover and mutation. section 2.4.1 section 2.6
Max-one fitness
For a binary chromosome, fitness can be the sum of its genes. Maximizing that sum drives the population toward an individual whose genes are all 1. With 100 binary genes, the ideal score is 100; a histogram of initial scores makes the randomized population visible before evolution proceeds. section 2.5.4
Fitness can combine task-specific measurements
A route evaluator sums the distances along a closed path, making total path length the score. A DCGAN evaluator derives partial values from real, generated, and fake losses, then averages them. For an evolved CNN, accuracy is clamped and inverted so lower fitness corresponds to better accuracy. section 3.3.1 section 9.5 section 7.5
Listing 2.15 EDL_2_5_Genetic_Algorithms.ipynb: Calculating fitness
fitness = np.sum(pop,axis=1) #1 plt.hist(fitness)
This compact NumPy calculation shows a fitness function directly: sum each population row to score every binary individual, then plot the score distribution. section 2.5.4





