Genetic algorithm is based on the Charles Darwin famous principle of survival of the fittest, where the fittest of the individuals are given higher importance and are chosen for reproduction in order to produce children for the new generation.
The process starts by selecting the fittest individuals from a population, who then produce offspring which inherit the characteristics of the parents. Since the parents already have better fitness among the population, their children will have a higher chance of surviving in their population.
Genetic Algorithm has five phases
- Fitness function
The process starts with the set of individuals known as Population where each individual is a solution to the problem you want to solve. An individual is characterized by a set of parameters (variables) known as Genes. Genes are joined into a string to form a Chromosome (solution)
The fitness function is used to predict a fitness score for each individual which shows how fit is that individual among the population. Individuals with a higher fitness score are given more probability for reproduction
In this phase, once the fitness function is applied and fitness score is calculated for each individual the selection of the fittest individuals starts which are then allowed to pass their genes to the next generation.
Crossover is considered to be the most important step in the process. In this phase, a crossover point is chosen at random from within the genes. Offsprings are then generated by exchanging the genes up to the point crossover isn’t reached. Then the new offsprings are added to the population.
In mutation, a random gene is inserted in offspring to maintaining the diversity in population to avoid the premature convergence
The algorithm terminates if the population has converged (does not produce offspring which are significantly different from the previous generation). Then it is said that the genetic algorithm has provided a set of solutions to our problem.
Hope you liked the post, let me know your thoughts in the comments.