Genetic Algorithm
Genetic Algorithm
Overview: Genetic Algorithms (GAs) are adaptive heuristic search algorithms premised on the
evolutionary ideas of natural selection and genetics. The basic concept is to simulate the process of
natural evolution to find approximate solutions to optimization and search problems.
Genetic Algorithms operate on a population of potential solutions applying the principle of survival
of the fittest to produce better approximations to a solution. Each individual in the population
represents a possible solution and is evaluated using a fitness function. The algorithm iteratively
improves the population by selection, crossover, and mutation.
The algorithm is inspired by natural genetics and selection processes observed in biological
evolution. It relies on key operators and parameters such as crossover rate, mutation rate, selection
pressure, and population size.
Chromosome 1: 1101
Chromosome 2: 1001
Chromosome 3: 0110
Chromosome 4: 0001
2. Fitness Evaluation
1101 13 169
1001 9 81
0110 6 36
0001 1 1
3. Selection Techniques
Example (Roulette):
Crossover combines the genetic information of two parent chromosomes to produce new offspring.
It is the primary operator for exploring the search space.
• Single-Point Crossover: A point is selected on the parent chromosome and the segments
beyond that point are swapped.
Example:
Parent1: 1101
Parent2: 1001
• Two-Point Crossover: Two points are selected and the genes between them are exchanged.
Example:
Parent1: 110110
Parent2: 001101
• Uniform Crossover: Each gene is chosen randomly from one of the two parents using a
mask.
Example:
Mask: 1010
Parent1: 1101
Parent2: 1001
Offspring: [1 from P1, 0 from P2, 0 from P2, 1 from P1] → 1001
• Arithmetic Crossover: For real-valued genes, offspring are linear combinations of parents.
Example:
Parent1: 2.0
Parent2: 4.0
5. Mutation Techniques
Mutation introduces diversity by randomly altering gene values. It prevents premature convergence.
• Bit Flip Mutation: Used in binary chromosomes.
Example:
Original: 1101
Example:
Original: [A B C D E]
Example:
Original: [1 2 3 4 5]
Scramble [2,3,4] → [1 4 2 3 5]
Example:
Original: [1 2 3 4 5]
Invert [2,3,4] → [1 4 3 2 5]
Example:
Original: 2.5
6. Replacement Strategies
7. Termination Conditions
Initial Population:
Step-by-Step:
1. Fitness:
1010 → 10 → 100
0110 → 6 → 36
1111 → 15 → 225
0001 → 1 → 1
Probabilities: 0.28, 0.10, 0.62, 0.003 → likely selects 1010 & 1111
3. Crossover:
Point = 2 →
Parent1: 10|10
Parent2: 11|11
Offspring1: 1011
Offspring2: 1110
4. Mutation:
5. New Generation: