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

📄 evotsc.java

📁 Java遗传算法库
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        String descr = "";
        int bestHD = -1;
        int LUTInputs = 2;
        boolean spaceForVoter = true;
        boolean locking = false;
        addCombBLIFBenchmark( blifFN, sisQFN, dirName, descr, bestHD, LUTInputs, spaceForVoter, locking );
    }
    
    
    protected  void addDecod() throws IOException
    {
        //System.out.println("22-8-2003");//D
        String blifFN = "/home/mmg20/eh/benchmarks/decod.blif";
        String sisQFN = "/home/mmg20/eh/benchmarks/decod.sout";
        String dirName = "Decod";
        String descr = "Adding Built-In Self-Test to Conventionally Designed Benchmark Circuit Allowing Design Modifications: Decod using 26 gates";
        int bestHD = 1;
        addCombBLIFBenchmarkNoLocking( blifFN, sisQFN, dirName, descr, bestHD );
    }

    protected  void addCM138A() throws IOException
    {
        //System.out.println("22-8-2003");//D
        String blifFN = "/home/mmg20/eh/benchmarks/cm138a.blif";
        String sisQFN = "/home/mmg20/eh/benchmarks/cm138a.sout";
        String dirName = "CM138AUL";
        String descr = "Adding Built-In Self-Test to Conventionally Designed Benchmark Circuit Allowing Design Modifications: Decod using 16 gates";
        int bestHD = 839;
        addCombBLIFBenchmarkNoLocking( blifFN, sisQFN, dirName, descr, bestHD );
    }

    protected  void addF51M() throws IOException
    {
        //System.out.println("22-8-2003");//D
        String blifFN = "/home/mmg20/eh/benchmarks/f51m.blif";
        String sisQFN = "/home/mmg20/eh/benchmarks/f51m.sout";
        String dirName = "F51ML";
        String descr = "Adding Built-In Self-Test to Conventionally Designed Benchmark Circuit Without Allowing Design Modifications: F51M using 112 gates";
        int bestHD = 972;
        addCombBLIFBenchmark( blifFN, sisQFN, dirName, descr, bestHD );
    }
    
    protected  void addTCON() throws IOException
    {
        //System.out.println("22-8-2003");//D
        String blifFN = "/home/mmg20/eh/benchmarks/tcon.blif";
        String sisQFN = "/home/mmg20/eh/benchmarks/tcon.sout";
        String dirName = "FTCONL";
        String descr = "Adding Built-In Self-Test to Conventionally Designed Benchmark Circuit Without Allowing Design Modifications: TCON using 32 gates";
        int bestHD = 1003;
        addCombBLIFBenchmark( blifFN, sisQFN, dirName, descr, bestHD );
    }

    protected  void addBW() throws IOException
    {
        //System.out.println("22-8-2003");//D
        String blifFN = "/home/mmg20/eh/benchmarks/bw.blif";
        String sisQFN = "/home/mmg20/eh/benchmarks/bw.sout";
        String dirName = "BWL";
        String descr = "Locked Benchmark: BW (209 gates)";
        int bestHD = 1677;
        addCombBLIFBenchmark( blifFN, sisQFN, dirName, descr, bestHD );
    }

    


    protected  void addCombBLIFBenchmarkNoLocking( String blifFileName, String sisOutputFileName, String dirName, String descr, int bestIndID ) throws IOException
    {
        final int INPUT_SAMPLE_SEP = 30;    final int SAMPLE_WINDOW_START = 20;
        final int DUMP_POP_EVERY = 500;
        
        final int LUT_INPUTS = 2; boolean spaceForVoter = true;
        
        FitnessFunction corrFF = new CorrelationFitnessFunction();
        FitnessFunction tSetupFF = new SampleWindowFitnessFunction( corrFF, SAMPLE_WINDOW_START  );
        TestPatternGenerator tpg = new CompleteShuffledTPG();
        CombinationalBLIFExperiment experiment = new CombinationalBLIFExperiment( blifFileName, tSetupFF, tpg );
        final int E_LINES = 1;
        final boolean FPGA = false;
        SisOutputReader sor = new SisOutputReader( new File( sisOutputFileName ), E_LINES, LUT_INPUTS, FPGA, spaceForVoter );
        FullOrderGenotype seed = new FullOrderGenotype ( sor.getGenotype() );
        int bitsPerVar = sor.getBitsPerVar();   
        int usedEls = sor.getTotalEls();        
        // A - Genetic Algorithms Properties
        // Standard
        final int POP_SIZE = 32;
        final int GENOTYPE_MUT = 1;
        final int NUM_OF_ELITES = 2;
        // M - Log Properties
        
        // D - DEPLOYMENT set up
        ElementDelayModel delayModel = new CoinDelayModel( );
        //ElementDelayModel delayModel = new GaussianDelayModel( 0.3, 0.3 );
        CircuitMapping circuitMapping = new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + E_LINES, bitsPerVar, LUT_INPUTS, delayModel );
        SimulatorFaultyCircuit circuit = new SimulatorFaultyCircuit( circuitMapping );
        SimulatorDeployment deployment = new SimulatorDeployment( circuit );
        SingleFaultModel faultModel = new SingleUsedFaultModel( circuit, experiment.getNumOfOutputs() );
        
        // A - Genetic Operators Set up
        int nrAddUnits = ( 1 << bitsPerVar ) - experiment.getNumOfInputs();
        int lutSize = 1 << LUT_INPUTS;
        int blockSize = lutSize + LUT_INPUTS * bitsPerVar;
        int genotypeLength = nrAddUnits * blockSize;

        Genotype[] seeds = new Genotype[ POP_SIZE ];
        seeds[ 0 ] = seed;
        for( int pl = 1; pl < POP_SIZE; pl++ )
        {
            seeds[ pl ] = ( FullOrderGenotype ) seed.clone();
            for( int bl = 0; bl < seeds[ pl ].length(); bl++ )
            {
                if( Math.random() < 0.5 )
                {
                    seeds[ pl ].set( bl );
                }
            }
        }
        int howManyBunches = 1;
        GeneticOperator m = new SAGAMutator( genotypeLength / 1000, genotypeLength / 50, 0 );
        //ExactGenotypeMutator m = new ExactGenotypeMutator( ( int ) ( genotypeLength / 500 ) + 1 ); // for biggies
        GeneticOperator spxo = new SinglePointXOver();
        GeneticOperator bmin0 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize );
        GeneticOperator bmin1 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerVar );
        GeneticOperator bmin2 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerVar * 2 );
        GeneticOperator bmin3 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerVar * 3 );
        GeneticOperator bc = new BlockCopy ( blockSize, blockSize, 0 );
        GeneticOperator[] geneticOps = { m, spxo, bmin0, bmin1, bmin2, bmin3, bc };
        double[] opsProbs = { 0.2, 0.3, 0.1, 0.1, 0.1, 0.1, 0.1 };
        if( LUT_INPUTS == 2 )
        {
            geneticOps[ 4 ] = bmin0;
            geneticOps[ 5 ] = bmin1;
        }
        
        Selector selector = new RankSelector(  );
        Evolver evolver = new StandardEvolver( POP_SIZE, genotypeLength, geneticOps, opsProbs, selector, NUM_OF_ELITES, seeds );
        
        PopulationLogReader.fullOrderGenotypes = true;
        int nrEvals = 1;
        int eSize = 10; int eStartAt = 20;
        boolean overdetecting = true;
        CircuitPainterObject painter = new CircuitPainterObject( new CircuitPainter(), new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + E_LINES, bitsPerVar, LUT_INPUTS, new ConstantDelayModel( 0 ) ) ); 
        BISTPIM inIm = new BISTPIM( evolver, deployment, circuit, experiment, faultModel, eSize, eStartAt, overdetecting, INPUT_SAMPLE_SEP, painter );
        int[] numProps = { 2 };
        InteractionModel noisyIM = new NoisyPIM( inIm, deployment, experiment, numProps, nrEvals );
        double maxSize = nrAddUnits;        
        InteractionModel interactionModel = new CircuitParsimonyPIM( noisyIM, circuit, maxSize );
        Monica monica = new Monica( interactionModel, DUMP_POP_EVERY, java.lang.Integer.MAX_VALUE );
        painter.setEvoTask( monica );
        monica.setName( dirName );
        taskQ.add( monica );
        taskQNames.add( dirName );
        taskQDescr.add( descr );
        taskQBestIndID.add( new Integer( bestIndID ) );
            ControlLib.writeGNUPlotScript( dirName, logDir, logFileName, 3, false );
            ControlLib.writeWebGraphDaemon( dirName, logDir, logFileName, 3, false, new File(".").getCanonicalPath() + File.separator );            
    }

    /** Called by clients the first time they connect.
     * @param initialParameters Initial parameters from client local configuration.
     * The current client implementation, see
     * InteractiveTaskClient, provides the ip address of
     * the client and the command line paramaters used to
     * launch the client.  These are packaged in a Vector.
     * @return The ID of this client will from now on used for
     * interaction with the server.
     */
    public Object getID(Object initialParameters) throws RemoteException {
        return ies.getID( initialParameters );
    }
    
    /** This will provide the client with the InteractiveTask
     * it should run.
     * @param id The ID provided by the getID method by which the
     * client will always refer to itself.
     * @return The task this client should run.  This could be
     * exactly the same as the one all other clients are
     * running or tailored to this particular client.
     */
    public InteractiveTask getTask(Object id) throws RemoteException {
        return ies.getTask( id );
    }
    
    /** Called by clients when they wish to interact.
     * @param ID the client's ID
     * @param clientTaskOutput the outputs of the client obtained by task.get( null ) on the client task
     * @return whatever should be sent into the client through task.set( )
     */
    public Object interact(Object ID, Object clientTaskOutput) throws RemoteException {
        return ies.interact( ID, clientTaskOutput );
    }    
    
    public String toString()
    {
        String rv = "EvoTSC with IES: " + ies;
        return rv;
    }
    
    
}

⌨️ 快捷键说明

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