⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 selectintersection.java

📁 遗传算法源代码,实现了选择操作、交叉操作和变异操作
💻 JAVA
字号:
/*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*//** * SelectIntersection Class * * location: net.openai.ai.ga.selection.common.SelectIntersection * */package net.openai.ai.ga.selection.common;import net.openai.ai.ga.selection.*;import net.openai.ai.ga.population.*;import net.openai.ai.ga.cell.*;import java.util.Collection;/** * <code>SelectIntersection</code> is a <code>SelectionAlgorithm</code> * that will return the intersection of the results of two specified <code> * SelectionAlgorithm</code>s. * * @author	Jared Grubb * @version	%I%, %G% * @since	JDK1.3 */public class SelectIntersection implements SelectionAlgorithm {    private SelectionAlgorithm arg1, arg2;    /**     * Creates a new <code>SelectIntersection</code> object for taking the     * intersection of the <code>Population</code>s returned by the two     * passed <code>SelectionAlgorithm</code>s.     *     * @param first the first <code>SelectionAlgorithm</code>     * @param second the second <code>SelectionAlgorithm</code>     */    public SelectIntersection(SelectionAlgorithm first,                       SelectionAlgorithm second) {        this.arg1 = first;        this.arg2 = second;    }    /**     * Returns a <code>Population</code> that represents the intersection     * (disjunction) of the two <code>SelectionAlgorithm</code>s specified in     * the constructor. The return is the result of the first selection     * algorithm with all but the results of the second removed from it via     * <code>Population.removeAllCellsBut()</code> method.     *     * If the first selection algorithm returns a <code>null</code> then a     * <code>NullPointerException</code> will be thrown. If the second one     * returns a <code>null</code>, the the results of the first will be     * returned unchanged.     *     * @param pop  the <code>Population</code> to choose from     * @return the intersection <code>Population</code> of the two selection algorithms     */    public Population selectFromPopulation(Population pop) {        Population toReturn = arg1.selectFromPopulation(pop);        toReturn.removeAllCellsBut(arg2.selectFromPopulation(pop));        return toReturn;    }}/*--- formatting done in "Sun Java Convention" style on 12-28-2000 ---*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -