예제 #1
0
        public void Test_That_Genetic_Algorithm_On_Sphere_Works()
        {
            GeneticAlgorithm <double[]> garden = new GeneticAlgorithm <double[]>((double[] sol1, double[] sol2) => {
                return(CrossOver.CutAndSplice <double>(sol1, sol2)[0].ToArray());
            });
            Sphere sphere = new Sphere();

            garden.create(sphere.getConfiguration());
            garden.fullIteration();
        }
예제 #2
0
        public void Test_That_Knapsack_Genetic_Algorithm_Works()
        {
            this.Load(Constants.SAMPLE_MKNAPCB4_DATASET);
            Console.WriteLine($"Goal:\t{this.goal}");
            GeneticAlgorithm <List <int> > ga = new GeneticAlgorithm <List <int> >((List <int> sol1, List <int> sol2) => {
                return(CrossOver.CutAndSplice <int>(sol1.AsEnumerable(), sol2.AsEnumerable())[0].ToList());
            });

            ga.create(this.getConfiguration());
            List <int> finalSolution = ga.fullIteration();
        }