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

📄 evokingkongbist_1.java~

📁 Java遗传算法库
💻 JAVA~
📖 第 1 页 / 共 2 页
字号:
/*
 * MonicaServer.java
 *
 * Created on 16 April 2001, 17:12
 */

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.*;

/**
 *
 * @author  Michael Garvie
 * @version 
 */
public abstract class EvoKingKongBIST
{
     static Vector taskQ = new Vector();
     static Vector taskQNames = new Vector();
    static Vector taskQDescr = new Vector(); // when using database
    static Vector taskQBestIndID = new Vector(); // when using database
    
    static String logDir;
    static final String logFileName = "kk-ms-log.txt";
    static final double migrationRate = 0.1;
    static final boolean log2dbase = true;
    
    public static void main( String[] args )
    {
        logDir = args[ 0 ];
        DebugLib.trcLogger.isLogging = true;
        DebugLib.logFileName = logFileName;

        //addEDLBIST( new SingleFullFaultModel( 14 ) );
        //add2MultLockedBIST();
        try
        {
            //addBeecount();
            //addDecod();
            addC17();
            IslandsEvolutionServer ms = new IslandsEvolutionServer( "KingKong", taskQ, taskQNames, logDir, migrationRate, log2dbase, taskQDescr, taskQBestIndID );
            ms.bindServer();
            //MonicaServer ms = new MonicaServer( "MonicaServer", taskQ, taskQNames, args[ 0 ], 0.5 );
        }catch( java.rmi.RemoteException e )
        {
            System.out.println( e );
        }catch( IOException e )
        {
            e.printStackTrace();
        }
    }
   
   
    private static void addEDLBIST( SingleFaultModel faultModel )
    {

        // A - Genetic Algorithms Properties
        // Standard
         final int POP_SIZE = 32;
         final int GENOTYPE_MUT = 1;
         final double XOVER_PROB = 0.4;
         final double MUTATION_PROB = 0.6;
         final int NUM_OF_ELITES = 2;

        /* 1+1
         final int POP_SIZE = 2;
         final int GENOTYPE_MUT = 2;
         final double XOVER_PROB = 0;
         final double MUTATION_PROB = 1;
         final int NUM_OF_ELITES = 1;

         final double[] RANK_PROBS = { 1d, 0d };
        */
        // D -  Circuit Structure Properties
         final int BITS_PER_VARIABLE = 4;
         final int LUT_INPUTS = 2;

        // 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
        //BooleanFunction boolFunQ = new Add1bitQFun();
        //BooleanFunction boolFunC = new Add1bitCFun();
        // BooleanFunction boolFun = new MUXFunction( 2 , 4 );
        // BooleanFunction boolFun = new VertorHorizFun();
        // BooleanFunction boolFun = new FLEXToneDetectFun();
        ConfigurableRandomInputExperiment experiment = new EdgeDLExperiment( T_SETUP );
         //ConfigurableRandomInputExperiment experimentQ = new ArbitraryFunctionExperiment( boolFunQ, T_SETUP );
        //ConfigurableRandomInputExperiment experimentC = new ArbitraryFunctionExperiment( boolFunC, T_SETUP );
        //ConfigurableRandomInputExperiment[] exps = { experimentQ, experimentC };
        //ConfigurableRandomInputExperiment experiment = new ConfigurableRandomInputMultiOutputExperiment( exps );

        // D - DEPLOYMENT set up
        // SimulatorCircuit circuit = new SimulatorLUTCircuit( SIMULATOR_GATE_DELAY, BITS_PER_VARIABLE , LUT_INPUTS, experiment.getNumOfInputs(), experiment.getNumOfOutputs() );
        //ElementDelayModel delayModel = new ConstantDelayModel( SIMULATOR_GATE_DELAY );
        //ElementDelayModel delayModel = new GaussianDelayModel( 0.5, 0.4 );
        ElementDelayModel delayModel = new CoinDelayModel( );
        CircuitMapping circuitMapping = new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + 1, BITS_PER_VARIABLE, LUT_INPUTS, delayModel );
        SimulatorFaultyCircuit circuit = new SimulatorFaultyCircuit( circuitMapping );
        SimulatorDeployment deployment = new SimulatorDeployment( circuit );

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

