# Fitness function calculation In order to understand the fitness function, you first have to understand that a genetic algorithm

is one which changes over time (it evolves). In nature we have things like predators and harsh environments which eliminate unwanted specimens of animals (a slow zebra will get eaten by a lion). We need to simulate this behavior when programming genetic algorithms. The fitness function basically determines which possible solutions get passed on to multiply and mutate into the next generation of solutions. This is usually done by analyzing the "genes," which hold some data about a particular solution to the problem you are trying to solve. The fitness function will look at the genes and make some qualitative assessment, returning a fitness value for that solution. The rest of the genetic algorithm will discard any solutions with a "poor" fitness value and accept any with a "good" fitness value. In short: the goal of a fitness function is to provide a meaningful, measurable, and comparable value given a set of genes.
A fitness function is a particular type of objective function that is used to summaries, as a single figure of merit, how close a given design solution is to achieving the set aims. In particular, in the fields of genetic programming and genetic algorithms, each design solution is represented as a string of numbers (referred to as a chromosome). After each round of testing, or simulation, the idea is to delete the 'n' worst design solutions, and to breed 'n' new ones from the best design solutions. Each design solution, therefore, needs to be awarded a figure of merit, to indicate how close it came to meeting the overall specification, and this is generated by applying the fitness function to the test, or simulation, results obtained from that solution. The reason that genetic algorithms are not a lazy way of performing design work is precisely because of the effort involved in designing a workable fitness function. Even though it is no longer the human designer, but the computer, that comes up with the final design, it is the human designer who has to design the fitness function. If this is designed wrongly, the algorithm will either converge on an inappropriate solution, or will have difficulty converging at all. Moreover, the fitness function must not only correlate closely with the designer's goal, it must also be computed quickly. Speed of execution is very important, as a typical genetic algorithm must be iterated many times in order to produce a usable result for a non-trivial problem. Fitness approximation may be appropriate, especially in the following cases:

  

Fitness computation time of a single solution is extremely high Precise model for fitness computation is missing The fitness function is uncertain or noisy.

Two main classes of fitness functions exist: one where the fitness function does not change, as in optimizing a fixed function or testing with a fixed set of test cases; and one where the fitness function is mutable, as in niche differentiation or co-evolving the set of test cases. Another way of looking at fitness functions is in terms of a fitness landscape, which shows the fitness for each possible chromosome. Definition of the fitness function is not straightforward in many cases and often is performed iteratively if the fittest solutions produced by GA are not what is desired. In some cases, it is very hard or impossible to come up even with a guess of what fitness function definition might be. Interactive genetic algorithms address this difficulty by outsourcing evaluation to external agents (normally humans).

also known as a heuristic evaluation function or static evaluation function.the elites should still be closely attached to the population at large so that they can share their beneficial genes around. One of these slots is mutated.that individual gets two reserved slots in the next generation.An evaluation function. at least one of those slots will reenter the general population as a parent. is a function used by game-playing programs to estimate the value or goodness of a position in the minimax and related algorithms. Either way . or by copying the elites and then mutating one . That article does take a slightly odd approach to elitism. and the elites should only represent a small portion of the population.especially on the need to maintain diversity and avoid premature convergence. That means that.com/topic/evaluation-function#ixzz2Nts4uhDv Elitism only means that the most fit handful of individuals are guaranteed a place in the next generation generally without undergoing mutation. The evaluation function is typically designed to prioritize speed over accuracy. and possibly two if both are overtaken. .answers. It suggests duplicating the most fit individual .whether by selecting elites as parents while also perpetuating them. the other is not. It does seem a viable approach. They should still be able to be selected as parents. @Peladao's answer and comment are also absolutely spot on . in the next generation. Read more: http://www. the function looks only at the current position and does not explore possible moves (therefore static). in addition to being brought forward themselves.