@Test
  public void testBiDistribution() {
    Algorithm algorithm = mock(Algorithm.class);

    MOFitness fitness01 =
        Fitnesses.create(new MinimisationFitness(3.0), new MinimisationFitness(0.0));
    final Type type01 = mock(Type.class, "type2_01");

    MOFitness fitness02 =
        Fitnesses.create(new MinimisationFitness(2.0), new MinimisationFitness(1.0));
    final Type type02 = mock(Type.class, "type2_02");

    // Cloning returns the mocked objects themselves.
    when(type01.getClone()).thenReturn(type01);
    when(type02.getClone()).thenReturn(type02);

    OptimisationSolution solution01 = new OptimisationSolution(type01, fitness01);
    OptimisationSolution solution02 = new OptimisationSolution(type02, fitness02);

    Archive archive = Archive.Provider.get();
    archive.add(solution01);
    archive.add(solution02);

    Real distribution = new SolutionDistribution().getValue(algorithm);
    Assert.assertEquals(0.0, distribution.doubleValue(), 0.0000000000001);
  }
示例#2
0
  @Test
  public void results() {
    Algorithm algorithm = this.mockery.mock(Algorithm.class);

    MOFitness fitness01 =
        Fitnesses.create(new MinimisationFitness(0.0), new MinimisationFitness(1.0));
    final Type type01 = this.mockery.mock(Type.class, "type_01");

    MOFitness fitness02 =
        Fitnesses.create(new MinimisationFitness(0.5), new MinimisationFitness(0.5));
    final Type type02 = this.mockery.mock(Type.class, "type_02");

    MOFitness fitness03 =
        Fitnesses.create(new MinimisationFitness(1.0), new MinimisationFitness(0.0));
    final Type type03 = this.mockery.mock(Type.class, "type_03");

    // Cloning returns the mocked objects themselves.
    this.mockery.checking(
        new Expectations() {

          {
            oneOf(type01).getClone();
            will(returnValue(type01));
            oneOf(type02).getClone();
            will(returnValue(type02));
            oneOf(type03).getClone();
            will(returnValue(type03));
          }
        });

    OptimisationSolution solution01 = new OptimisationSolution(type01, fitness01);
    OptimisationSolution solution02 = new OptimisationSolution(type02, fitness02);
    OptimisationSolution solution03 = new OptimisationSolution(type03, fitness03);

    Archive archive = Archive.Provider.get();
    archive.add(solution01);
    archive.add(solution02);
    archive.add(solution03);

    Real extent = new ParetoFrontExtent().getValue(algorithm);
    Assert.assertEquals(Math.sqrt(2.0), extent.doubleValue(), 0.00001);
  }
示例#3
0
  @Test
  public void results() {
    Algorithm algorithm = this.mockery.mock(Algorithm.class);

    MOFitness fitness01 =
        Fitnesses.create(new MinimisationFitness(0.0), new MinimisationFitness(1.0));
    final Type type01 = this.mockery.mock(Type.class, "type_01");

    MOFitness fitness02 =
        Fitnesses.create(new MinimisationFitness(0.5), new MinimisationFitness(0.5));
    final Type type02 = this.mockery.mock(Type.class, "type_02");

    MOFitness fitness03 =
        Fitnesses.create(new MinimisationFitness(1.0), new MinimisationFitness(0.0));
    final Type type03 = this.mockery.mock(Type.class, "type_03");

    // Cloning returns the mocked objects themselves.
    this.mockery.checking(
        new Expectations() {

          {
            oneOf(type01).getClone();
            will(returnValue(type01));
            oneOf(type02).getClone();
            will(returnValue(type02));
            oneOf(type03).getClone();
            will(returnValue(type03));
          }
        });

    OptimisationSolution solution01 = new OptimisationSolution(type01, fitness01);
    OptimisationSolution solution02 = new OptimisationSolution(type02, fitness02);
    OptimisationSolution solution03 = new OptimisationSolution(type03, fitness03);

    Archive archive = Archive.Provider.get();
    archive.add(solution01);
    archive.add(solution02);
    archive.add(solution03);

    Int solutionCount = new NumberOfSolutions().getValue(algorithm);
    assertThat(solutionCount.intValue(), is(equalTo(3)));
  }
示例#4
0
 @AfterClass
 public static void teardown() {
   Archive.Provider.get().clear();
 }
 @After
 public void reset() {
   Archive.Provider.get().clear();
 }