TournamentSelection implements SelectionPolicy { public ChromosomePair select(final Population population) throws MathIllegalArgumentException { return new ChromosomePair(tournament((ListPopulation) population), tournament((ListPopulation) population)); } TournamentSelection(final int arity); ChromosomePair select(final Population population); int getArity(); void setArity(final int arity);  }
@Test public void testSelect() { TournamentSelection ts = new TournamentSelection(2); ElitisticListPopulation pop = new ElitisticListPopulation(100, 0.203); for (int i=0; i<pop.getPopulationLimit(); i++) { pop.addChromosome(new DummyChromosome()); } for (int i=0; i<20; i++) { ChromosomePair pair = ts.select(pop); Assert.assertTrue(pair.getFirst().getFitness() > 0); Assert.assertTrue(pair.getSecond().getFitness() > 0); } }