コード例 #1
0
  @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
ファイル: StandardPattern.java プロジェクト: vervas/cilib
 /**
  * Convenience constructor setting the vector and target.
  *
  * @param vector the new pattern's vector.
  * @param target the new pattern's target.
  */
 public StandardPattern(Vector vector, Type target) {
   this.vector = Vector.copyOf(vector);
   this.target = target.getClone();
 }
コード例 #3
0
 /**
  * Constructs a new instance of {@code OptimisationSolution}.
  *
  * @param position The position of the solution within the search space of the problem.
  * @param fitness The fitness of the optimisation solution.
  */
 public OptimisationSolution(Type position, Fitness fitness) {
   this.position = position.getClone();
   this.fitness = fitness.getClone();
 }