Beispiel #1
0
        protected override IEnumerable <IStrategy> GetStrategies()
        {
            var generations           = new[] { 50, 100, 150, 200 };
            var populations           = new[] { 10, 20, 30, 50 };
            var mutationProbabilities = new[] { 1 };
            var crossStrategies       = new ICrossStrategy[] { new DoubleCrossStrategy() };
            var selectionStrategies   = new ISelectionStrategy[]
            {
                new TournamentSelectionStrategy(5, 5, 5, new RatioCorrectionStrategy()),
                new TournamentSelectionStrategy(10, 5, 5, new RatioCorrectionStrategy()),
                new FitnessSelectionStrategy(5, 5, new RatioCorrectionStrategy()),
                new RankingSelectionStrategy(5, 5, new RatioCorrectionStrategy()),
            };

            foreach (var generation in generations)
            {
                foreach (var population in populations)
                {
                    foreach (var mutationProbability in mutationProbabilities)
                    {
                        foreach (var crossStrategy in crossStrategies)
                        {
                            foreach (var selectionStrategy in selectionStrategies)
                            {
                                yield return(new GeneticStrategy(generation, population, mutationProbability, 50, crossStrategy,
                                                                 selectionStrategy));
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
 public GeneticStrategy(int generationCount, int populationSize, int mutationProbability,
                        int crossoverProbability, ICrossStrategy crossStrategy, ISelectionStrategy selectionStrategy)
 {
     Generations          = generationCount;
     PopulationSize       = populationSize;
     MutationProbability  = mutationProbability;
     CrossoverProbability = crossoverProbability;
     CrossStrategy        = crossStrategy;
     SelectionStrategy    = selectionStrategy;
 }