protected WorkingSet(string Name, GeneticAlgorithmConfig <T> GAC, IGeneticOperatorProvider <T> Provider, IFitnessMeasuredCreator <T> Creator, Func <GeneticAlgorithm <T>, C> CM) { this.Lock = new ManualResetEvent(false); this.Name = Name; this.Log = new EmptyLogger(); //this.Log = new StreamLogger(string.Format("{0}-{1}-{2}.log", Name, GAC.PopulationSize, DateTime.Now.ToString("yyyy-MM-dd-HH-mm"))); this.GA = new GeneticAlgorithm <T>(GAC, Provider, Creator, Log); this.CalculationMode = CM(this.GA); this.GAC = GAC; }
public GeneticAlgorithm(GeneticAlgorithmConfig <T> gac, IGeneticOperatorProvider <T> OperatorProvider, IFitnessMeasuredCreator <T> Creator, Logger log) { this.Log = log; this.CurrentGeneration = 0; this.Operators = OperatorProvider.GetOperators(); this.Creator = Creator; this.GAC = gac; this.Cache = new List <GACache>(this.GAC.PopulationSize); for (int i = 0; i < this.GAC.PopulationSize; i++) { var Elem = Creator.CreateNew(this.GAC); Cache.Add(new GACache() { GAElement = Elem, Fitness = Elem.CalculateFitness(this.GAC.Sequence) }); } }