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

📄 vassilevmapping.java~

📁 Java遗传算法库
💻 JAVA~
字号:
/*
 * VassilevMapping.java
 *
 * Created on October 28, 2002, 3:18 PM
 */
package es.pj.circuits.fpgaft;

import es.pj.circuits.*;
import es.BitSet;

/** Circuit Mapping such that it:
 *<p>uses LUTS.
 *<p>has fixed genotype length and number of units
 *<p>has fixed indexes for the inputs being N-I..N-1 where I is nr of inputs and N nr of units
 *<p>has variable indexes for the Q outputs defined by the first Q*bpv genotype bits
 *
 * @author  Michael Garvie
 * @version 
 */
public class VassilevMapping implements CircuitMapping {

    protected int bitsPerVar, nrOuts;
    protected CircuitMapping inMap;
    
    public VassilevMapping(int bitsPerVar, int nrOuts, CircuitMapping inMap )
    {
        this.bitsPerVar = bitsPerVar;
        this.nrOuts = nrOuts;
        this.inMap = inMap;
    }
        
    public SimulatorLogicElement[][] map( BitSet genotype )
    {
        int genLen = genotype.length();
        int qDefLen = bitsPerVar * nrOuts;
        int noQDefGenLen = genLen - qDefLen;
        BitSet noQDefGenotype = new BitSet( noQDefGenLen );
        for( int bl = 0; bl < noQDefGenLen; bl++ )
        {
            noQDefGenotype.setTo( bl, genotype.get( qDefLen + bl ) );
        }
        SimulatorLogicElement[][] rv = inMap.map( noQDefGenotype );
        SimulatorLogicElement[] outs = rv[ CircuitMapping.OUTPUTS ];
        for( int ql = 0; ql < nrOuts; ql++ )
        {
            int currQAddr = genotype.bitsToInt( ql * bitsPerVar, ( ql + 1 ) * bitsPerVar );
            outs[ ql ] = inMap.getElementFromAddress( rv, currQAddr );
        }
        return rv;
    }
    
    public String toString()
    {
        String rv = "VassilevMapping with internal Mapping:  " + inMap;
        return rv;
    }
 
    public void resetDelays( Object delayDef )
    {
        inMap.resetDelays( delayDef );
    }
    
    public SimulatorLogicElement getElementFromAddress(SimulatorLogicElement[][] inoutels, int address) {
        return inMap.getElementFromAddress( inoutels, address );
    }
    
}

⌨️ 快捷键说明

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