0% found this document useful (0 votes)
4 views

Genetic Algorithm

Genetic Algorithms (GAs) are heuristic search algorithms that mimic natural evolution to solve optimization problems through a process involving selection, crossover, and mutation. The typical GA cycle includes initialization, fitness evaluation, selection, crossover, mutation, replacement, and termination. Various techniques for selection, crossover, and mutation are employed to enhance the diversity and quality of the solutions generated.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Genetic Algorithm

Genetic Algorithms (GAs) are heuristic search algorithms that mimic natural evolution to solve optimization problems through a process involving selection, crossover, and mutation. The typical GA cycle includes initialization, fitness evaluation, selection, crossover, mutation, replacement, and termination. Various techniques for selection, crossover, and mutation are employed to enhance the diversity and quality of the solutions generated.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Genetic Algorithm (GA)

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.

Steps in Genetic Algorithm

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.

The typical cycle of a GA is:


1. Initialization: Random generation of initial population.
2. Fitness Evaluation: Evaluate the fitness of each individual.
3. Selection: Select the fittest individuals for mating.
4. Crossover: Combine the selected parents to generate new offspring.
5. Mutation: Introduce random variations.
6. Replacement: Form a new generation.
7. Termination: Repeat the process until a stopping condition is met.
1. Initialization

Chromosomes can be binary strings, real numbers, or permutations.

Example (Binary Encoding):

Population (size = 4):

Chromosome 1: 1101

Chromosome 2: 1001

Chromosome 3: 0110

Chromosome 4: 0001

2. Fitness Evaluation

Fitness functions are problem-specific.

Objective: Maximize f(x) = x² where x is a 4-bit binary number.

Chromosome Decimal Fitness = x²

1101 13 169

1001 9 81

0110 6 36

0001 1 1

3. Selection Techniques

• Roulette Wheel Selection: Probability proportional to fitness.

• Tournament Selection: Randomly choose k individuals, pick the best.

• Rank Selection: Assign ranks and select based on rank.

• Elitism: Best individuals pass to next generation.

Example (Roulette):

Total fitness = 287

P(1101) = 169/287 ≈ 0.59

P(1001) = 81/287 ≈ 0.28

P(0110) = 36/287 ≈ 0.13

P(0001) = 1/287 ≈ 0.003


4. Crossover Techniques

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

Cut point = 2 → Offspring1: 11|01 → 1101

Offspring2: 10|01 → 1001

• Two-Point Crossover: Two points are selected and the genes between them are exchanged.

Example:

Parent1: 110110

Parent2: 001101

Cut points = 2 and 4 → Offspring1: 11[01]10 → 110110

Offspring2: 00[11]01 → 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

α = 0.5 → Offspring1 = α*2.0 + (1-α)*4.0 = 3.0

Offspring2 = α*4.0 + (1-α)*2.0 = 3.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

Bit flipped at position 2 → 1001

• Swap Mutation: Used in permutations (e.g., TSP).

Example:

Original: [A B C D E]

Swap positions 2 and 4 → [A E C D B]

• Scramble Mutation: A subset of genes is randomly shuffled.

Example:

Original: [1 2 3 4 5]

Scramble [2,3,4] → [1 4 2 3 5]

• Inversion Mutation: A subset of genes is reversed.

Example:

Original: [1 2 3 4 5]

Invert [2,3,4] → [1 4 3 2 5]

• Gaussian Mutation: Used in real-valued chromosomes.

Example:

Original: 2.5

Add Gaussian noise N(0, 0.1) → 2.5 + 0.07 = 2.57

6. Replacement Strategies

• Generational: Entire population replaced.

• Steady-State: A few are replaced.

• Elitism: Top individuals retained.

7. Termination Conditions

• Maximum number of generations reached.

• No improvement in best solution.

• Desired fitness level achieved.


Solved Exercise
Objective: Maximize f(x) = x², x in [0, 15]

Initial Population:

Chromosomes: 1010, 0110, 1111, 0001

Step-by-Step:

1. Fitness:

1010 → 10 → 100

0110 → 6 → 36

1111 → 15 → 225

0001 → 1 → 1

2. Selection: Roulette based on total = 362

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:

1011 → 1001 (flip 2)

1110 → 1111 (flip 4)

5. New Generation:

1001, 1111, ...

Repeat until best fitness (225) dominates.

You might also like