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 static void RunCrossOver(List <CoupleParent> coupleParents, List <string> crossoverChildren, List <Person> population) { Random random = new Random(); int setCrossoverPoint = random.Next(0, 1); if (setCrossoverPoint == 0) { SinglePointCrossover.DoCrossover(coupleParents, crossoverChildren, crossOverPercentage, population); } else { TwoPointCrossover.DoCrossover(coupleParents, crossoverChildren, crossOverPercentage, population); } }
public void TestTwoPointCrossOver_ItemsIndex1And2SwappedInChildren() { var r = new InsertNextItemRandomizer(1, 3); var tpco = new TwoPointCrossover(r); var c = tpco.DoCrossover(_moveList4Moves1, _moveList4Moves2); AssertMove(c.Item1[0], Color.Blue, Color.Red, CoordinateProvider.GetCoordinate('F', 7)); AssertMove(c.Item1[1], Color.White, Color.Cyan, CoordinateProvider.GetCoordinate('E', 7)); AssertMove(c.Item1[2], Color.Red, Color.Blue, CoordinateProvider.GetCoordinate('A', 5)); AssertMove(c.Item1[3], Color.Blue, Color.Red, CoordinateProvider.GetCoordinate('C', 6)); AssertMove(c.Item2[0], Color.Blue, Color.Red, CoordinateProvider.GetCoordinate('F', 2)); AssertMove(c.Item2[1], Color.White, Color.Cyan, CoordinateProvider.GetCoordinate('B', 4)); AssertMove(c.Item2[2], Color.Red, Color.Blue, CoordinateProvider.GetCoordinate('G', 4)); AssertMove(c.Item2[3], Color.Blue, Color.Red, CoordinateProvider.GetCoordinate('B', 7)); }