예제 #1
0
        public void PrintDebugScores()
        {
            var best10 = CurrentPopulation.OrderByDescending((x) => x.CurrentScore).Take(10);

            Debug.Log($"Best 10 of generation {CurrentGeneration}");
            var str = "";

            foreach (var entry in best10)
            {
                str += $"{entry.CurrentScore}\n";
            }

            Debug.Log(str);
        }
예제 #2
0
        public void CreateNewPopulation()
        {
            CurrentPopulation = Enumerable.Range(0, Algorithm.SeedingPopulationCount)
                                .Select(_ => GetRandomIndividual())
                                .ToList();

            ApplyBounds(CurrentPopulation);

            if (OptimizationTarget == OptimizationTarget.Minimum)
            {
                BestIndividual = CurrentPopulation.OrderBy(e => e.Cost).First();
            }
            else
            {
                BestIndividual = CurrentPopulation.OrderByDescending(e => e.Cost).First();
            }

            Generation = 0;
        }
예제 #3
0
 public void GetTheBestScouts(int n)
 {
     TheBestScouts = CurrentPopulation.OrderByDescending(x => CalculateCost(x)).Take(n).ToList();
 }