1

I am struggling to completely understand how to get a new generation in GA. AFAIK, these are the steps (let's consider elitist approach):

  • selection (retain 20% of the best in population and put them in next generation)
  • crossover (crossover the rest 70% - each parent crosses with other parent only once; what do we do with crossover probability here?)
  • mutate (mutate all specimens in generation with probability MP)

I am not sure this is OK and also as mentioned - what do you do with crossover probability CP? I mean, you need to have the same population size between generations therefore you need to cross all specimens from the worse 70% of population - rendering CP useless.

c0dehunter
  • 6,412
  • 16
  • 77
  • 139
  • http://stackoverflow.com/questions/14011844/choosing-parents-to-crossover-in-genetic-algorithms/14020358#14020358 and http://stackoverflow.com/questions/10778530/benefits-and-implementation-of-crossover-probability-in-genetic-algorithm/10785061#10785061 – Andreas Mar 17 '13 at 12:42

2 Answers2

2

The probabilities for crossover act as follows:

if rand() < crossProb:
  child1, child2 = crossover(parent1, parent2)
else:
  child1, child2 = parent1, parent2

Assuming rand() gives a float between [0, 1) and your crossover function is designed to return two values. Mutation works essentially the same but with a single parent-to-child relation.

The initial 20% in your selection process is simply guaranteed to have no mutation/crossover.

OliasailO
  • 522
  • 3
  • 11
1

Each individual could contain two copies of genome, and gametes contain a single copy. Gametes are produced from such dual genome by taking the required genes from each of these two copies at random. When gametes join, a new individual with two copies is produced. At least, this is how it works in nature where crossover always occurs (there is no such thing as CP).

This however requires to solve how two genomes are reflected to the single phenotype that participates in selection. Depending on the task you try to solve with genetic algorithm this may vary from trivial to very problematic.

I also recommend to use JGap package that provides many algorithms, both nature and human invented.

Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93