Subjects genetic algorithms

Genetic Algorithm Maximization F2Dcf8

Step-by-step solutions with LaTeX - clean, fast, and student-friendly.

Search Solutions

Genetic Algorithm Maximization F2Dcf8


1. **Problem Statement:** Maximize the function $f(x) = x^2 + 1$ using a Genetic Algorithm (GA) with the given population: (a) 01101, (b) 01000, (c) 11000, (d) 10010. Use single-point crossover for two iterations. 2. **Step 1: Decode Binary to Decimal** Each chromosome is a binary string representing an integer $x$. Convert each to decimal: - (a) 01101 = $0\times2^4 + 1\times2^3 + 1\times2^2 + 0\times2^1 + 1\times2^0 = 0 + 8 + 4 + 0 + 1 = 13$ - (b) 01000 = $0 + 8 + 0 + 0 + 0 = 8$ - (c) 11000 = $16 + 8 + 0 + 0 + 0 = 24$ - (d) 10010 = $16 + 0 + 0 + 2 + 0 = 18$ 3. **Step 2: Calculate Fitness** Fitness function is $f(x) = x^2 + 1$: - (a) $13^2 + 1 = 169 + 1 = 170$ - (b) $8^2 + 1 = 64 + 1 = 65$ - (c) $24^2 + 1 = 576 + 1 = 577$ - (d) $18^2 + 1 = 324 + 1 = 325$ 4. **Step 3: Select Parents for Crossover** Select two chromosomes for crossover based on fitness. The top two are (c) and (d). 5. **Step 4: Single-Point Crossover (Iteration 1)** Choose a crossover point randomly, say after the 2nd bit: - Parent 1 (c): 11000 - Parent 2 (d): 10010 Crossover: - Child 1: first 2 bits of (c) + last 3 bits of (d) = 11 + 010 = 11010 - Child 2: first 2 bits of (d) + last 3 bits of (c) = 10 + 000 = 10000 6. **Step 5: Decode Children and Calculate Fitness** - Child 1 (11010) = $16 + 8 + 0 + 2 + 0 = 26$ - Child 2 (10000) = $16 + 0 + 0 + 0 + 0 = 16$ Fitness: - Child 1: $26^2 + 1 = 676 + 1 = 677$ - Child 2: $16^2 + 1 = 256 + 1 = 257$ 7. **Step 6: Single-Point Crossover (Iteration 2)** Crossover children from iteration 1 at a new point, say after the 3rd bit: - Child 1: 11010 - Child 2: 10000 Crossover: - New Child 1: first 3 bits of Child 1 + last 2 bits of Child 2 = 110 + 00 = 11000 - New Child 2: first 3 bits of Child 2 + last 2 bits of Child 1 = 100 + 10 = 10010 8. **Step 7: Decode New Children and Calculate Fitness** - New Child 1 (11000) = 24 - New Child 2 (10010) = 18 Fitness: - New Child 1: $24^2 + 1 = 577$ - New Child 2: $18^2 + 1 = 325$ 9. **Conclusion:** The maximum fitness found is $677$ for $x=26$ (Child 1 after iteration 1). The GA improved the population by crossover. **Final answer:** Maximum value of $f(x) = x^2 + 1$ found is $677$ at $x=26$ after two iterations of single-point crossover.