        //final Genotype SEED0 = new FullOrderGenotype( "011100100011011000000111000101001111010011110000011101010110001011101111000111110100011110001001000110101111010011110111011110111100001011101111000111111010000000000000" );
        final Genotype SEED0 = new FullOrderGenotype( genotypeLength );
        //final Genotype SEED0 = new FullOrderGenotype( "TBO_PMG]JgUsO9URJuJn6q7lJuPM", genotypeLength, 6 );
        // final Genotype SEED2 = new Genotype( "2GS_i17CiQY8ELA2eO6ZJ8eMnPDTC_jrLtUVdjDG8EEQS\\beNi9PKfu87Jjc3jRiaIqH[ALYJsE11WIqSMRIgj04oBe09jKAhLiLaMVU_08qdSQaImCtgaB4cc[3r3raARcfpAJli0jWiJ0kq4Nk0WPF64USqpH2gi3bBKu2]SRe`cCfknjBqEMKTO7Iu5ru1_THNb72V3n6rWD824uaHW0etY9[[Iv9KTBf`gtYM_AhAq6hNldYCEAdb1i0", genotypeLength, 6 );
        // final Genotype[] SEEDS = { SEED0, SEED1, SEED2 };
         //final Genotype[] SEEDS = { SEED0, SEED1 };
        // final Genotype[] SEEDS = { SEED0 };
        //final Genotype[] SEEDS = { };
        Genotype[] SEEDS = new Genotype[ POP_SIZE ];
        SEEDS[ 0 ] = SEED0;
        for( int pl = 0; pl < POP_SIZE; pl++ )
        {
            SEEDS[ pl ] = ( FullOrderGenotype ) SEED0.clone();
            for( int bl = 0; bl < SEEDS[ pl ].length(); bl++ )
            {
                if( Math.random() < 0.5 )
                {
                    SEEDS[ pl ].set( bl );
                }
            }
        }
        GeneticOperator m = new SAGAMutator( 1, 10 );
        GeneticOperator spxo = new SinglePointXOver();        
        GeneticOperator bmin0 = new BunchMutator( BITS_PER_VARIABLE, 1, blockSize, lutSize );
        GeneticOperator bmin1 = new BunchMutator( BITS_PER_VARIABLE, 1, blockSize, lutSize + BITS_PER_VARIABLE );
        GeneticOperator bc = new BlockCopy ( blockSize, blockSize );
        
        GeneticOperator[] geneticOps = { m, spxo, bmin0, bmin1, bc };
        double[] opsProbs = { 0.3, 0.1, 0.2, 0.2, 0.2 };
        
         /* 1+1
         GeneticOperator[] geneticOps = { m };
         double[] opsProbs = { MUTATION_PROB };
         */
        // Selector selector = new FitnessProportionateSelector();
         Selector selector = new RankSelector(  );
         Evolver evolver = new StandardEvolver( POP_SIZE, genotypeLength, geneticOps, opsProbs, selector, NUM_OF_ELITES, SEEDS );

        //SingleFaultModel faultModel = new SingleStaticFaultModel( fPos );
        
        //InteractionModel interactionModel = new StandardInteractionModel( evolver, deployment, experiment );
        PopulationLogReader.fullOrderGenotypes = true;
        int eSize = 15;
        int nrEvals = 30;
        boolean overdetecting = true;
        BISTPIM inIm = new BISTPIM( evolver, deployment, circuit, experiment, faultModel, eSize, overdetecting );
        inIm.sequentialCircuit = true;
        int[] numProps = { 2 };
        InteractionModel noisyIM = new NoisyPIM( inIm, deployment, experiment, numProps, nrEvals );
        InteractionModel interactionModel = new CircuitParsimonyPIM( noisyIM, circuit );
         int[] evolutionFrequency = { 1 , 4 };
         //InteractionModel interactionModel = new CircuitTestPatternIM( evolvers, deployment, experiments, evolutionFrequency );

         Monica monica = new Monica( interactionModel, DUMP_POP_EVERY, java.lang.Integer.MAX_VALUE );
        
