コード例 #1
0
        public void GeneticAlgorithmCompetitionTest()
        {
            GeneticDataConfig cfg = new GeneticDataConfig()
            {
                ChromosomeCount = 100,
                GenCount        = 20,
                MaxGen          = 1,
                MinGen          = 0,
                AllowFloat      = false
            };
            GeneticAlgorithm alg = Factory.RandomGenerationAlgorithmFactory.Create(cfg);

            alg.Algorithm.Task       = new Examples.TaskExample();
            alg.Algorithm.Comparator = new Util.Comparators.ChromosomeComparatorDescendingDefault();

            alg.Competition();

            Assert.IsTrue(alg.CurrentGeneration[0].FitnessResult > alg.CurrentGeneration[99].FitnessResult);
        }