A genetic algorithm (GA) generates solutions to optimization problems using operators inspired by natural evolution, such as inheritance, mutation, selection, and crossover.Candidate solutions to the optimization problem play the role of individuals in a population, while a fitness function determines the quality of the solutions. Evolution of the population then takes place after the repeated application of the above operators.