        String dirName = "EDLBIST-2";
        monica.setName( dirName );
        taskQ.add( monica );
        taskQNames.add( dirName );
        taskQDescr.add( "Edge-Triggered D-Latch with Built-In Self-Test" );
        taskQBestIndID.add( new Integer( 2 ) );
        ControlLib.writeGNUPlotScript( dirName, logDir, logFileName, 3, false );
    }
    
    private static void add2MultLockedBIST( )
    {
        SingleFaultModel faultModel = new SingleFullFaultModel( 8 ); // from el0 to el7 inc
        
        // A - Genetic Algorithms Properties
        // Standard
         final int POP_SIZE = 32;
         final int GENOTYPE_MUT = 1;
         final double XOVER_PROB = 0.4;
         final double MUTATION_PROB = 0.6;
         final int NUM_OF_ELITES = 2;

        // D -  Circuit Structure Properties
         final int BITS_PER_VARIABLE = 5;
         final int LUT_INPUTS = 2;

        // 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
        int multWidth = 2;
        ConfigurableRandomInputDeterministicExperiment experiment = new MultiplierExperiment( multWidth, T_SETUP );
        
        // D - DEPLOYMENT set up
        // SimulatorCircuit circuit = new SimulatorLUTCircuit( SIMULATOR_GATE_DELAY, BITS_PER_VARIABLE , LUT_INPUTS, experiment.getNumOfInputs(), experiment.getNumOfOutputs() );
        //ElementDelayModel delayModel = new ConstantDelayModel( SIMULATOR_GATE_DELAY );
        //ElementDelayModel delayModel = new GaussianDelayModel( 0.5, 0.4 );
        ElementDelayModel delayModel = new CoinDelayModel( );
        CircuitMapping circuitMapping = new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + 1, BITS_PER_VARIABLE, LUT_INPUTS, delayModel );
        SimulatorFaultyCircuit circuit = new SimulatorFaultyCircuit( circuitMapping );
        SimulatorDeployment deployment = new SimulatorDeployment( circuit );

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

        final Genotype SEED0 = new FullOrderGenotype( "00010010100110011000000001110110001010011000011111011100001101000000000001111101110100011110011111000111101111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ); // Hand designed HDCompact7 with unit 4 (E) routed to unit 8.
        //final Genotype SEED0 = new FullOrderGenotype( genotypeLength );
        //final Genotype SEED0 = new FullOrderGenotype( "TBO_PMG]JgUsO9URJuJn6q7lJuPM", genotypeLength, 6 );
        // final Genotype SEED2 = new Genotype( "2GS_i17CiQY8ELA2eO6ZJ8eMnPDTC_jrLtUVdjDG8EEQS\\beNi9PKfu87Jjc3jRiaIqH[ALYJsE11WIqSMRIgj04oBe09jKAhLiLaMVU_08qdSQaImCtgaB4cc[3r3raARcfpAJli0jWiJ0kq4Nk0WPF64USqpH2gi3bBKu2]SRe`cCfknjBqEMKTO7Iu5ru1_THNb72V3n6rWD824uaHW0etY9[[Iv9KTBf`gtYM_AhAq6hNldYCEAdb1i0", genotypeLength, 6 );
        // final Genotype[] SEEDS = { SEED0, SEED1, SEED2 };
         //final Genotype[] SEEDS = { SEED0, SEED1 };
        // final Genotype[] SEEDS = { SEED0 };
        //final Genotype[] SEEDS = { };
        Genotype[] SEEDS = new Genotype[ POP_SIZE ];
        SEEDS[ 0 ] = SEED0;
        for( int pl = 1; pl < POP_SIZE; pl++ )
        {
            SEEDS[ pl ] = ( FullOrderGenotype ) SEED0.clone();
            for( int bl = 0; bl < SEEDS[ pl ].length(); bl++ )
            {
                if( Math.random() < 0.5 )
                {
                    SEEDS[ pl ].set( bl );
                }
            }
        }
        
        int fixedAlignments = 8;
        int howManyBunches = 1;
        //GeneticOperator m = new SAGAMutator( 1, 10 );
        ExactGenotypeMutator m = new ExactGenotypeMutator( 1 );
        m.setRange( fixedAlignments * blockSize, -1 );
        GeneticOperator spxo = new SinglePointXOver();        
        GeneticOperator bmin0 = new BunchMutator( BITS_PER_VARIABLE, howManyBunches, blockSize, lutSize, fixedAlignments );

⌨️ 快捷键说明

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