コード例 #1
0
ファイル: Program.cs プロジェクト: JamalG94/GeneticAlgorithm
        static void Main(string[] args)
        {
            FileReader            fileReader       = new FileReader();
            List <double>         pregnantOutcomes = fileReader.ReadPregData();
            List <List <double> > population       = fileReader.ReadData();

            int    populationAmount  = 60;
            int    coefficientAmount = 19;
            int    min        = -1;
            int    max        = 1;
            double mR         = 0.01;
            double cR         = 0.9;
            bool   preserve   = true;
            int    iterations = 500;

            SeedGenerator    seedGenerator    = new SeedGenerator(populationAmount, coefficientAmount, min, max);
            FitnessEvaluator fitnessEvaluator = new FitnessEvaluator(population, pregnantOutcomes);
            ISelection       roulette         = new Roulette();
            ICrossover       crossover        = new TwoPointCrossover(cR);
            IMutation        mutation         = new Mutation(mR, min, max);
            Elitism          elitism          = new Elitism(preserve);
            GeneticAlgorithm geneticAlgorithm = new GeneticAlgorithm(seedGenerator, fitnessEvaluator, roulette, crossover, mutation, elitism);

            geneticAlgorithm.Run(populationAmount, iterations);
        }