Genetic Algorithms: The basics
A search heuristic called a genetic algorithm was influenced by Charles Darwin’s notion of natural evolution. The fittest people are chosen for reproduction in order to give rise to the next generation’s children, which is how natural selection works.
The selection of the fittest members of a population is the first step in the process of natural selection. They give birth to children who carry on their parents’ traits and join the following generation. Parents who are more physically fit will produce children who will outperform them and have a higher chance of surviving. The fittest generation will eventually emerge as a result of this process’ continual iterations.
This idea can be used to solve a search difficulty. We take into account a number of potential solutions to a problem and choose the finest ones.
A genetic algorithm considers five stages.
- Initial population
- Fitness function
- Selection
- Crossover
- Mutation
Initial population
A population, a group of people, is where the process starts. Every person is a component of the answer to the issue you’re trying to address.
Genes are a set of parameters (variables) that define an individual. A chromosome is made up of a string of genes (solution).
A string, or an alphabet, is used in a genetic algorithm to represent a person’s collection of genes. Binary values are typically used (string of 1s and 0s). We refer to the genes on a chromosome as being encoded.
Fitness function
The fitness function gauges a person’s level of fitness (the ability of an individual to compete with other individuals). Each person receives a fitness rating from the system. Based on its fitness score, an individual’s likelihood of being chosen for reproduction is determined.
Selection
The purpose of the selection phase is to choose the most fit people and allow them to pass on their genes to the following generation. Based on their fitness ratings, two sets of people (parents) are chosen. High fitness people are more likely to be chosen for reproduction.
Crossover
The reproductive and biological crossover operations are analogous to the crossover operator. In this, more than one parent is chosen, and using the genetic makeup of the parents, one or more offspring are created. In a GA, crossover is typically used with a high probability of success.
One Point Crossover
In this one-point crossover, the tails of the two parents are switched to produce new offspring at a randomly chosen crossing site.
Multi Point Crossover
A variation on the one-point crossover known as multi point crossover involves swapping alternating segments to produce new offspring.
Uniform Crossover
Instead of segmenting the chromosome, we treat each gene separately in a uniform crossover. For each chromosome, we effectively flip a coin to determine whether or not it will be present in the progeny. We can also tilt the odds in favour of one parent so that the child inherits more of their genetic makeup.
Mutation
Some of the newly produced offspring’s genes are susceptible to a low-probability random mutation. This suggests that a few bits in the bit string could be reversed.
To preserve diversity throughout the population and avoid early convergence, mutation takes place.