Beispiel #1
0
 private void AddCrossovers(int amount, IReadOnlyList <Point[]> from, List <Point[]> to)
 {
     for (int i = 0; i < amount; i++)
     {
         Point[] parent1 = from.Accept_Reject(bestSolution, ref rand, fitness);
         Point[] parent2 = from.Accept_Reject(bestSolution, ref rand, fitness);
         double  middle  = (fitness(parent1) + fitness(parent2)) / 2;
         Point[] newSol  = CrossOver(parent1, parent2);
         while (fitness(newSol) < middle)
         {
             if (badSolutionProb >= rand.NextDouble())
             {
                 break;
             }
             newSol = CrossOver(parent1, parent2);
         }
         to.Add(newSol);
     }
     addedCrossovers = amount;
 }