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

📄 optimizedmapping.java~

📁 Java遗传算法库
💻 JAVA~
字号:
/* * OptimizedMapping.java * * Created on 25 November 2003, 15:39 */package es.pj.circuits;import es.BitSet;import es.pj.circuits.*;import java.util.Vector;/** This will remove elements from the element array that aren't connected to the outputs * in order to optimize the circuit simulation by avoiding refreshing unused gates.  This will * obviously skew the position of these elements in the array making the getElementFromAddress * method useless. * * @author  mmg20 */public class OptimizedMapping implements CircuitMapping {        protected CircuitMapping inMap;        /** Creates a new instance of OptimizedMapping */    public OptimizedMapping( CircuitMapping inMap ) {        this.inMap = inMap;    }        public SimulatorLogicElement getElementFromAddress(SimulatorLogicElement[][] inoutels, int address) {        return inMap.getElementFromAddress( inoutels, address );    }        /** Takes and individual and an array of arrays of logic elements where this     * individual must be instantiated.     * @param individual The individual to be mapped into a circuit.     * @return Array consisting of three subarrays: The first will represent     * the inputs to the circuit and is where the inputs will be fed in.  The second     * represents the elements that are the outputs of the circuit and is where they     * will be read out from.  The last is an array with all the elements of the     * circuit.     */    public SimulatorLogicElement[][] map(BitSet individual)     {        SimulatorLogicElement[][] rv = inMap.map( individual );                int nrOuts = rv[ OUTPUTS ].length;        Vector added = CircuitsLib.addConnectedGates( rv[ OUTPUTS ] );        int nrUsed = added.size();        SimulatorLogicElement[] onlyUsedElements = new SimulatorLogicElement[ nrUsed ];                // Qs always        for( int ol = 0; ol < Math.min( nrOuts, nrUsed ); ol++ )        {            onlyUsedElements[ ol ] = rv[ ELEMENTS ][ ol ];            added.remove( rv[ ELEMENTS ][ ol ] );        }        // The rest can go in any order        for( int ll = 0; ll < nrUsed - nrOuts; ll++ )        {            onlyUsedElements[ ll + nrOuts ] = ( SimulatorLogicElement ) added.get( ll );            //System.out.println("El " + ( ll + nrOuts ) + " in opt is " + es.ESLib.indexOf( onlyUsedLUTs[ ll + nrOuts ], elements ) + " in all " ); //D        }                rv[ ELEMENTS ] = onlyUsedElements;        return rv;    }        public void resetDelays(Object delayDef) {        inMap.resetDelays( delayDef );    }    }

⌨️ 快捷键说明

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