コード例 #1
0
ファイル: Genetics.cs プロジェクト: genveir/Genetics-Library
        public MissileProgram run()
        {
            BitGeneStringGenerator generator = new BitGeneStringGenerator();
            GeneratorParameters generatorParameters = new GeneratorParameters(null, 300, 100, true, null);

            BasicGeneticInstanceParameters bgiParams = new BasicGeneticInstanceParameters(generator, generatorParameters, new MissileProgramFitness());
            BasicGeneticRunParameters bgrParams = new BasicGeneticRunParameters(20, 0.7d, 25, 0.3d, false);
            BasicGenetics basicGenetics = new BasicGenetics(null, bgiParams);

            FuzzyGeneticsInstanceParameters fgiParams = new FuzzyGeneticsInstanceParameters();
            FuzzyGeneticsRunParameters fgrParams = new FuzzyGeneticsRunParameters(basicGenetics, bgiParams, bgrParams,
                10, 15, true);
            FuzzyGenetics genetics = new FuzzyGenetics(null, fgiParams);

            genetics.run(fgrParams);

            GeneString best = genetics.getBest();

            return new MissileProgramSemantics().parse(best);
        }
コード例 #2
0
ファイル: GenTest.cs プロジェクト: genveir/Genetics-Library
        private static void runTest()
        {
            StringReversalFitness fitness = new StringReversalFitness();

            Generator generator = new BitGeneStringGenerator();
            GeneratorParameters generatorParameters = new GeneratorParameters(null, 100, 100, true, null);

            BasicGeneticInstanceParameters bgiParams = new BasicGeneticInstanceParameters(generator, generatorParameters, fitness);
            BasicGeneticRunParameters bgrParams = new BasicGeneticRunParameters(20, 0.7d, 5, 0.3d, false);
            BasicGenetics basicGenetics = new BasicGenetics(null, bgiParams);

            RandomRestartInstanceParameters rriParams = new RandomRestartInstanceParameters(13000000);
            RandomRestartRunParameters rrrParams = new RandomRestartRunParameters(basicGenetics, bgiParams, bgrParams, 1, 200, true);

            RandomRestartGenetics randomRestartGenetics = new RandomRestartGenetics(null, rriParams);

            int bestFitness = randomRestartGenetics.run(rrrParams);

            GeneString bestResult = randomRestartGenetics.getBest();

            Console.WriteLine("best result: " + bestFitness);

            List<Swap> swaps = new StringReversalSemantics().parse(bestResult);

            Console.WriteLine(swaps.Count);

            int num = 0;
            for (int n = 0; n < 10; n++)
            {
                num = num * 10 + n;
                showTest(num + "", swaps);
            }

            showTest("Hello World", swaps);
            showTest("Wajoo", swaps);
            showTest("Werkt Aardig", swaps);
        }