The mating algorithm
We have a population of animals. Each individual can be associated with a certain "value", expressing his "fit level to the environment". We want to design a simple algorithm in the animal's genes that would make the individuals to mate close to optimal. Let's say that resulting value for the mating is the product of the "value" of the two involved individuals. We will study the case when each individual can only be involved in mating with a single other individual. In this conditions, the close to optimum mating is reached when mating is realized between individuals with very close values. Mathematically, we have a set of positive numbers (the values) and we want to create the pairs of numbers so that the sum of products of each pair will be maximal. This happens when we sort the numbers and we pair each number with the one next to it.