Пример #1
0
        public void BuildFitnessFunction(ManagerGA managerGA, ConverterToFromChromosome converter)
        {
            _fitness =
                new GeneticSharp.Domain.Fitnesses.FuncFitness(c =>
            {
                var fc                = c as BinaryChromosome;
                double result         = 0.0;
                string viewChromosome = "";

                foreach (GeneticSharp.Domain.Chromosomes.Gene gene in fc.GetGenes())
                {
                    viewChromosome += gene.Value.ToString();
                }

                int[] solutionsNumber = converter.ConvertFromChromosome(viewChromosome, managerGA.GetCountFunctions);

                result = Convert.ToDouble(managerGA.FitnessFunction(solutionsNumber));


                return(result);
            });
        }