Beispiel #1
0
 public static void Random <G>(GeneticAlgorithm <G> alg, Func <int, double> familiesCount)
     where G : Chromosome
 {
     alg.GetCrossoverFamilies = delegate
     {
         var res = new Tuple <G, G, int> [(int)familiesCount(alg.Pool.Count)];
         for (int i = 0; i < res.Length; i++)
         {
             res[i] = new Tuple <G, G, int>(alg.RandomChromosomeFromPool(), alg.RandomChromosomeFromPool(), 1);
         }
         return(res);
     };
 }
Beispiel #2
0
 public static void Random <G>(GeneticAlgorithm <G> alg, double mutationPercentage)
     where G : Chromosome
 {
     alg.GetMutationOrigins = delegate
     {
         var res = new Tuple <G, int> [(int)(alg.Pool.Count * mutationPercentage)];
         for (int i = 0; i < res.Length; i++)
         {
             res[i] = new Tuple <G, int>(alg.RandomChromosomeFromPool(), 1);
         }
         return(res);
     };
 }