예제 #1
0
 public void Crossover(ref Genome genome2, out Genome child1, out Genome child2)
 {
     int pos = (int)(m_random.NextDouble() * (double)m_length);
     child1 = new Genome(m_length, false);
     child2 = new Genome(m_length, false);
     for(int i = 0 ; i < m_length ; i++)
     {
         if (i < pos)
         {
             child1.m_genes[i] = m_genes[i];
             child2.m_genes[i] = genome2.m_genes[i];
         }
         else
         {
             child1.m_genes[i] = genome2.m_genes[i];
             child2.m_genes[i] = m_genes[i];
         }
     }
 }
예제 #2
0
 /// <summary>
 /// Create the *initial* genomes by repeated calling the supplied fitness function
 /// </summary>
 private void CreateGenomes()
 {
     for (int i = 0; i < m_populationSize ; i++)
     {
         Genome g = new Genome(m_genomeSize);
         m_thisGeneration.Add(g);
     }
 }