Esempio n. 1
0
  @Test
  // tests concatenation of single EMPTY Population
  public void testConcatenate4() throws Exception {
    SimplePopulation pop1 = new SimplePopulation();

    Individual[] indOut =
        PopulationUtils.concatenate(new Population[] {pop1}, new SimplePopulationFactory())
            .getIndividuals();

    assertTrue(pop1.getIndividuals() == indOut || indOut.length == 0);
  }
Esempio n. 2
0
  @Test
  // tests concatenation of single Population - creation of new array of Individual
  public void testConcatenate3() throws Exception {
    SimpleIndividual[] ind1 =
        new SimpleIndividual[] {
          new SimpleIndividual(1, 1.0, null),
          new SimpleIndividual(2, 3.0, null),
          new SimpleIndividual(5, 3.0, null)
        };
    SimplePopulation pop1 = new SimplePopulation(ind1);

    Individual[] indOut =
        PopulationUtils.concatenate(new Population[] {pop1}, new SimplePopulationFactory())
            .getIndividuals();

    assertTrue(indOut[0] == ind1[0]);
    assertTrue(indOut[1] == ind1[1]);
    assertTrue(indOut[2] == ind1[2]);
    assertNotSame(pop1.getIndividuals(), indOut);
    assertNotSame(ind1, indOut);
    assertTrue(indOut.length == ind1.length);
  }