3

I read the tutorial on TutorialsPoint and this question and answer on StackOverflow. However, I still do not understand the meaning of Crossover Probability in the Parent Selection and Crossover process of a genetic algorithm.

Say I have a population of size 100 and the crossover probability is 0.9. What does it mean? Do I:

  • select precisely 10 parents (since 90 % of offsprings shall be made by crossover), or
  • run a RNG 100 times and for each time the 0.9 probability fails, I select a parent?

Then, the parents are somehow crossed over and some individuals mutate. Does the population need to have exactly 100 members at this point, or there is an additional selection of which individuals make it to the next generation?

karlosss
  • 2,816
  • 7
  • 26
  • 42
  • 1
    The precise definitions and how they're implemented don't *really* matter unless you're trying to adhere to an exact specification. The point is just to randomly cross parents. It doesn't matter exactly how you achieve that. Play around with a few ways. – Carcigenicate Dec 28 '18 at 16:06

2 Answers2

3

As mentioned by Carcingenicate, the implementations can vary. A 0.90 crossover rate indicates that 90% of the offspring, or child, population will be created through a crossover operation on parent solutions. This might be implemented such that exactly 90% of the child are produced by crossover each generation, or it may be implemented probabilistically (as is done in AI_Learning's example). The children produced by crossover may or may not be also subject to mutation.

How the parent solutions are selected can also vary. It may be that more fit parent solutions are more likely to be selected to produce offspring, and whatever offspring are produced will constitute next generation's parent population. Alternatively, the parent solutions may be randomly chosen to produce offspring. Selection is then performed on the combined parent and offspring populations to create the next generation's parent population.

Generally, the parent population will always be equal to the prescribed population size. However, it is possible to produce a greater number of offspring and then select only a subset. Or only a few offspring may be created each generation, each potentially replacing a parent solution. Some implementations may also vary the population size over time, perhaps using large populations initially to promote exploration and then reducing the population size over time to promote exploitation.

Matt
  • 1,342
  • 5
  • 12
1

Its not exactly 10 parents, on average 10 parents. Following is the pseudo code, which I follows.

current_population <- comes from previous generation
new_population <- []

for i upto number of chromosomes in current_population :
    parent1, parent2 <- pick 2 parents from current population based on fitness function

    if random_number is less than cross_over_ratio :
        offspring <- crossover (parent1, parent2)
    else:
        if random_number is 0.5:
            offspring <- parent1
        else:
            offspring <- parent2

    append the offspring to new_population

for i upto number of chromosomes in new_population :

    if random_number is less than mutation_ratio :
        i_th chromosome in new_population <- mutation (i_th chromosome in new_population)
Venkatachalam
  • 16,288
  • 9
  • 49
  • 77