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

net.sourceforge.cilib.algorithm.population.knowledgetransferstrategies.SelectiveKnowledgeTransferStrategy Maven / Gradle / Ivy

Go to download

A library of composable components enabling simpler Computational Intelligence

There is a newer version: 0.8
Show newest version
/**           __  __
 *    _____ _/ /_/ /_    Computational Intelligence Library (CIlib)
 *   / ___/ / / / __ \   (c) CIRG @ UP
 *  / /__/ / / / /_/ /   http://cilib.net
 *  \___/_/_/_/_.___/
 */
package net.sourceforge.cilib.algorithm.population.knowledgetransferstrategies;

import java.util.List;
import net.sourceforge.cilib.algorithm.population.MultiPopulationBasedAlgorithm;
import net.sourceforge.cilib.algorithm.population.PopulationBasedAlgorithm;
import net.sourceforge.cilib.entity.Entity;
import net.sourceforge.cilib.type.types.Type;
import net.sourceforge.cilib.util.selection.recipes.ElitistSelector;
import net.sourceforge.cilib.util.selection.recipes.RingBasedPopulationSelector;
import net.sourceforge.cilib.util.selection.recipes.Selector;

/**
 * 

* An implementation of {@link KnowledgeTransferStrategy} where two {@link Selection} * instances are used to first select a sub-population ({@link PopulationBasedAlgorithm}) from * a collection of population-based algorithms (see {@link MultiPopulationBasedAlgorithm) and then * within this sub-population's {@link Topology}, which entity's knowledge is to be transferred * to the caller requesting it. *

* */ public class SelectiveKnowledgeTransferStrategy implements KnowledgeTransferStrategy { private static final long serialVersionUID = 402688951924934682L; private Selector populationSelection; private Selector entitySelection; public SelectiveKnowledgeTransferStrategy() { this.populationSelection = new RingBasedPopulationSelector(); this.entitySelection = new ElitistSelector(); } public SelectiveKnowledgeTransferStrategy(SelectiveKnowledgeTransferStrategy copy) { this.populationSelection = copy.populationSelection; this.entitySelection = copy.entitySelection; } @Override public SelectiveKnowledgeTransferStrategy getClone() { return new SelectiveKnowledgeTransferStrategy(this); } public void setPopulationSelection(Selector populationSelection) { this.populationSelection = populationSelection; } public Selector getPopulationSelection() { return this.populationSelection; } public void setEntitySelection(Selector entitySelection) { this.entitySelection = entitySelection; } public Selector getEntitySelection() { return this.entitySelection; } @Override public Type transferKnowledge(List allPopulations) { PopulationBasedAlgorithm population = this.populationSelection.on(allPopulations).select(); Entity entity = this.entitySelection.on((Iterable) population.getTopology()).select(); return entity.getProperties(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy