Logo Search packages:      
Sourcecode: gaffitter version File versions  Download package

void GeneticAlgorithm::InitPopulation (  )  [protected]

Create the population of individuals.

The first created individuals are sparse (several '0' genes). However the last individuals contain several '1' genes. This improves the diversity and exploration of the search space.

Definition at line 164 of file GeneticAlgorithm.cc.

References Optimizer::Diff(), LocalOptimizer(), m_cur_gen, Optimizer::m_files, m_genomes, m_pop_size, NonUniformFiller(), and Random::Probability().

Referenced by Evolve().

   // create the individuals

   // Probability between (p_min, p_max]
   const float p_min = min(1.0/m_files.size(),0.5); // maximum p_min = 0.5 (50%)
   const float p_max = 1.0 - p_min; // maximum p_max = 1.0 - p_min

   for(unsigned int j=0; j<m_pop_size; ++j)
      float cur_prob = 
             NonUniformFiller((j+1)*(p_max - p_min)/m_pop_size + p_min);

      m_genomes.push_back(new Genome(m_files.size()));

      for (int i=0; i<m_genomes[j]->Length(); ++i) 
                   m_genomes[j]->Gene(i, Random::Probability(cur_prob));

      // evaluate

   ++m_cur_gen; // the initial population is the first generation

Generated by  Doxygen 1.6.0   Back to index