ElitisticListPopulation extends ListPopulation { public void setElitismRate(final double elitismRate) throws OutOfRangeException { if (elitismRate < 0 || elitismRate > 1) { throw new OutOfRangeException(LocalizedFormats.ELITISM_RATE, elitismRate, 0, 1); } this.elitismRate = elitismRate; } ElitisticListPopulation(final List<Chromosome> chromosomes, final int populationLimit,
                                   final double elitismRate);  ElitisticListPopulation(final int populationLimit, final double elitismRate); Population nextGeneration(); void setElitismRate(final double elitismRate); double getElitismRate();  }
@Test public void testSetElitismRate() { final double rate = 0.25; final ElitisticListPopulation pop = new ElitisticListPopulation(100, 0.203); pop.setElitismRate(rate); Assert.assertEquals(rate, pop.getElitismRate(), 1e-6); }
@Test(expected = OutOfRangeException.class) public void testSetElitismRateTooLow() { final double rate = -0.25; final ElitisticListPopulation pop = new ElitisticListPopulation(100, 0.203); pop.setElitismRate(rate); }
@Test(expected = OutOfRangeException.class) public void testSetElitismRateTooHigh() { final double rate = 1.25; final ElitisticListPopulation pop = new ElitisticListPopulation(100, 0.203); pop.setElitismRate(rate); }