tm1701
tm1701

Reputation: 7581

Why does an AI genetic algortihm gives an equal fit or fitter solution in each generation?

The genetic algorithm is a meta-heuristic algorithm. The statement is that the population evolves each generation into a better (fitter) solution. Why is that?

I am pretty new at AI but want to improve step by step ;-) So please help me understand this algorithm.

At each iteration, a new generation of the population is created. Why will it contain an equal fit or fitter Individual?

Create a population of Individuals
WHILE population does not have the optimal fittest OR not maximum number of generations 
   call: evoluate the population
print fittest of population

method: evoluate the population 
   Craete a new population
   FOR the number of individuals in the population
     Select a fittest individual out of 5 random Individuals
     Select a fittest individual out of 5 random Individuals
     Store the crossover of these (parent) Individuals in the new population
   FOR the number of individuals in the population
     mutate the individual

Is it possible that the next population contains a less fitt solution?

Upvotes: 0

Views: 99

Answers (2)

Aaron Ryne
Aaron Ryne

Reputation: 26

Note: Apology for any grammatical mistakes.

Ques: Why will it contain an equal fit or fitter Individual?

Ans: Let's say the algorithm starts with a certain number (say 30) of the population (individual/solutions set) and will run for a certain number (say 30) of generation.

  1. Initially a fitness score is given to each individual either randomly or using a fitness function.
  2. In Each generation all the individual goes through some steps (Selection, crossover, mutation). In selection step the individuals with higher fitness value are more likely to be selected. During the crossover process, the individuals with higher fitness values are more likely to be selected as parents. Similarly, in the mutation step. (NOTE: A probability value is used in selection, crossover, mutation step.) Thus, in the next generation, the new population is more likely to perform better than the previous generation.

For details, you can check this book: https://www.amazon.com/Hands-Genetic-Algorithms-Python-intelligence-ebook/dp/B0842372RQ/ref=zg_bs_3880_18?_encoding=UTF8&psc=1&refRID=CEXPB1J6G099H25M0S21

Ques: Is it possible that the next population contains a less fitt solution?

Ans: Yes. Due to crossover and mutation, some of the offspring (new individuals) may change a lot from their best parent individual (previous individual selected for crossover/mutation) that they may not give the best result. However, in each generation, the individuals ultimately get better.

Sample Image

Upvotes: 1

Geoffrey De Smet
Geoffrey De Smet

Reputation: 27312

It could also contain a less fit solution too, to escape a local optima. That's why the global best solution must be remembered too, unless the first individual is guaranteed to contain it and survive.

Upvotes: 1

Related Questions