/// <summary> /// Mutates an individual by choosing an index at random and randomizing /// its training point among possible individuals. /// </summary> protected internal override GAIndividual ReproduceByMutation(int inIndex) { FloatRegFitPredictionIndividual i = (FloatRegFitPredictionIndividual)ReproduceByClone(inIndex); int index = Rng.Next(FloatRegFitPredictionIndividual._sampleSize); i.SetSampleIndex(index, Rng.Next(_solutionGA._testCases.Count)); return(i); }
protected internal override GAIndividual ReproduceByCrossover(int inIndex) { FloatRegFitPredictionIndividual a = (FloatRegFitPredictionIndividual)ReproduceByClone(inIndex); FloatRegFitPredictionIndividual b = (FloatRegFitPredictionIndividual)TournamentSelect(_tournamentSize, inIndex); // crossoverPoint is the first index of a that will be changed to the // gene from b. int crossoverPoint = Rng.Next(FloatRegFitPredictionIndividual._sampleSize - 1) + 1; for (int i = crossoverPoint; i < FloatRegFitPredictionIndividual._sampleSize; i++) { a.SetSampleIndex(i, b.GetSampleIndex(i)); } return(a); }