What if Roulette Wheel Selection returns the same parent?

I am trying to implement a genetic algorithm using roulette wheel selection and I am wondering - what happens if, when we try to breed a child, the same parent is selected? Are we still doing the crossover since the resulting child will be the same as the parent's?

breedChild: function() {

  //blah blah blah
  //blah blah blah
  //blah blah blah

  var mom = this.rouletteWheelSelection(),
    dad = this.rouletteWheelSelection();
}



rouletteWheelSelection: function() {
  var total = 0,
    //totalFitnessScore is precalculated, and represents the sum of all the fitness scores in current population
    threshold = totalFitnessScore * Math.random();

  for (var i = 0; i < genomesArr.length; i++) {
    total += genomesArr[i].fitnessScore;

    if (total >= threshold) break;
  };

  return genomesArr[i];
}

      

+3


source to share


1 answer


The crossover will not change the situation, but the selection of the same parents should be so rare that checking if the parents are the same for every child produced will be more expensive compared to doing the crossover in such cases - if it is not then the gene pool will be too small to obtain effective results. On the other hand, the child may still be different from the parent if a mutation is introduced.



+3


source







All Articles