예제 #1
0
파일: Program.cs 프로젝트: Skrobson/AI_lab
        static void Main(string[] args)
        {
            //  Crossover		= 80%
            //  Mutation		=  5%
            //  Population size = 100
            //  Generations		= 2000
            //  Genome size		= 2
            var crossover      = 0.8;
            var mutationRate   = 0.05;
            var populationSize = 100;
            var generations    = 2000;
            var genomeSize     = 2;
            //create objects
            var random           = new Random((int)DateTime.Now.Ticks);
            var genesFactory     = new GenesFactory(random);
            var genomeFactory    = new GenomeFactory(genesFactory, random, mutationRate);
            var geneticAlghoritm = new GeneticAlghoritm(random, FitnessFunction, genomeFactory, crossover, populationSize, generations, genomeSize);

            //execute alghoritm
            geneticAlghoritm.Execute();
            //show results
            ShowResults(true, geneticAlghoritm);
            ShowResults(false, geneticAlghoritm);
            //
            Console.ReadKey();
        }
예제 #2
0
 public GenomeFactory(GenesFactory genesFactory, Random random, double mutationRate)
 {
     _genesFactory = genesFactory;
     _random       = random;
     _mutationRate = mutationRate;
 }