コード例 #1
0
        public RobotChromosome(RobotEvolutionConfiguration config)
        {
            Config = config;

            var phenotypeEntities = new BehaviorPhenotypeEntity[config.BehaviorCount];

            for (int i = 0; i < phenotypeEntities.Length; i++)
            {
                phenotypeEntities[i] = new BehaviorPhenotypeEntity(config, i);
            }

            SetPhenotypes(phenotypeEntities);
            CreateGenes();
        }
コード例 #2
0
ファイル: RobotFitness.cs プロジェクト: yahyaguzide/daud
 public RobotFitness(Func <RobotChromosome, Task <ContestGame> > contestFactoryAsync,
                     RobotEvolutionConfiguration config)
 {
     this.ContestFactoryAsync         = contestFactoryAsync;
     this.RobotEvolutionConfiguration = config;
 }
コード例 #3
0
        public GeneticAlgorithm CreateGA(Func <RobotChromosome, Task <ContestGame> > contestFactory, RobotEvolutionConfiguration config)
        {
            NumberOfSimultaneousEvaluations = 2;
            var fitness    = new RobotFitness(contestFactory, config);
            var chromosome = new RobotChromosome(config);
            var crossover  = new UniformCrossover();
            var mutation   = new FlipBitMutation();
            var selection  = new EliteSelection();
            var population = new Population(NumberOfSimultaneousEvaluations, NumberOfSimultaneousEvaluations, chromosome)
            {
                GenerationStrategy = new PerformanceGenerationStrategy()
            };

            var ga = new GeneticAlgorithm(population, fitness, selection, crossover, mutation)
            {
                Termination = new RobotTermination(),

                //TaskExecutor = new LinearTaskExecutor(),
                TaskExecutor = new ParallelTaskExecutor
                {
                    MaxThreads = 10
                }
            };

            ga.GenerationRan += delegate
            {
                Console.WriteLine("Generation complete");
            };

            ga.MutationProbability = .1f;

            return(ga);
        }