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

net.sourceforge.cilib.coevolution.cooperative.contributionselection.SocialFitnessContributionSelectionStrategy 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.coevolution.cooperative.contributionselection;

import java.util.Comparator;
import net.sourceforge.cilib.algorithm.population.SinglePopulationBasedAlgorithm;
import net.sourceforge.cilib.entity.MemoryBasedEntity;
import net.sourceforge.cilib.entity.SocialEntity;
import net.sourceforge.cilib.entity.Topologies;
import net.sourceforge.cilib.entity.comparator.SocialBestFitnessComparator;
import net.sourceforge.cilib.type.types.container.Vector;

/**
 * Select the contribution based on the best position of the social best entity of the
 * {@linkplain PopulationBasedAlgorithm}.
 *
 */
public class SocialFitnessContributionSelectionStrategy implements
        ContributionSelectionStrategy {
    private static final long serialVersionUID = -2477638582277950895L;

    /**
     * {@inheritDoc}
     */
    @Override
    public Vector getContribution(SinglePopulationBasedAlgorithm algorithm) {
        MemoryBasedEntity entity = (MemoryBasedEntity) Topologies.getBestEntity(algorithm.getTopology(),
                (Comparator) new SocialBestFitnessComparator());
        return (Vector) entity.getBestPosition();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ContributionSelectionStrategy getClone() {
        return this;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy