Beispiel #1
0
        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();
        }
Beispiel #2
0
 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);
     }
 }