Evolutionary Computing Spring 2025
Quiz # 1
Marks : 10 Time:40 min
Name: Muhammad Nehal Ashfaq
Roll No: 21-F BSCS 09
Instructor: Dr. Asma Sanam Larik
Question #1:
a) List down the basic steps of an Evolutionary Algorithm?
• Initialization
• Evaluation
• Selection
• Crossover
• Mutation
• Survivor Selection
• Termination.
b) What are the advantages of Tournament Selection over Fitness Proportion Selection?
1) Prevents premature convergence
2) Provides better control over selection pressure
3) Handles negative and non-normalized fitness values effectively
4) Less affected by scaling issues:
c) What is suboptimal solution?
A suboptimal solution is one that is not the best possible outcome but is still
acceptable. It occurs when an algorithm finds a solution that is better than others but
not necessarily the global optimum.
d) What is a premature convergence?
Premature convergence occurs when a population loses diversity too soon and gets stuck in a
local optimum rather than exploring better solutions. This can result from excessive selection
pressure, low mutation rates, or overly exploitative search strategies.
Question #2:
Let f(x)= x2 be the function that we want to maximize
a. Initialize population with x= {3,5,2,1,9,7} . Represent it in binary.
3=0011
5=0101
2=0010
1=0001
9=1001
7=0111
Calculate fitness values:
f(3)=9, f(5)=25 , f(2)=4, f(1)=1, f(9)=81, f(7)=49
Compute total fitness:
9+25+4+1+81+49=169
Determine selection probability for each individual (FPS method):
P(3)=9/169
P(5)=25/169
P(2)=4/169
P(1)=1/169
P(9)=81/169
P(7)=49/169
Cumulative probabilities (for RBS):
3→0.053
5→0.201
2→0.225
1→0.231
9→0.711
7→1.0
Using the given random numbers {0.2, 0.4, 0.12, 0.6, 0.33, 0.9}, selection
results are:
0.2 → 5
0.4 → 9
0.12 → 3
0.6 → 9
0.33 → 9
0.9 → 7
New selected population: {5, 9, 3, 9, 9, 7}
Binary representation: {0101, 1001, 0011, 1001, 1001, 0111}
b. Apply crossover with one point bit flip.
Choose a crossover point (e.g., after the 2nd bit):
(01∣01) (10∣01) ⇒ (01∣01),(10∣01) (No change)
(00∣11) (10∣01) ⇒ (00∣01),(10∣11)
(01∣11) (01|11) ⇒ (10∣11),(01∣01)
New population: {0101, 1001, 0001, 1011, 1011, 0101}
c. Apply swap mutation
0101 → 0001
1001 → 1101
0001 → 0100
1011 → 0011
1011 → 0011
0101 → 0001
Mutated population: {0001, 1101, 0100, 0011, 0011, 0001}
d. Apply Truncation as Survival Selection
Sort individuals based on fitness and retain only the best ones:
f(0001)=1,
f(1101)=169,
f(0100)=16,
f(0011)=9,
f(0011)=9,
f(0001)=1,
f(0001) =1
Sorted order: 1101, 0100, 0011, 0011, 0001, 0001
After truncation (keeping the top 4 individuals):
Final population: {1101, 0100, 0011, 0011}
e. Write down the population that survives for the next generation.
Binary: {1101, 0100, 0011, 0011}
Decimal: {13, 4, 3, 3}
This final set of individuals moves to the next generation.
Good Luck