Search in sources :

Example 1 with FON

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);
}
Also used : NSGAChromosome(org.evosuite.ga.NSGAChromosome) FON(org.evosuite.ga.problems.multiobjective.FON) ArrayList(java.util.ArrayList) Problem(org.evosuite.ga.problems.Problem) FitnessFunction(org.evosuite.ga.FitnessFunction) FONIntTest(org.evosuite.ga.problems.multiobjective.FONIntTest) Test(org.junit.Test)

Example 2 with FON

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);
}
Also used : NSGAChromosome(org.evosuite.ga.NSGAChromosome) FON(org.evosuite.ga.problems.multiobjective.FON) ArrayList(java.util.ArrayList) Problem(org.evosuite.ga.problems.Problem) FitnessFunction(org.evosuite.ga.FitnessFunction) FONIntTest(org.evosuite.ga.problems.multiobjective.FONIntTest) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 FitnessFunction (org.evosuite.ga.FitnessFunction)2 NSGAChromosome (org.evosuite.ga.NSGAChromosome)2 Problem (org.evosuite.ga.problems.Problem)2 FON (org.evosuite.ga.problems.multiobjective.FON)2 FONIntTest (org.evosuite.ga.problems.multiobjective.FONIntTest)2 Test (org.junit.Test)2