/// <summary> /// Initializes a new instance of the <see cref="Optimizer"/> class. /// </summary> /// <param name="ancestor">The ancestor chromosome.</param> /// <param name="populationSize">Size of the population.</param> /// <param name="ff">The fitness function to use for chromosome fitness calculation.</param> /// <param name="selection">The selection to be used to select the best chromosomes.</param> public Optimizer(IChromosome ancestor, int populationSize, IFitnessFunction ff, Selection.SelectionBase selection) { if (ancestor == null) { throw new ArgumentNullException("ancestor"); } if (ff == null) { throw new ArgumentNullException("ff"); } if (selection == null) { throw new ArgumentNullException("selection"); } _populationSize = populationSize; FitnessFunction = ff; Selection = selection; _population = new List <IChromosome>(); ancestor.Evaluate(ff); _population.Add(ancestor); while (_population.Count < populationSize) { IChromosome newC = ancestor.Clone(); newC.Generate(); newC.Evaluate(ff); _population.Add(newC); } MutationRate = 0.08f; CrossoverRate = 0f; }
public DecoratorSelection(Selection.SelectionBase selection) { mSelection = selection; }