public static void RunExampleOnce() { List <Person> population = new List <Person>(); List <double> coefficient = new List <double>(); List <CoupleParent> coupleParents = new List <CoupleParent>(); List <string> crossoverChildren = new List <string>(); FileReader.CoefficientRead(coefficient); FileReader.ReadFile(population, 5); Fitness.CalculateSSE(population); Fitness.CalculateCoefSSE(coefficient, population); //Stap 1 t/m 5 RouletteWheel.DoCalculation(population); //Crossover Methods //SinglePointCrossover.DoCrossover(coupleParents, crossoverChildren); TwoPointCrossover.DoCrossover(coupleParents, crossoverChildren, crossOverPercentage, population); //Mutation Mutation.MutationChildren(crossoverChildren); //Recalculate Fitness for Childrens List <Person> childrenPopulation = Fitness.CalculateCoefSSEChild(coefficient, crossoverChildren); //Elitism best solution var bestPerson = Elitism.ChildHighestFit(childrenPopulation, crossOverPercentage); Console.ReadKey(); }
public void printDNA(Elitism e) { int i = 0; Console.WriteLine("DNA of best seed"); e.best_seed.DNA.ForEach(dna => { Console.WriteLine("[" + i + "] >>> " + dna); i++; }); }
public static void RunElitism(int idx, List <Person> childrenPopulation) { if (idx > 0) { var blabla = Elitism.ChildHighestFit(childrenPopulation, crossOverPercentage); if (bestPerson.NormalizedFitness != blabla.NormalizedFitness) { bestPerson = blabla; } } else if (bestPerson == null) { bestPerson = Elitism.ChildHighestFit(childrenPopulation, crossOverPercentage); } }
public IEnumerable <Individual> Apply(IEnumerable <Individual> source) { var prms = ParamsProvider(this); var inp = source.ToArray(); var elite = Elitism.SelectElite(inp, prms.ElitismFraction).ToArray(); if (elite.Length % 2 != 0) { throw new InvalidOperationException("Elitism fraction must result in an even number of individuals"); } var selected = Selection.Roulette(inp, inp.Length - elite.Length); var crossed = Crossover.UniformCrossoverPop(selected); var mutated = Mutation.MutatePop(crossed, prms.MutationFraction, RandomValueProvider); var retPop = elite.Concat(mutated).ToArray(); history.Add(CalcStats(prms, inp, retPop)); return(retPop); }
public void printSSEperIteration(int iteration, Elitism e) { Console.WriteLine(" | SSE of Iteration " + iteration + ": " + e.best_seed.SSE); Console.WriteLine(" __________________"); }
//private Elitism e = new Elitism(); public void printBestSSE(Elitism e) { Console.WriteLine(" | The individual with the best SSE: " + e.best_seed.SSE); Console.WriteLine(" _______________________________________________________________"); }