use of org.evosuite.ga.problems.multiobjective.FON in project evosuite by EvoSuite.
the class TestDominanceComparator method testDominanceComparatorSeveralFitnessesNoDomination.
@Test
public void testDominanceComparatorSeveralFitnessesNoDomination() {
Problem p = new FON();
List<FitnessFunction<NSGAChromosome>> fitnessFunctions = p.getFitnessFunctions();
FitnessFunction<NSGAChromosome> ff_1 = fitnessFunctions.get(0);
FitnessFunction<NSGAChromosome> ff_2 = fitnessFunctions.get(1);
NSGAChromosome c1 = new NSGAChromosome();
NSGAChromosome c2 = new NSGAChromosome();
// Set Fitness
c1.setFitness(ff_1, 0.7);
c1.setFitness(ff_2, 0.2);
c2.setFitness(ff_1, 0.3);
c2.setFitness(ff_2, 0.5);
List<NSGAChromosome> population = new ArrayList<NSGAChromosome>();
population.add(c1);
population.add(c2);
DominanceComparator dc = new DominanceComparator();
Collections.sort(population, dc);
Assert.assertEquals(population.get(0).getFitness(ff_1), 0.7, 0.0);
Assert.assertEquals(population.get(0).getFitness(ff_2), 0.2, 0.0);
Assert.assertEquals(population.get(1).getFitness(ff_1), 0.3, 0.0);
Assert.assertEquals(population.get(1).getFitness(ff_2), 0.5, 0.0);
}
use of org.evosuite.ga.problems.multiobjective.FON in project evosuite by EvoSuite.
the class TestDominanceComparator method testDominanceComparatorSeveralFitnessesDomination.
@Test
public void testDominanceComparatorSeveralFitnessesDomination() {
Problem p = new FON();
List<FitnessFunction<NSGAChromosome>> fitnessFunctions = p.getFitnessFunctions();
FitnessFunction<NSGAChromosome> ff_1 = fitnessFunctions.get(0);
FitnessFunction<NSGAChromosome> ff_2 = fitnessFunctions.get(1);
NSGAChromosome c1 = new NSGAChromosome();
NSGAChromosome c2 = new NSGAChromosome();
// Set Fitness
c1.setFitness(ff_1, 0.7);
c1.setFitness(ff_2, 0.6);
c2.setFitness(ff_1, 0.3);
c2.setFitness(ff_2, 0.5);
List<NSGAChromosome> population = new ArrayList<NSGAChromosome>();
population.add(c1);
population.add(c2);
DominanceComparator dc = new DominanceComparator();
Collections.sort(population, dc);
Assert.assertEquals(population.get(0).getFitness(ff_1), 0.3, 0.0);
Assert.assertEquals(population.get(0).getFitness(ff_2), 0.5, 0.0);
Assert.assertEquals(population.get(1).getFitness(ff_1), 0.7, 0.0);
Assert.assertEquals(population.get(1).getFitness(ff_2), 0.6, 0.0);
}
Aggregations