All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.cilib.pso.crossover.parentupdate.ElitistParentReplacementStrategy Maven / Gradle / Ivy

Go to download

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