@Test public void testGetLames() { ESamplingSurvivorGeneration survivorGeneration = mock(ESamplingSurvivorGenerationBasic.class); EpsilonSamplingSelector selector = new EpsilonSamplingSelector(survivorGeneration); Individual first = mock(Individual.class); Individual second = mock(Individual.class); Individual third = mock(Individual.class); Set<Individual> survivors = new HashSet<>(); survivors.add(first); survivors.add(second); Population population = new Population(); population.add(first); population.add(second); population.add(third); when(survivorGeneration.getSurvivors(population, 2)).thenReturn(survivors); Collection<Individual> result = selector.getLames(1, population); verify(survivorGeneration).getSurvivors(population, 2); assertEquals(1, result.size()); assertTrue(result.contains(third)); }
@Override public Collection<Individual> getLames(int lambda, Collection<Individual> population) { int survivorNumber = population.size() - lambda; Set<Individual> survivors = survivorGeneration.getSurvivors(population, survivorNumber); Set<Individual> lames = new HashSet<>(population); lames.removeAll(survivors); return lames; }
EpsilonSamplingSelector implements Selector { @Override public Collection<Individual> getLames(int lambda, Collection<Individual> population) { int survivorNumber = population.size() - lambda; Set<Individual> survivors = survivorGeneration.getSurvivors(population, survivorNumber); Set<Individual> lames = new HashSet<>(population); lames.removeAll(survivors); return lames; } }
EpsilonSamplingSelector implements Selector { @Override public Collection<Individual> getLames(int lambda, Collection<Individual> population) { int survivorNumber = population.size() - lambda; Set<Individual> survivors = survivorGeneration.getSurvivors(population, survivorNumber); Set<Individual> lames = new HashSet<>(population); lames.removeAll(survivors); return lames; } @Inject  EpsilonSamplingSelector(ESamplingSurvivorGeneration survivorGeneration); }
EpsilonSamplingSelector implements Selector { @Override public Collection<Individual> getLames(int lambda, Collection<Individual> population) { int survivorNumber = population.size() - lambda; Set<Individual> survivors = survivorGeneration.getSurvivors(population, survivorNumber); Set<Individual> lames = new HashSet<>(population); lames.removeAll(survivors); return lames; } @Inject  EpsilonSamplingSelector(ESamplingSurvivorGeneration survivorGeneration); @Override Collection<Individual> getParents(int mu, Collection<Individual> population); @Override Collection<Individual> getLames(int lambda, Collection<Individual> population); @Override void init(int maxsize); }
EpsilonSamplingSelector implements Selector { @Override public Collection<Individual> getLames(int lambda, Collection<Individual> population) { int survivorNumber = population.size() - lambda; Set<Individual> survivors = survivorGeneration.getSurvivors(population, survivorNumber); Set<Individual> lames = new HashSet<>(population); lames.removeAll(survivors); return lames; } @Inject  EpsilonSamplingSelector(ESamplingSurvivorGeneration survivorGeneration); @Override Collection<Individual> getParents(int mu, Collection<Individual> population); @Override Collection<Individual> getLames(int lambda, Collection<Individual> population); @Override void init(int maxsize);  }