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

void GeneticAlgorithm::LocalOptimizer ( Genome g  )  const [protected]

This genetic operator perform a local optimization upon a Genome.

First it makes the individual feasible, from left to right or vice-versa. Finally, LocalOptimizer fill the individual to minimize the difference (target - sum)

Definition at line 260 of file GeneticAlgorithm.cc.

References Genome::AddSize(), Genome::DelSize(), Genome::Length(), Optimizer::m_files, Genome::OverTarget(), Random::Probability(), and Genome::UnderTarget().

Referenced by Generation(), and InitPopulation().

{
   if (Random::Probability(0.5))
   {
      int i = g.Length()-1;
      while (g.OverTarget()) { g.DelSize(i, m_files[i].Size()); --i; }
   }
   else
   {
      int i = 0;
      while (g.OverTarget()) { g.DelSize(i, m_files[i].Size()); ++i; }
   }

   if (g.UnderTarget())
   {
      for (int i=0; i<g.Length(); ++i) { g.AddSize(i, m_files[i].Size()); }
   }

}


Generated by  Doxygen 1.6.0   Back to index