A genetic algorithm is a metaheuristic that is inspired by Charles Darwin’s theory of natural selection. Genetic algorithms are generally used to find high-quality solutions to optimization and search problems using techniques inspired by natural selection.

A basic genetic algorithm can be split up into five distinct parts:

  1. Initial Population
  2. Fitness Test
  3. Selection
  4. Crossover
  5. Mutations

The initial population is the initial set of individuals in the population. Each individual in the set can be used to solve the problem at hand but they have no prior input so they could be good or bad at solving the problem.

The individual really just boils down to a set of parameters that can be input into the function and returns a result.

The fitness test takes an individual from a population and determs how fit they are. It does this by giving the individual a fitness score. This score is then used later to determine if the individual will be allowed to reproduce.

The selection phase is when individuals in the population are chosen to die or reproduce and live on. The individuals are decided on based on how close they can get to the ideal fitness score.

Two individuals(parents) are selected based on their fitness scores. Based on their fitness score the individual will have more chances to be selected to pass on their genes.

Crossover is significant because it is a way for the parents to pass on their genes to their children. A random set of genes are taken and swapped between the parents to create their children thus creating two new individuals for the next generation.

A mutation is a process of changing one gene or parameter to another value. This is done to add variability into a population so that traits that are not in a population can be introduced. Otherwise, the population may not be able to continue progressing after some number of generations have passed.

After all of these steps are complete it is best to continue steps 2 through 5 until you are satisfied with the results or no more progress is occurring.

If you would like to see an application of genetic algorithms the https://rednuht.org/genetic_cars_2/ is a great introduction.