Genetic
Genetic
Genetic Algorithm
Dr.Yasser Fouad
1) Suppose a genetic algorithm uses chromosomes of the form x = abcdefgh with a fixed
length of eight genes. Each gene can be any digit between 0 and 9. Let the fitness of
individual x be calculated as:
f(x) = (a + b) − (c + d) + (e + f) − (g + h)
and let the initial population consist of four individuals with the following chromosomes:
x1 = 6 5 4 1 3 5 3 2
x2 = 8 7 1 2 6 6 0 1
x3 = 2 3 9 2 1 2 8 5
x4 = 4 1 8 5 2 0 9 4
a) Evaluate the fitness of each individual, showing all your workings, and arrange them
in order with the fittest first and the least fit last.
c) Suppose the new population consists of the six offspring individuals received by the
crossover operations in the above question. Evaluate the fitness of the new population,
showing all your workings.
d) By looking at the fitness function and considering that genes can only be digits
between 0 and 9 find the chromosome representing the optimal solution (i.e. with the
maximum fitness). Find the value of the maximum fitness.
e) By looking at the initial population of the algorithm can you say whether it will be
able to reach the optimal solution without the mutation operator?
Smart Systems – 2024/2025
Genetic Algorithm
Dr.Yasser Fouad
2) Consider the following fitness function: fitness = 5a + 3bc – d + 2e, Compute the
fitness of each of the members of the initial populavion below.
a b c d e
1 1 0 1 1
0 1 1 0 1
1 1 0 0 0
1 0 1 1 1
1 0 0 0 0
Assuming the first two of members of the population are selected for reproduction, and
crossover the rest where crossover point is that between b and c, show the resulting
children.
3) Consider the following fitness function: fitness (bitstring) = number of 1’s in the
bitstring where both adjacent bits are 0’s. For example, fitness (“010110100”) = 2;
fitness (“100011011”) = 0; and fitness (“010101010”) = 4. (Notice that 1’s in the first or
last position in the string are not counted in the fitness function, even if adjacent to a 0.)
Assume the design of our genetic algorithm is:
Start with the initial population and show what the next two (2) generations might
look like. Explain your reasoning.