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

📄 evogodzillabist.java~

📁 Java遗传算法库
💻 JAVA~
字号:
package es.pj.circuits.control;

import es.control.*;
import es.deploy.*;
import es.evolve.*;
import es.experiment.*;
import es.*;

import es.pj.circuits.*;
import es.pj.circuits.experiment.*;
import es.pj.circuits.fpgaft.*;
import es.pj.gral.*;

import islandev.IslandsEvolutionServer;

import debug.DebugLib;

import java.util.Vector;
import java.rmi.*;
import java.io.*;
import java.awt.Point;
/**
 *
 * @author  Michael Garvie
 * @version 
 */
public abstract class EvoGodzillaBIST
{
     static Vector taskQ = new Vector();
     static Vector taskQNames = new Vector();
    
    static String logDir;
    static final String logFileName = "god-ms-log.txt";
    static final double migrationRate = 0.5;
    
    public static void main( String[] args )
    {
        logDir = args[ 0 ];
        //DebugLib.trcLogger.isLogging = true;
        DebugLib.logFileName = logFileName;
        
        //add2MultBISTpF( new SingleFullFaultModel( 28 ) );
        
        
        try
        {
            // I - Two bit mult Single Fault repair
            int usedEls = 1;
            int N = 1;
            FaultModel faultModel = new SingleFullFaultModel( usedEls );
            for( int nl = 0; nl < N; nl++ )
            {
                while( faultModel.hasMoreElements() )
                {
                    Point fault = ( Point ) faultModel.nextElement();
                    addRepair2MultSingle( nl, fault );
                }
                faultModel.reset();
            }
            
            // II - Multiple faults
            
            IslandsEvolutionServer ms = new IslandsEvolutionServer( "Godzilla", taskQ, taskQNames, logDir, migrationRate );
            ms.bindServer();
            //MonicaServer ms = new MonicaServer( "MonicaServer", taskQ, taskQNames, args[ 0 ], 0.5 );
        }catch( Exception e )
        {
            e.printStackTrace();
        }
        
    }
    
    
    private static void addRepair2MultSingle( int ix, Point fault ) throws IOException
    {
        // A - Genetic Algorithms Properties
         final int POP_SIZE = 2;
         final int GENOTYPE_MUT = 1;
         final int NUM_OF_ELITES = 1;
         final double[] RANK_PROBS = { 1d, 0d };
        
        // D -  Circuit Structure Properties
         final int LUT_INPUTS = 4;

        // D - Simulator Properties
         final int SIMULATOR_GATE_DELAY = 1;
         final double T_SETUP = 0.45;

        // M - Log Properties
         int DUMP_POP_EVERY = 100;

        // E - EXPERIMENT set up
        ConfigurableRandomInputExperiment experiment = new MultiplierExperiment( 2, T_SETUP );
        
        // A - Load Seed
        String sisOutputFileName = "/home/mmg20/eh/benchmarks/2multL4.sout";
        int resQ = 0;
        boolean fpga = true;
        boolean voter = false;
        SisOutputReader sor = new SisOutputReader( new File( sisOutputFileName ), resQ, LUT_INPUTS, fpga, voter );
        Genotype seed = new Genotype( sor.getGenotype() );
        System.out.println( seed );
        int bitsPerVar = sor.getBitsPerVar();
        int usedEls = sor.getTotalEls();
        

        // D - DEPLOYMENT set up
        ElementDelayModel delayModel = new CoinDelayModel( );
        CircuitMapping circuitMapping = new FPGALUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs(), bitsPerVar, LUT_INPUTS, delayModel );
        SimulatorFaultyCircuit circuit = new SimulatorFaultyCircuit( circuitMapping );
        int[] fPos = { fault.x };
        int[] fVal = { fault.y };
        circuit.setPersistentFaults( fPos, fVal );
        SimulatorDeployment deployment = new SimulatorDeployment( circuit );

        // A - Genetic Operators Set up
         int genotypeLength = ( ( 1 << bitsPerVar ) - experiment.getNumOfInputs() ) * ( ( 1 << LUT_INPUTS ) + LUT_INPUTS * bitsPerVar );
         int lutSize = 1 << LUT_INPUTS;
        int blockSize = lutSize + LUT_INPUTS * bitsPerVar;

        final Genotype[] SEEDS = { seed };
        GeneticOperator m = new ExactGenotypeMutator( GENOTYPE_MUT );
        GeneticOperator[] geneticOps = { m };
        double[] opsProbs = { 1 };
        
         Selector selector = new RankSelector( RANK_PROBS );
         Evolver evolver = new StandardEvolver( POP_SIZE, genotypeLength, geneticOps, opsProbs, selector, NUM_OF_ELITES, SEEDS );

        InteractionModel interactionModel = new StandardInteractionModel( evolver, deployment, experiment );
        Monica monica = new Monica( interactionModel, DUMP_POP_EVERY, java.lang.Integer.MAX_VALUE );

        String fs = File.separator;
        String faultDesc = "SSA" + fault.x + "." + fault.y;
        String dirName = "Repair" + fs + "2Mult" + fs + faultDesc + fs + ix ;
        monica.setName( dirName );
        taskQ.add( monica );
        taskQNames.add( dirName );
        ControlLib.writeGNUPlotScript( dirName, logDir, logFileName );
    }   
}

⌨️ 快捷键说明

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