Ejemplo n.º 1
0
 private static void Mutate(Gene[] genes)
 {
     if (MyRandom.NextDouble() < AlgoParam.MutationRate)
     {
         genes[MyRandom.Next(ChromosomeLength)] = Gene.CreateRandomGene();
         genes[MyRandom.Next(ChromosomeLength)] = Gene.CreateRandomGene();
     }
 }
Ejemplo n.º 2
0
        public static Chromosome CreateRandomChromosome(int generation = 0)
        {
            var genes = new Gene[Length];

            for (var g = 0; g < Length; g++)
            {
                genes[g] = Gene.CreateRandomGene();
            }

            return(new Chromosome(genes, generation));
        }