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

📄 cell.java

📁 遗传算法源代码,实现了选择操作、交叉操作和变异操作
💻 JAVA
字号:
/*--- formatted by Jindent 2.1, (www.c-lab.de/~jindent) ---*//** * Cell Interface * * location: net.openai.ai.ga.cell.Cell * */package net.openai.ai.ga.cell;import net.openai.ai.ga.environment.*;import net.openai.ai.ga.population.*;/** * The <code>Cell</code> interface is an encapsulation of data that will * be used to try to solve a problem (<code>Environment</code>). It is * provided as an Interface to allow for maximum flexibility in the * implementation of the solution. The <code>Cell</code>s must know how * to interact with the <code>Environment</code>, as none of that is provided * here. A <code>Cell</code> must know how to perform the following functions: * <ul> *   <li>Mature (or age) *   <li>Evaluate *   <li>Return its fitness as an integer *   <li>Combine (or reproduce) *   <li>Mutate * </ul> * * @author	Jared Grubb * @version	%I%, %G% * @since	JDK1.3 */public interface Cell {    /**     * Return the fitness of the <code>Cell</code>. This call does not     * neccessarily require that a new evaluation is performed, only that     * the last fitness generated is desired. This is the preferred method     * for any function curious about the cell's fitness as it should not     * require any complex calculations. The fitness must be quantifiable     * as an integer.     *     * @return	a <code>double</code> representing the fitness of this     *           <code>Cell</code>     */    public double getFitness();    /**     * Return the fitness of the <code>Cell</code>. This call asks that a new     * evaluation is performed. This method is called during every iteration     * of a <code>Population</code>. The implementation must determine whether     * a new evaluation is required or whether the last returned value will     * suffice. The fitness must be quantifiable as an integer. This function     * should only be called if there is reason to ask for a new value, but     * should be generally avoided since it may require extra overhead.     *     * @param env	the <code>Environment</code> to evaluate against     * @return	a <code>double</code> representing the fitness of this     *           <code>Cell</code>     */    public double evaluateFitness(Environment env);    /**     * Returns the maturity of the <code>Cell</code>.     *     * @return	the maturity of this <code>Cell</code>     */    public int getMaturity();    /**     * Tells the cell that it has been condemned to die. This allows for any     * extra clean-up necessary or for record-keeping of cells that are     * removed from a population. It is not required that the Cell destroy     * itself or any objects, but is provided as notification that the Cell     * will be removed from the population.     */    public void condemn();    /**     * Tells the cell that it has been chosen to mutate.     */    public void mutate();    /**     * Tells the cell to mature. This function is called before evaluation     * on the cells. Outside calling of this function should be avoided as it     * may cause over-maturation of a cell. This function may also be as     * simple as incrementing the age of the cell.     */    public void mature();    /**     * Tells the cell to create new offspring, which will be placed in     * the population. The offspring should be new <code>Cell</codes created     * by some combination of the parents and should also be initialized with     * data. The instance of <code>Cell</code> called is the first Cell in the     * <code>Population</code>.     *     * @param parents	the chosen <code>Population</code> of parents for     *				the new cell     * @return	a new <code>Population</code> to be added into the population     */    public Population combine(Population parents);}/*--- formatting done in "Sun Java Convention" style on 12-28-2000 ---*/

⌨️ 快捷键说明

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