EliteOperationSelection extends SelectionOperation { Fitness[] rankPopulation(List<Individual> operands){ Fitness[] fAt = new Fitness[operands.size()]; for(int i=0;i<fAt.length;i++) { fAt[i] = operands.get(i).getFitness(); } Arrays.sort(fAt); return fAt; } EliteOperationSelection(int size);  EliteOperationSelection(Properties p); @Override void setProperties(Properties p); boolean isEvaluateElites(); void doOperation(Individual operand); void doOperation(List<Individual> operands); void setEvaluate_elites(boolean evaluate_elites);  }
@Test public void testRankPopulation() { System.out.println("* EliteOperationSelection: rankPopulation"); List<Individual> operands = new ArrayList<Individual>(); operands.add(IndividualMaker.makeIndividual()); operands.get(0).getFitness().setDouble(2.0); operands.add(IndividualMaker.makeIndividual()); operands.get(1).getFitness().setDouble(1.0); EliteOperationSelection instance = new EliteOperationSelection(1); instance.setEvaluate_elites(false); instance.doOperation(operands); Fitness[] expResult = {operands.get(1).getFitness(), operands.get(0).getFitness()}; Fitness[] res = instance.rankPopulation(operands); assertEquals(expResult.length, res.length); assertArrayEquals(expResult, res); }