net.sourceforge.cilib.pso.crossover.parentupdate.ElitistParentReplacementStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cilib-library Show documentation
Show all versions of cilib-library Show documentation
A library of composable components enabling simpler Computational Intelligence
The newest version!
/** __ __
* _____ _/ /_/ /_ Computational Intelligence Library (CIlib)
* / ___/ / / / __ \ (c) CIRG @ UP
* / /__/ / / / /_/ / http://cilib.net
* \___/_/_/_/_.___/
*/
package net.sourceforge.cilib.pso.crossover.parentupdate;
import com.google.common.collect.Lists;
import java.util.List;
import net.sourceforge.cilib.pso.particle.Particle;
import net.sourceforge.cilib.util.selection.Samples;
import net.sourceforge.cilib.util.selection.recipes.ElitistSelector;
/**
* This ParentReplacementStrategy selects the best particles from both the parents
* and the offspring.
*/
public class ElitistParentReplacementStrategy extends ParentReplacementStrategy {
@Override
public List f(List parents, List offspring) {
List joined = Lists.newArrayList(parents);
joined.addAll(offspring);
return new ElitistSelector().on(joined).select(Samples.first(parents.size()));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy