コード例 #1
0
ファイル: Engine.cs プロジェクト: tsvgeorgieva/AmAm
        public IMeal Solve(IEnumerable <DietaryReferenceIntake> maxWeight, IEnumerable <Food> items, int iterationCount)
        {
            MaxWeight      = maxWeight;
            Items          = items;
            IterationCount = iterationCount;

            var population = PopulationInitializer.InitializePopulation(MaxWeight, items);

            for (int i = 0; i < IterationCount; i++)
            {
                if (IsDebug)
                {
                    Console.WriteLine($"{population.GetFittest().TotalCostSum:F2}");
                }

                population.RemoveNotFit();
                PopulationCrossoverer.CrossoverPopulation(population);
                PopulationMutator.MutatePopulation(population);
                population.MergeNewGeneration();
            }

            return(population.GetFittest());
        }