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

pair< int, int > GeneticAlgorithm::Tournament2 ( int  from,
int  to 
) const [protected]

Choose a individual via tournament (need 2 or more competitors). This is a 2 competitors optimized version.

See also:
TournamentN()

Definition at line 365 of file GeneticAlgorithm.cc.

References Score(), and Select().

Referenced by GeneticAlgorithm().

{
   int sel1 = Select(from,to);
   int sel2 = Select(from,to,sel1);

   // best and worse index, respectively
   if (Score(sel1) < Score(sel2))
      return make_pair(sel1,sel2);
   else
      return make_pair(sel2,sel1);
}


Generated by  Doxygen 1.6.0   Back to index