CrossoverModule extends OperatorModule { Individual getRandomNotThis(Individual me) { this.population.remove(me); Individual notMe; notMe = this.population.get(rng.nextInt(this.population.size())); this.population.add(me); return notMe; } CrossoverModule(RandomNumberGenerator m, CrossoverOperation xOver); void perform(); Operation getOperation(); void setOperation(Operation op);  }
@Test @SuppressWarnings("empty-statement") public void testGetRandomNotThis() { System.out.println("* CrossoverModule: getRandomNotThis"); Individual me = operands.get(0); operands.remove(operands.get(1)); CrossoverModule instance = new CrossoverModule(rng, new SinglePointCrossover(rng, 0.9)); instance.setPopulation(operands); Individual expResult = operands.get(1); Individual result = instance.getRandomNotThis(me); assertEquals(expResult, result); }