0
$\begingroup$

Here is my (mis?)understanding of genetic algorithm:

  1. Create n individuals. This is initial population
  2. Calculate fitness of each individual in this population
  3. for i in range(n): select two individuals randomly with replacement from population with probability of selection of each individual proportional to its fitness value cross over the two selected individuals to create two offsprings introduce mutation
  4. Calculate fitness value for each offspring

Now you have an initial population of n and n offsprings.

What comes now?

Is my new population the n offsprings or the n fittest individuals of the 2n (n population + n offsprings) available?

$\endgroup$
1
$\begingroup$

In the simplest implementations, you simply discard the old population and maintain a population of size $n$ in each generation.

There is lots of variation on this though, any of which could be useful in practice. As a start to show the range of possibilities, you can do some or all of the following:

  • Keep a top number (say $m$) of the original population, and only generate $n-m$ new offspring in each generation.

  • Generate offspring in small groups and assess them. They must beat a member of the current population on the fitness measure in order to find a place (this can work nicely in round-robin tournaments, where the fitness measure is winner of a game).

  • Keep snapshots every so many generations (e.g. every 10 generations) of the whole population or just the best performing individuals. You may use these snapshots to assess long-term improvement or as a "gene pool" to keep good performers around in some form for a while longer than a single generation.

Variations like these are hyperparameters for your GA. They might help in certain circumstances, or be a hindrance in others. So start with the simple "everything is replaced" is recommended initially, especially if you are learning genetic algorithms.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.