Genetic Algorithm


A genetic algorithm solves optimization problems by creating a population or group of possible solutions to the problem. The individuals in this population will carry chromosomes that are the values of variables of the problem, such as the number of periods in a moving average. The genetic algorithm actually solves your problem by allowing the less fit individuals in the population to die (peacefully) and selectively breeding the most fit individuals (the ones that solve the problem best by making the most profit, for example). This process is called selection as in selection of the fittest. The genetic algorithm will take two fit individuals and mate them (a process called crossover that takes some genes from the mother and others from the father). The offspring of the mated pair will receive some of the characteristics of the mother, and some of the father.


In nature, offspring often have some slight abnormalities, called mutations. Usually these mutations are disabling and inhibit the ability of the children to survive, but once in a while they improve the fitness of the individual (like toes stuck together in a web-like fashion). The genetic algorithm similarly occasionally causes mutations in its populations by randomly changing the value of a variable. The children, whether they were created from two parents or a mutation, are then tested and an overall score for the population is calculated. In financial applications, this test can determine the net profit or number of winning trades. Different types of tests are often called objective functions.

After testing, the population undergoes a generation change. The population will then consist of offspring plus a few of the older individuals, which the genetic algorithm allows to survive to the next generation because they are the most fit in the population, and we will want to keep them breeding. These most fit individuals are called elite individuals.

After dozens or even hundreds of "generations", a population eventually emerges wherein the individuals will solve the problem very well. In fact, the most fit (elite) individual will be an optimum or close to optimum solution. The processes of selection, crossover, and mutation are called genetic operators.