Genetic Algorithms (GA): Core Idea and Steps for Selection, Crossover, and Mutation
A Genetic Algorithm (GA) is an evolutionary computation method that repeatedly evolves a population of candidate solutions over generations until a stopping criterion is met. The GA framework typically includes: initialize a population, evaluate each candidate via a fitness function, select parents, apply crossover and mutation, then form a new generation and repeat. This canonical flow is described in GA overviews and tutorials. 3
Key learning goals in this section:
- Understand how fitness evaluation guides search pressure.
- Outline the GA cycle with selection, crossover, and mutation, using a concrete optimization example. 2
- Recognize practical termination criteria used in GA variants.
Footnotes
-
Genetic Algorithms - GeeksforGeeks - Lists GA steps including population initialization, fitness evaluation, selection, crossover, mutation, and termination criteria. ↩ ↩2
-
Julian Blank — An Introduction to Genetic Algorithms - Describes the GA cycle: evaluate, select parents, crossover, mutation, merge, and survival/termination. ↩ ↩2
-
A Genetic Algorithm Tutorial (JHU PDF) - Tutorial explaining GA components like roulette-style selection, crossover, and mutation mechanics. ↩ ↩2
-
Choosing Mutation and Crossover Ratios for Genetic Algorithms—A Review - Documents typical GA stopping/termination criteria (fixed generations, fitness-level reached, no improvement). ↩
Genetic Algorithms Explained (Selection, Crossover, Mutation)
Core components (what each part does)
Fitness function transforms a candidate solution into a numeric score that the GA tries to maximize (or minimize). Tutorials commonly present GA iterations as: initialize population → evaluate fitness → select parents → crossover → mutation → repeat with termination. 2
Selection implements “survival of the fittest” by probabilistically favoring better individuals (fitness-proportional) or by deterministic competition among random subsets (tournament). GA tutorials and references also explicitly list selection as choosing individuals to act as parents for recombination.
Crossover recombines parents to form offspring; simple forms include one-point crossover where a crossover point is chosen and gene segments are swapped.
Mutation applies small random changes (often bit-flips for binary encoding) to introduce diversity and reduce the risk of premature convergence to local optima. 2
Termination may occur after a fixed number of generations, when improvement stalls, or when the population fitness reaches a target level; GA reviews and tutorials document these common criteria.
Footnotes
-
Genetic Algorithms - GeeksforGeeks - Lists GA steps including population initialization, fitness evaluation, selection, crossover, mutation, and termination criteria. ↩ ↩2
-
Julian Blank — An Introduction to Genetic Algorithms - Describes the GA cycle: evaluate, select parents, crossover, mutation, merge, and survival/termination. ↩ ↩2
-
JCBose UES T (GA notes PDF excerpt) - Explains roulette-wheel selection with fitness-based probability mapping. ↩
-
A Genetic Algorithm Tutorial (JHU PDF) - Tutorial explaining GA components like roulette-style selection, crossover, and mutation mechanics. ↩
-
Protorials By Saif — Genetic Algorithms Explained (Representation, Fitness, Parent Selection, Crossover, Mutation) - Demonstrates crossover/mutation and selection concepts in a step-by-step explanation. ↩
-
Choosing Mutation and Crossover Ratios for Genetic Algorithms—A Review - Documents typical GA stopping/termination criteria (fixed generations, fitness-level reached, no improvement). ↩
A basic GA outline (selection → crossover → mutation) on an encoded optimization problem
- 1Step 1
Pick a function to minimize or maximize. GA will search over candidate solutions to optimize this objective.
- 2Step 2
Represent each candidate solution as a chromosome (e.g., a fixed-length binary string).
- 3Step 3
Create random chromosomes that satisfy any constraints (or generate them uniformly over the allowed domain).
- 4Step 4
Compute a fitness score for every chromosome using the fitness function; higher fitness should correspond to better solutions (or convert minimization into maximization).
- 5Step 5
Select parent chromosomes with a probability biased by fitness (roulette-wheel/fitness proportionate or tournament selection).
- 6Step 6
With crossover probability , pair selected parents and perform crossover to produce offspring.
- 7Step 7
With mutation probability , randomly alter genes in each offspring to maintain diversity.
- 8Step 8
Replace the old population with the offspring (generational GA) or merge and then select survivors (steady-state or other variants).
- 9Step 9
Stop after a maximum number of generations, or when improvement becomes sufficiently small, etc., then return the best solution found.
Example optimization problem: maximize a simple linear function under binary encoding
We’ll solve a small maximization problem using a standard binary-encoded GA.
Objective: maximize
where each gene . This objective is equivalent to interpreting the chromosome as a 3-bit integer with weights .
Encoding: chromosome = a length-3 bit string .
Fitness function: since we are maximizing, we can use
GA hyperparameters (for the worked step):
- Population size
- Crossover probability
- Mutation probability per gene
- Selection: fitness-proportional (roulette-wheel) in this worked example (tutorials describe roulette-style fitness-biased selection).
Footnotes
-
JCBose UES T (GA notes PDF excerpt) - Explains roulette-wheel selection with fitness-based probability mapping. ↩
Worked iteration (from generation to generation )
1) Initialize population and evaluate fitness
Let the initial population be:
| Individual | Chromosome | Fitness |
|---|---|---|
| A | 000 | |
| B | 010 | |
| C | 101 | |
| D | 111 |
Fitness sum:
So roulette-wheel selection probabilities are:
(Conceptually consistent with roulette-wheel selection that maps fitness to selection probability.)
2) Selection (choose parents)
Suppose the GA selects two parents (for producing two offspring) using roulette-wheel outcomes. Assume:
- Parent 1 = D (111)
- Parent 2 = C (101)
This selection is fitness-biased: higher-fitness individuals have higher chance to be chosen.
3) Crossover (make offspring)
Use one-point crossover. Pick a crossover point between gene positions. For 3 genes, suppose we choose the point after the first gene.
Parents:
- D: 1 | 11 (111)
- C: 1 | 01 (101)
After one-point crossover at the shown cut:
- Offspring O1: take left from D and right from C → 1 01 = 101
- Offspring O2: take left from C and right from D → 1 11 = 111
Apply crossover only if a random draw is below ; in this example we assume crossover occurred (common GA step description). 3
4) Mutation (randomly flip bits)
Mutation introduces random diversity. For per gene, suppose mutation flips:
- In O1 (101): flip the last bit with the given event → 100
- In O2 (111): no mutation occurs → 111
Now recompute offspring fitness:
- fitness(100) = 4
- fitness(111) = 7
5) Form next generation
If we use a generational GA for simplicity, the next population becomes (in some order):
- 101 → mutated to 100 (fitness 4)
- 111 → (fitness 7)
- plus other offspring created from additional parent pairings (to fill )
After each generation, the GA checks termination criteria (max generations, stagnation, or reaching a fitness level).
Footnotes
-
JCBose UES T (GA notes PDF excerpt) - Explains roulette-wheel selection with fitness-based probability mapping. ↩ ↩2
-
Julian Blank — An Introduction to Genetic Algorithms - Describes the GA cycle: evaluate, select parents, crossover, mutation, merge, and survival/termination. ↩
-
A Genetic Algorithm Tutorial (JHU PDF) - Tutorial explaining GA components like roulette-style selection, crossover, and mutation mechanics. ↩
-
Protorials By Saif — Genetic Algorithms Explained (Representation, Fitness, Parent Selection, Crossover, Mutation) - Demonstrates crossover/mutation and selection concepts in a step-by-step explanation. ↩
-
Choosing Mutation and Crossover Ratios for Genetic Algorithms—A Review - Documents typical GA stopping/termination criteria (fixed generations, fitness-level reached, no improvement). ↩
Fitness before vs. after one GA reproduction (illustrative)
Shows how crossover + mutation can change fitness in a generation step.
Pro Tip: Fit the encoding to the problem
For binary optimization, bitstrings + one-point crossover + bit-flip mutation are natural. For real-valued problems, you typically use real-coded encodings and operators (e.g., blend crossover) rather than bitstrings.
Avoid premature convergence
If mutation is too low, the population can converge to a local optimum early. If it’s too high, the algorithm behaves almost like random search. GA literature commonly treats and as key interacting parameters.
Conceptual checks (selection, crossover, mutation, termination)
Minimal pseudo-logic of the GA loop (ties to the steps)
A canonical GA iteration can be summarized as:
and stop on a termination criterion such as max generations or fitness stagnation. 2
Footnotes
-
Julian Blank — An Introduction to Genetic Algorithms - Describes the GA cycle: evaluate, select parents, crossover, mutation, merge, and survival/termination. ↩
-
Choosing Mutation and Crossover Ratios for Genetic Algorithms—A Review - Documents typical GA stopping/termination criteria (fixed generations, fitness-level reached, no improvement). ↩
Knowledge Check
In a binary-encoded GA, what is mutation most commonly doing?
Explore Related Topics
Minimax on a Simple 3-Level Two-Player Game Tree: Step-by-Step Selection of the Maximizer’s Best Move
Simulated Annealing (SA): Working Mechanism and Worked Example
Generative AI
Generative AI comprises models that learn data distributions to create new text, images, audio, code, or video, driven mainly by transformer‑based language models and diffusion image models.
- Core architectures are large‑scale transformers for language and diffusion models for image synthesis, approximating , or .
- Foundation models are pretrained on massive corpora and adapted via prompting, fine‑tuning, or retrieval‑augmented generation for diverse downstream tasks.
- 2023 saw billion private investment, 149 new foundation models, and a rise to open‑source releases, though frontier models remain costly.
- Major risks include confabulation, bias, privacy leakage, copyright disputes, and deepfake misuse, requiring systematic governance.
- Responsible deployment combines data provenance, RAG grounding, safety layers, human oversight, and continuous monitoring.