The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Genetic Algorithm Example
1. GENETIC ALGORITHM EXAMPLE
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
(TOTAL MARKS = 30)
Suppose we want to maximize the number of ones in a string of 10 binary digits.
a) What is the best possible string? (5 marks)
1111111111 (5 marks)
b) How much number of strings can be generated for this problem? (5 marks)
210
= 1024 (5 marks)
Now we are going to apply genetic algorithms to solve this problem. We toss a fair coin 60 times
and get the following initial population.
s1 = 1111010101
s2 = 0111000101
s3 = 1110110101
s4 = 0100010011
s5 = 1110111101
s6 = 0100110000
c) Suggest an appropriate fitness function (5 marks)
F (s) = Number of 1s in the binary string s (5 marks)
d) Evaluate the fitness of each individual (6 marks)
F (s1) = 7 (1 marks)
F (s2) = 5 (1 marks)
F (s3) = 7 (1 marks)
F (s4) = 4 (1 marks)
F (s5) = 8 (1 marks)
F (s6) = 3 (1 marks)
2. Suppose that after performing selection, we get the following population.
s1` = 1111010101 (s1)
s2` = 1110110101 (s3)
s3` = 1110111101 (s5)
s4` = 0111000101 (s2)
s5` = 0100010011 (s4)
s6` = 1110111101 (s5)
e) Apply single point cross over for the couples (s1`, s3`) and (s2`, s6`) at the points 3 and 6
respectively (6 marks)
For couple (s1`, s3`):
s1`` = 1110111101 (1.5 marks)
s3`` = 1111010101 (1.5 marks)
For couple (s2`, s6`):
s2`` = 1110111101 (1.5 marks)
s6`` = 1110110101 (1.5 marks)
f) Mutate the derived population with 0.1 probability (3 marks)
Derived population,
s1`` = 1110111101
s2`` = 1110111101
s3`` = 1111010101
s4`` = 0111000101
s5`` = 0100010011
s6`` = 1110110101
Note: Select 6 (= 10 * 6 * 0.1) random digits and perturb. (0.5 * 6 marks). Following is just
an example.