0% found this document useful (0 votes)
10 views2 pages

Genetic Algorithm Assignment

The document outlines a solution to maximize the function f(x) = 67x - x^2 using a Genetic Algorithm with a 4-bit binary encoding for x in the range [0, 15]. It details the steps including initial population creation, fitness calculation, one-point crossover, and bit-flip mutation, leading to final offspring and their respective fitness values. The final output table summarizes the chromosomes, their binary representation, corresponding x values, and fitness scores.
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)
10 views2 pages

Genetic Algorithm Assignment

The document outlines a solution to maximize the function f(x) = 67x - x^2 using a Genetic Algorithm with a 4-bit binary encoding for x in the range [0, 15]. It details the steps including initial population creation, fitness calculation, one-point crossover, and bit-flip mutation, leading to final offspring and their respective fitness values. The final output table summarizes the chromosomes, their binary representation, corresponding x values, and fitness scores.
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

Assignment Solution - Genetic Algorithm

Question 1: Genetic Algorithm

Maximize the function: f(x) = 67x - x^2 for x in [0, 15]

Step 1: Encode x (0-15) using 4-bit Binary

Step 2: Initial Population (Random Chromosomes)

Chromosomes:

- 0101 -> x = 5

- 1100 -> x = 12

- 0001 -> x = 1

- 1001 -> x = 9

- 0111 -> x = 7

- 1110 -> x = 14

Step 3: Fitness Calculation

f(5) = 310, f(12) = 660, f(1) = 66, f(9) = 522, f(7) = 420, f(14) = 742

Step 4: One-Point Crossover (after 2nd bit)

- Pair 1: 0101 and 1100 -> Offspring: 0100 and 1101

- Pair 2: 0001 and 1001 -> Offspring: 0001 and 1001

Step 5: Bit-Flip Mutation (p=0.1)

Simulated mutation (some bits flipped):


Assignment Solution - Genetic Algorithm

- 0100 -> 0000 (x = 0)

- 1101 -> unchanged (x = 13)

- 0001 -> 0000 (x = 0)

- 1001 -> 1011 (x = 11)

Step 6: Final Offspring and Fitness

- 0000 -> x = 0 -> f(x) = 0

- 1101 -> x = 13 -> f(x) = 702

- 0000 -> x = 0 -> f(x) = 0

- 1011 -> x = 11 -> f(x) = 616

Final Output Table:

| Chromosome | Binary | x | Fitness |

|------------|--------|----|---------|

| O1 | 0000 | 0 | 0 |

| O2 | 1101 | 13 | 702 |

| O3 | 0000 | 0 | 0 |

| O4 | 1011 | 11 | 616 |

You might also like