Genetic Algorithm (GA) – Working Principle
A Genetic Algorithm works by imitating the process of natural evolution. It starts with a population of possible solutions and gradually improves them using selection, crossover, and mutation.
1. Basic Working
Generate Initial Population
↓
Calculate Fitness
↓
Selection
↓
Crossover
↓
Mutation
↓
New Population
↓
Check Stop Condition
↙ ↘
No Yes
↓ ↓
Repeat Best Solution
2. Steps of Genetic Algorithm
Step 1: Initial Population
First, GA generates a group of possible solutions called a population.
Example:
101101
110010
011011
100111
Each solution is called a chromosome.
Step 2: Fitness Evaluation
Each chromosome is evaluated using a fitness function.
The fitness function tells us how good a solution is.
Example:
Chromosome Fitness
101101 45
110010 62
011011 38
100111 55
Higher fitness means a better solution, depending on the problem.
Step 3: Selection
The better chromosomes are given a higher chance of becoming parents for the next generation.
Common selection methods:
- Roulette Wheel Selection
- Tournament Selection
- Rank Selection
Purpose: Give better solutions more opportunity to reproduce.
Step 4: Crossover
Crossover combines two parent chromosomes to create new offspring.
Example:
Parent 1: 101 | 110
Parent 2: 110 | 010
↓ Crossover
Child 1: 101 | 010
Child 2: 110 | 110
Crossover helps create new combinations of good characteristics.
Step 5: Mutation
Mutation makes a small random change in a chromosome.
Example:
Before: 101101
After: 101001
↑
changed bit
Mutation helps maintain diversity and prevents the algorithm from getting stuck in a poor solution.
Step 6: New Generation
The offspring form a new population.
The new population is again evaluated using the fitness function.
The process continues:
Selection → Crossover → Mutation → Evaluation
Step 7: Termination
The algorithm stops when a suitable condition is reached, for example:
- Desired fitness is achieved
- Maximum number of generations reached
- No significant improvement occurs
The best chromosome is taken as the final solution.
3. Complete Example
Suppose GA wants to maximize a mathematical function.
Initial population:
1010
1100
0110
1110
The fitness function evaluates each chromosome.
1110 → Highest fitness
1100 → Good
1010 → Medium
0110 → Low
The better chromosomes are selected as parents.
Parent 1: 1110
Parent 2: 1100
After crossover:
Child: 1110
After mutation:
1110 → 1111
If 1111 has higher fitness, it becomes an improved solution.
4. Main Components
| Component | Meaning |
|---|---|
| Population | Collection of candidate solutions |
| Chromosome | Representation of one solution |
| Gene | Individual part of a chromosome |
| Fitness Function | Measures quality of solution |
| Selection | Chooses better parents |
| Crossover | Combines parents |
| Mutation | Makes random changes |
| Generation | One cycle of evolution |
Exam Definition
The working principle of a Genetic Algorithm involves generating an initial population of candidate solutions, evaluating their fitness, selecting suitable individuals, applying crossover and mutation to produce new solutions, and repeating the process until a satisfactory or optimal solution is obtained.
Memory Trick
P → F → S → C → M → R
Population → Fitness → Selection → Crossover → Mutation → Repeat
