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

📄 simplexlist.java

📁 模拟退火是一种启发式算法
💻 JAVA
字号:
package org.theblueplanet.annealing;import org.apache.log4j.Logger;import java.util.ArrayList;/** *  An ArrayList of Simplex Objects * * @see org.theblueplanet.annealing.Simplex * * @author     Charles M間nin * @since    October 29, 2001 * @version    1.0 */public class SimplexList {    private Logger logger = Logger.getLogger(this.getClass().toString());    private ArrayList list;    private final static double MAXVALUE = -1.0e100;    /**     *  Constructor for the SimplexList object     *     * @param  itol  Description of Parameter     */    public SimplexList(int itol) {        this.list = new ArrayList(itol);    }    /**     *  Gets the Index the Simplex with the maximum value field in the     *  SimplexList     *     * @return    The index of the Simplex with the highest value field     */    public int getIndexOfMax() {        double max  = MAXVALUE;        int index   = -1;        for (int ii = 0; ii < list.size(); ii++) {            if (((Simplex) list.get(ii)).getValue() > max) {                max = ((Simplex) list.get(ii)).getValue();                index = ii;            }        }        return index;    }    /**     *  Gets the Index the Simplex with the minimum value field in the     *  SimplexList     *     * @return    The index of the Simplex with the lowest value field     */    public Simplex getMinSimplex() {        double min          = -MAXVALUE;        Simplex minSimplex  = null;        for (int ii = 0; ii < list.size(); ii++) {            if (((Simplex) list.get(ii)).getValue() < min) {                minSimplex = (Simplex) list.get(ii);                min = ((Simplex) list.get(ii)).getValue();            }        }        return minSimplex;    }    /**     *  Add a Simplex object to the ArrayList     *     * @param  simplex  Description of Parameter     */    public void add(Simplex simplex) {        list.add(simplex);    }    /**     *  Computes the difference between the maximum and the minimum values of     *  the elements of the SimplexList, <b>excluding the last Simplex added</b>     *     * @return    The spread     */    public double spread() {        double max  = MAXVALUE;        double min  = -max;        for (int ii = 0; ii < list.size() - 1; ii++) {            if (((Simplex) list.get(ii)).getValue() > max) {                max = ((Simplex) list.get(ii)).getValue();            }            if (((Simplex) list.get(ii)).getValue() < min) {                min = ((Simplex) list.get(ii)).getValue();            }        }        return max - min;    }    /**     *  Recursively calls the toScreen() method on all Simplex objects of the     *  ArrayList     *     * @see org.theblueplanet.annealing.Simplex#toScreen()     */    public void toScreen() {        for (int ii = 0; ii < list.size(); ii++) {            ((Simplex) list.get(ii)).toScreen();        }    }    /**     *  Returns the size of the ArrayList     *     * @return    The number of Simplex objects in the SimplexList     */    public int size() {        return list.size();    }    /**     *  Removes a Simplex from the SimplexList     *     * @param  ii  The index of the Simplex to be removed     */    public void remove(int ii) {        list.remove(ii);    }}

⌨️ 快捷键说明

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