use of org.evosuite.ga.problems.singleobjective.Booths in project evosuite by EvoSuite.
the class TestSortByFitness method testSortByFitnessC1win.
@Test
public void testSortByFitnessC1win() {
Problem p = new Booths<NSGAChromosome>();
List<FitnessFunction<NSGAChromosome>> fitnessFunctions = p.getFitnessFunctions();
FitnessFunction<NSGAChromosome> ff = fitnessFunctions.get(0);
NSGAChromosome c1 = new NSGAChromosome();
NSGAChromosome c2 = new NSGAChromosome();
// Set Fitness
c1.setFitness(ff, 0.7);
c2.setFitness(ff, 0.3);
List<NSGAChromosome> population = new ArrayList<NSGAChromosome>();
population.add(c1);
population.add(c2);
SortByFitness sf = new SortByFitness(ff, true);
Collections.sort(population, sf);
Assert.assertTrue(population.get(0) == c1);
Assert.assertEquals(population.get(0).getFitness(ff), 0.7, 0.0);
Assert.assertTrue(population.get(1) == c2);
Assert.assertEquals(population.get(1).getFitness(ff), 0.3, 0.0);
}
Aggregations