Пример #1
0
// tournament selection without replacement
// the individuals that survive reproduction are placed in the mating pool
void tselect_without_replacement( population &pop )
{
	int *shuffle = new int [pop.popsize()];
	int pick;
	int s = parameter::tournament_size;

	pre_tselect_without_replacement( shuffle, pick, pop.popsize() );//take pick to zero & shuffle the shuffle array (permutation)
	pop.MatingPool[0]=pop.best();
	for( int i=1; i< pop.popsize(); i++ )
	{
		if( pick+s > pop.popsize() )
			pre_tselect_without_replacement( shuffle, pick, pop.popsize() );
		pop.MatingPool[i] = pop.tournament_winner( shuffle, pick, s );
	}
	delete [] shuffle;
}