Genetic Algorithms (GA) are a class of optimization algorithms inspired by the process of natural selection and genetics. They belong to the family of evolutionary algorithms and are based on the idea of mimicking biological evolution to find optimal solutions to complex problems. GAs are particularly useful for solving problems where the solution space is large, complex, and poorly understood, such as optimization problems and machine learning tasks.
Genetic algorithms are search heuristics that simulate the process of natural evolution. They operate on a population of potential solutions (called individuals or chromosomes), using techniques inspired by genetic operations such as selection, crossover (recombination), and mutation to evolve the population toward an optimal solution.
Population: A set of potential solutions to the problem. Each solution is called an individual or chromosome.
Chromosome: A single candidate solution, often represented as a string (binary, real, or permutation encoding) that encodes a potential solution to the problem.
Gene: A component or part of a chromosome, analogous to the way genes are a part of a biological chromosome. In GA, genes represent specific values in the solution.
Fitness Function: A function that evaluates how good a particular solution is. The fitness function is problem-specific and determines the "quality" of a solution. Individuals with higher fitness have a better chance of being selected for reproduction.
Selection: The process of choosing which individuals will be used to create the next generation. It is based on fitness: fitter individuals are more likely to be selected.
Crossover (Recombination): A genetic operator used to combine two parent solutions to produce offspring. This mimics the process of reproduction in biology, where offspring inherit traits from both parents.
Mutation: A genetic operator used to randomly alter a solution's genes to introduce diversity and avoid premature convergence to local optima.
Elitism: A strategy where the best solution from one generation is carried over to the next generation unchanged, ensuring that the quality of the population doesn't degrade.
The basic steps of a genetic algorithm are as follows:
Initialization:
Selection:
Crossover (Recombination):
Mutation:
Evaluation:
Replacement:
Termination:
Here's a simple pseudocode for a genetic algorithm:
1. Initialize population P with random solutions
2. Evaluate fitness of each individual in P
3. Repeat until stopping criteria are met:
a. Select parents based on fitness
b. Apply crossover to selected parents to produce offspring
c. Apply mutation to offspring
d. Evaluate fitness of offspring
e. Select individuals for the next generation
4. Return the best solution in the population
Roulette Wheel Selection: In roulette wheel selection, individuals are selected based on their fitness. A "wheel" is constructed where each individual’s slice is proportional to its fitness value. The wheel is spun, and the individual selected corresponds to the slice where the wheel stops.
Tournament Selection: In tournament selection, a small group (or tournament) of individuals is randomly selected, and the best individual from that group is chosen to be a parent. This method is popular because it’s simple and effective.
Rank Selection: In rank selection, individuals are ranked according to their fitness, and the selection is based on their rank, not their absolute fitness value. This method helps prevent premature convergence that might occur if selection was based purely on fitness differences.
Crossover is the process of combining two parent solutions to generate offspring. Some common crossover methods are:
Single-Point Crossover: The two parents are divided at a single point, and the genes are exchanged between the two parts.
Example:
Parent 1: 101010
Parent 2: 110011
Crossover point: 3
Offspring 1: 101011
Offspring 2: 110010
Two-Point Crossover: Two crossover points are chosen, and the part of the chromosome between these points is swapped between the parents.
Uniform Crossover: Each gene in the offspring is chosen randomly from one of the corresponding genes in the two parents.
Mutation introduces small, random changes to a solution, helping to maintain genetic diversity and avoid premature convergence.
Bit-flip Mutation: In binary encoding, a bit in the chromosome is randomly flipped (0 to 1 or 1 to 0).
Random Value Mutation: In real-valued encoding, a gene is modified by adding a small random value (often drawn from a normal distribution).
Elitism ensures that the best solutions are preserved from one generation to the next. In elitism, the top best individuals are copied directly into the next generation without any change. This guarantees that the solution quality doesn't degrade over time.
GAs have been successfully applied in a wide variety of fields, including:
Open this section to load past papers