public Individual Mutation() { var indA = _randomProvider.GetRandomValue(Genom.Length); var indB = _randomProvider.GetRandomValue(Genom.Length); var a = Genom[indA]; Genom[indA] = Genom[indB]; Genom[indB] = a; return(this); }
private Individual DoTournament(IReadOnlyList <Individual> population, int tournamentSize) { var selectedForTournament = new List <Individual>(); while (selectedForTournament.Count < tournamentSize) { selectedForTournament.Add(population[_randomProvider.GetRandomValue(population.Count())]); } var minDistance = selectedForTournament.Min(x => x.CalculateAdaptation()); return(selectedForTournament.First(y => y.CalculateAdaptation() == minDistance)); }