concept fitness in category AI

This is an excerpt from Manning's book Grokking Artificial Intelligence Algorithms.
Selection—A mechanism that measures the fitness of individuals. Stronger individuals have the highest likelihood of survival (survival of the fittest).
These properties imply that the following things happen during the process of evolution (figure 4.3):
In our example, the solution attempts to maximize the value of the items in the knapsack while respecting the weight-limit constraints. The fitness function measures the total value of the items in the knapsack for each individual. The result is that individuals with higher total values are more fit. Note that an invalid individual appears in figure 4.17, to highlight that its fitness score would result in 0—a terrible score, because it exceeds the weight capacity for this instance of the problem, which is 6,404,180.
Figure 4.17 Measuring the fitness of individuals
![]()
Depending on the problem being solved, the result of the fitness function may be required to be minimized or maximized. In the Knapsack Problem, the contents of the knapsack can be maximized within constraints, or the empty space in the knapsack could be minimized. The approach depends on the interpretation of the problem.