Definition of Algorithm

Genetic algorithms (GA) are adaptive heuristic search algorithms based on genetics and natural selection that falls under optimization algorithms. That was a lot. But simply, genetic algorithms are algorithms that are designed to find an optimal solution in a sometimes large problem set by mimicking the process of evolution.

Here are the steps the algorithm takes:

Algorithm Breakdown

The example I am going to use is designing rockets to reach space. There are thousands if not millions of different rocket designs and in order to find the best one, we follow a genetic algorithm. (This is not how actual rockets are designed, but I'm just using it as an example.)

  1. Initiation

    Initiation is when a population is randomly generated. It is expected that the members of the population will perform poorly; they are randomly generated after all. For example, in this step, we would randomly create thirty rockets that would probably be so bad they wouldn’t reach the heights of modern skyscrapers.

  2. Evaluation

    Now we score the population. In the rocket design scenario, this would be measuring the altitude they reach.

  3. Selection

    Here we select some of the fittest in the population to “breed”. We might select the ten highest altitude reaching rockets or select the highest altitude rocket out of a small randomly-picked sample and do this ten times, each time with a different sample. Different methods would result in different results.

  4. Crossover (also called Recombination)

    Here we will generate a second (hopefully better) population. We take the best rockets selected in step three and take random traits of either "parent" to create “children” that would make up the second population. Two rockets would be “bred” by combining random features of both, for example, taking the fins of one “parent” and the engine of the second ”parent”. The result is not necessarily better than either of the parents, but generally would be. Now that we create the second population what happens to the first? The first is scrapped and the second takes their place.

  5. Mutation

    There is still a problem with this algorithm. What if one rocket type just completely overwhelms the population? This is bad as the population lacks diversity and would not be able to improve itself, so we would introduce little changes, mutations, to every rocket. Not always a better population, but it is certainly possible that one or more rockets receive improvements.

  6. Repeat steps 2 to 5.

Relationship to Evolution

Why does it work? Because evolution works. Notice the similarities. The step of selection is the selection of the fittest. Only the strongest will be able to breed and pass on their traits. The step of crossover is the step of procreation, parents creating offspring. The step of mutation is literally when mutation occurs within our bodies.


Great. Any downsides? Plenty.

Evaluation has to measure the individuals in a population on a continuous scale. So a success or fail when evaluating an individual wouldn’t work.

It is also quite possible that the population is stuck in a local minimum. The individuals in it might seem to be the best possible, but there might be a completely different design that would be much better.