Exemple #1
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;
        }
Exemple #2
0
 private void SetBestSequence()
 {
     BestSequence = CurrentPopulation
                    .OrderBy(e => e.Cost)
                    .First();
 }