Intelligent Systems II · M2 · mocks

Q2 · GA through two generations [3]

M2 mock 3 · 10 marks

Q1(a)+Q1(b) compulsory; any two of Q2–Q4. Answers immediately below each question.

Confirmed M2 pattern: Q1(a) [2] and Q1(b) [2] are compulsory. Attempt any two of Q2, Q3 and Q4, each worth 3 marks. The paper offers 13 marks; you attempt 10. These are newly written practice questions, not claims about the exact upcoming paper. Solutions are directly below each question; the teaching working is deliberately longer than a concise exam answer.

Q2. Maximise f(x)=x^2LaTeX: f(x)=x^2 over unsigned 4-bit integers using the supplied GA settings. Perform two complete generations and compare the population fitness. [3 marks · Practice; complete two-generation solution]

Given

Initial ordered population: [2, 7, 8, 13]. Use 4 bits, crossover after bit 2, pair mating-pool slots 1–2 and 3–4. Flip bit 4 of children [1, 2, 3, 4] in every generation. Replace the whole population with the four children; no elitism.

GenerationSelection instruction
1Current individual row numbers [3, 4, 4, 3]
2Current individual row numbers [2, 3, 2, 3]

To find

Both generations: evaluation, selection, crossover, mutation, decoding and comparison.

Formula and why it applies

Encoding represents x; it does not change the objective. Crossover exchanges tails. Mutation flips specified bits. Fitness must be recomputed after mutation. Use exactly the supplied selection rule; replacing the weakest by the strongest is not a universal GA step.

Solution

Step 1. Generation 1: evaluate and encode the current population
IndividualxBinaryObjective calculation
1200102 × 2 = 4
2701117 × 7 = 49
3810008 × 8 = 64
413110113 × 13 = 169
Step 2. Generation 1: apply the supplied selection order

The question directly supplies individual numbers [3, 4, 4, 3]. These refer to the current generation’s row numbers, not their x values.

Mating-pool slotChosen individualxChromosome
1381000
24131101
34131101
4381000
Step 3. Generation 1: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

Pool slots pairedParent AParent BChild AChild B
1 & 210 | 0011 | 0110011100
3 & 411 | 0110 | 0011001001
Step 4. Generation 1: mutate only the specified bits
ChildBefore mutationInstructionAfter mutation
11001Flip bit 41000
21100Flip bit 41101
31100Flip bit 41101
41001Flip bit 41000
Step 5. Generation 1: decode and evaluate every child
ChromosomeDecode using place valuesObjective
10008 + 0 + 0 + 0 = 88² = 64
11018 + 4 + 0 + 1 = 1313² = 169
11018 + 4 + 0 + 1 = 1313² = 169
10008 + 0 + 0 + 0 = 88² = 64
Step 6. Generation 1: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.

\overline f_{old}=\frac{4+49+64+169}{4}=\frac{286}{4}=71.5LaTeX: \overline f_{old}=\frac{4+49+64+169}{4}=\frac{286}{4}=71.5
\overline f_{new}=\frac{64+169+169+64}{4}=\frac{466}{4}=116.5LaTeX: \overline f_{new}=\frac{64+169+169+64}{4}=\frac{466}{4}=116.5

Best objective: 169 → 169. Higher is better. The next population is [8, 13, 13, 8]. No elitism is imposed, so the best previous individual is not automatically protected.

Step 7. Generation 2: evaluate and encode the current population
IndividualxBinaryObjective calculation
1810008 × 8 = 64
213110113 × 13 = 169
313110113 × 13 = 169
4810008 × 8 = 64
Step 8. Generation 2: apply the supplied selection order

The question directly supplies individual numbers [2, 3, 2, 3]. These refer to the current generation’s row numbers, not their x values.

Mating-pool slotChosen individualxChromosome
12131101
23131101
32131101
43131101
Step 9. Generation 2: crossover after bit 2

Keep each prefix and exchange the suffixes. Bit positions are counted from the left starting at 1.

Pool slots pairedParent AParent BChild AChild B
1 & 211 | 0111 | 0111011101
3 & 411 | 0111 | 0111011101
Step 10. Generation 2: mutate only the specified bits
ChildBefore mutationInstructionAfter mutation
11101Flip bit 41100
21101Flip bit 41100
31101Flip bit 41100
41101Flip bit 41100
Step 11. Generation 2: decode and evaluate every child
ChromosomeDecode using place valuesObjective
11008 + 4 + 0 + 0 = 1212² = 144
11008 + 4 + 0 + 0 = 1212² = 144
11008 + 4 + 0 + 0 = 1212² = 144
11008 + 4 + 0 + 0 = 1212² = 144
Step 12. Generation 2: compare and form the next population

Add the objective scores in each population, then divide by its number of individuals.

\overline f_{old}=\frac{64+169+169+64}{4}=\frac{466}{4}=116.5LaTeX: \overline f_{old}=\frac{64+169+169+64}{4}=\frac{466}{4}=116.5
\overline f_{new}=\frac{144+144+144+144}{4}=\frac{576}{4}=144LaTeX: \overline f_{new}=\frac{144+144+144+144}{4}=\frac{576}{4}=144

Best objective: 169 → 144. Higher is better. The next population is [12, 12, 12, 12]. No elitism is imposed, so the best previous individual is not automatically protected.

Final answer. After two generations the ordered population is [12, 12, 12, 12]. Best final objective = 144 at x = [12].