Genetic Algorithms (GA)
Topic - The Genetic Algorithm (GA) is an adaptive heuristic search algorithm modeled on Darwinian natural selection and genetics. By treating candidate solutions as chromosomes and evolving a population through selection, crossover, and mutation, GAs intelligently exploit random search within complex, multi-dimensional search spaces to solve discontinuous, non-linear optimization problems.
1. Foundational Principles & Biological Analogy
Originating from the work of John Holland (1975), Genetic Algorithms simulate the fundamental processes that govern biological evolution:
- Natural Selection: Embodies Darwin's principle of "Survival of the Fittest" - individuals with higher fitness have a greater probability of reproducing and transmitting their genetic material to future generations.
- Chromosomes & Genes: Each candidate solution vector is represented as a chromosome, where individual decision variables or bits constitute the genes.
- Population: A collection of candidate chromosomes evaluated concurrently.
- Fitness Function (): The quantitative objective metric that scores how effectively each candidate solution satisfies the problem goal.
- Stochastic Balance: GAs combine random search + Darwinian selection to thoroughly explore the landscape while progressively concentrating search power in promising high-fitness regions.
2. The 7 Methodological Stages of Genetic Algorithms
Execution of a Genetic Algorithm follows seven structured stages:
Stage 1: Chromosome Formation
Represent each possible problem solution as an encoded data structure (chromosome):
- Binary Encoding: Strings of bits ( and ), ideal for discrete or bounded integer problems.
- Real-Valued (Continuous) Encoding: Vectors of floating-point numbers (), preferred for physical engineering parameter optimization.
Stage 2: Random Population Creation
Generate an initial population of candidate chromosomes using uniform random distribution across the feasible search space to ensure maximum initial diversity.
Stage 3: Fitness Assessment
Evaluate each individual chromosome using the problem's mathematical fitness function (). Solutions that better satisfy constraints and objectives are assigned higher numerical fitness values.
Stage 4: Selection / Mating Pool
Select superior individuals from the current population to serve as parents for reproduction:
- Roulette Wheel Selection: Probability of selection is proportional to individual fitness:
- Tournament Selection: Subsets of individuals are picked at random; the fittest individual in each tournament is selected.
- Mean Partitioning: Calculate the population's average fitness (). Divide the population into group (fitness , high performers) and group (fitness , preserving diversity). Pairs are chosen across groups to balance quality and diversity.
Stage 5: Crossover (Recombination)
Combine sub-sequences of two parent chromosomes to produce offspring with shared traits:
- Single-Point Crossover: A single cut point is randomly chosen; segments to the right of the cut are swapped between parents.
- Double-Point Crossover: Two cut points are selected; the middle genetic segment is swapped.
- Uniform Crossover: Each gene in the child is chosen randomly from either parent according to a fixed probability (e.g., ).
Stage 6: Mutation
Introduce small random changes into offspring chromosomes with a low probability ():
- In binary chromosomes, mutation flips a bit ( or ).
- Purpose: Reintroduces lost genetic alleles and prevents the population from prematurely converging to a suboptimal local peak.
Stage 7: New Offspring Creation & Generational Replacement
Form the next generation by combining newly generated children with selected elite individuals from the previous generation:
- Elitism: Automatically copies the top 1 or 2 highest-fitness chromosomes directly into the new generation without alteration, guaranteeing that the best solution found never deteriorates over time.
- Repetition: The process repeats through Stages 3 to 7 until convergence or reaching the maximum generation limit.
3. Step-by-Step Solved Problem: Maximizing
Benchmark Optimization Task: Maximize the function over the integer domain .
- Encoding: 5-bit binary strings (since , covering integers to ).
- Population Size: candidate solutions.
Step 1: Population Initialization
Initialize 4 random binary chromosomes:
- Chromosome 1 ():
- Chromosome 2 ():
- Chromosome 3 ():
- Chromosome 4 ():
Step 2: Binary to Decimal Decoding
Convert each binary string into its corresponding integer decimal value:
The initial population in decimal is .
Step 3: Fitness Function Evaluation ()
Calculate the fitness of each decoded individual:
Initial Generation Average Fitness ():
Step 4: Parent Selection
Select the two chromosomes with the highest fitness values:
- Parent 1: (, Fitness = )
- Parent 2: (, Fitness = )
Step 5: Crossover (Single-Point Cut after Bit 2)
Divide each parent chromosome after the second bit:
Swap the tail segments to produce two new offspring:
Step 6: Mutation (Bit Flip)
Apply a random mutation to Child 2 by flipping its 5th (last) bit from to :
Step 7: New Generation Assembly (with Elitism)
To maintain search progress without losing peak solutions, combine the two offspring with the two elite performers from Generation 0:
- Child 1: (New best solution discovered!)
- Child 2 (Mutated):
- Elite Old Best:
- Elite Old Second Best:
New Generation Average Fitness ():
Evolutionary Improvement:
In a single generation, the average population fitness increased by , and the algorithm discovered an individual () achieving , which is of the theoretical global maximum ().
4. Exam Traps & Operational Nuances
- 1. The Zero-Mutation Trap
- 2. Excessive Selection Pressure
- The Trap: Setting mutation rate to zero () to avoid disrupting high-fitness parents.
- The Consequence: If an allele (e.g., bit at position 1) is missing from all individuals in the initial population, crossover can never introduce a at that index. The search space is permanently truncated, leading to premature convergence in a sub-optimal hypercube.
- The Correction: Always sustain a small background mutation rate ().
- The Trap: Selecting only the single top-ranking individual for all crossover pairings.
- The Consequence: The entire population becomes genetically identical within 2-3 generations, destroying population diversity and ending exploration.
- The Correction: Use stochastic selection (roulette wheel or tournament) so sub-average individuals with rare, useful alleles retain a non-zero probability of reproduction.
5. Summary & Cheatsheet
Core Genetic Operators
- Selection: Biased toward higher fitness .
- Crossover: Swaps genetic blocks between parents.
- Mutation: Random bit flips prevent allele extinction.
- Elitism: Automatically preserves top performers.
7 Execution Stages
- 1-3: Chromosome encode, init population, score fitness.
- 4-6: Parent selection, crossover, bit mutation.
- 7: Generational replacement & elitist survival.
Key Takeaways
- Intelligent Exploitation: Genetic algorithms do not conduct blind random search; they intelligently propagate winning building blocks of genetic material (schemata) across generations.
- Diversity Preservation: Balancing crossover recombination with stochastic bit-flip mutation sustains population variance, preventing premature stagnation.
- Monotonic Convergence: Implementing elitism ensures the highest fitness discovered across all iterations never deteriorates as the population evolves.
Next Section: Physics & Swarm-Based Optimization (SA & PSO) - Deep dive into Simulated Annealing thermodynamics, Metropolis acceptance criteria, and Particle Swarm velocity dynamics.