public void GetParentPopulation_ReturnsCorrectAmountOfPotentialParents_WhenPopulationCountIsEven()
        {
            // Arrange
            List <Solution> currentParentPopulation = SetUpCurrentParentPopulation(true);

            // Act
            var result = parentSelection.GetParentPopulation(currentParentPopulation);

            // Assert
            result.Should().HaveCount(currentParentPopulation.Count);
        }
        public Dictionary <int, Solution> FindSolutions()
        {
            parentPopulation = randomSolutionGenerator.GeneratePopulationOfRandomSolutions(GenericConstants.SIZE_OF_POPULATION);

            for (int generationNum = 0; generationNum < GenericConstants.NUMBER_OF_ITERATIONS; generationNum++)
            {
                Random          random = new Random();
                List <Solution> potentialParentPool = parentSelection.GetParentPopulation(parentPopulation);

                // Generate an offspring population through recombination
                while (offspringPopulation.Count < parentPopulation.Count)
                {
                    Solution parentOne = potentialParentPool.ElementAt(random.Next(0, potentialParentPool.Count - 1));
                    Solution parentTwo = potentialParentPool.ElementAt(random.Next(0, potentialParentPool.Count - 1));

                    offspringPopulation.AddRange(recombination.RecombineParents(parentOne, parentTwo));
                }

                // For each offspring run mutation
                foreach (Solution offspring in offspringPopulation)
                {
                    mutation.MutateSolution(offspring);
                }

                // Find best solution in the generation and repeat
                solutions.Add(generationNum, bestSolutionFinder.GetBestSolutionInGeneration(offspringPopulation));

                if (EvolutionaryAlgorithmConstants.IS_USING_ADAPTIVE_CROSSOVER_CHANCES)
                {
                    adptiveChanceAdjuster.AdjustMutationRecombinationChances(recombination.SumOfCostOfRecombinedIndividuals, mutation.SumOfCostOfMutatedIndividuals);
                    ResetSumValues();
                }

                ResetPopulations();
            }

            return(solutions);
        }