Ejemplo n.º 1
0
 public Evolution(IRandomNumberGenerator random, 
     IChromosomeFactory chromosomeFactory, 
     IPopulationStrategy populationStrategy, 
     IMutationStrategy mutationStrategy,
     ICrossoverStrategy crossoverStrategy, 
     ISelectionStrategy selectionStrategy)
 {
     // TODO: Complete member initialization
     this.random = random;
     this.chromosomeFactory = chromosomeFactory;
     this.populationStrategy = populationStrategy;
     this.mutationStrategy = mutationStrategy;
     this.crossoverStrategy = crossoverStrategy;
     this.selectionStrategy = selectionStrategy;
 }
        private GeneticAlgorithm(int continuousVariablesCount, int integerVariablesCount, IDesignFactory designFactory,
                                 IOptimizationLogger logger, IConvergenceCriterion convergenceCriterion, IInitializer <double> initializer,
                                 IEncoding <T> encoding, int populationSize, IPopulationStrategy <T> populationStrategy,
                                 ISelectionStrategy <T> selection, IRecombinationStrategy <T> recombination, IMutationStrategy <T> mutation)
        {
            this.continuousVariablesCount = continuousVariablesCount;
            this.integerVariablesCount    = integerVariablesCount;
            this.designFactory            = designFactory;

            this.logger = logger;
            this.convergenceCriterion = convergenceCriterion;
            this.initializer          = initializer;

            this.encoding           = encoding;
            this.populationSize     = populationSize;
            this.populationStrategy = populationStrategy;
            this.selection          = selection;
            this.recombination      = recombination;
            this.mutation           = mutation;

            this.CurrentIteration = -1; // Initialization phase is not counted towards iterations
            this.BestPosition     = null;
            this.BestFitness      = double.MaxValue;
        }