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

📄 evokingkongbist.java~

📁 Java遗传算法库
💻 JAVA~
📖 第 1 页 / 共 4 页
字号:
        GeneticOperator bmin3 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + 3 * bitsPerVar, fixedAlignments, qDefSize );
        GeneticOperator bc = new BlockCopy ( blockSize, blockSize, 0, fixedAlignments, qDefSize );
        GeneticOperator[] geneticOps ={ m,      spxo,   bmin0,  bmin1,  bmin2,  bmin3,  bc      };
        double[] opsProbs =          {  0.3,    0.2,    0.1,    0.1  ,  0.1  ,  0.1  ,  0.1     };
        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 = 3;  int startAt = 3;
        CircuitPainterObject painter = new CircuitPainterObject( new CircuitPainter(), new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + E_LINES, bitsPerVar, LUT_INPUTS, new ConstantDelayModel( 0 ) ) ); 
        double[] thresholds = { 0.1, 0.1, 0.1 };    int avgRound = 1;   int faultDepth = 4;
        boolean simpleMode = true;  int getEMode = BISTLib.E_OSCILLATING;
        TestingTesterBISTPIMComb inIm = new TestingTesterBISTPIMComb( evolver, deployment, experiment, circuit, thresholds, eSize, E_LINES, avgRound, faultDepth, startAt, getEMode, INPUT_SAMPLE_SEP, simpleMode, painter );
        int[] numProps = { 2 }; // Warning, if raise nrEvals will give incorrect value for p0d
        InteractionModel noisyIM = new NoisyPIM( inIm, deployment, experiment, numProps, nrEvals );
        double maxSize = ( 1 << bitsPerVar ) - experiment.getNumOfInputs();
        InteractionModel parsIM = new CircuitParsimonyPIM( noisyIM, circuit, maxSize );
        int windowSize = 10;
        InteractionModel interactionModel = new HistoryWindowIM( windowSize, parsIM );
        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 );
        ControlLib.writeGNUPlotScript( dirName, logDir, logFileName, 3, false );        
        ControlLib.writeWebGraphDaemon( dirName, logDir, logFileName, 3, false, new File(".").getCanonicalPath() + File.separator );

        taskQDescr.add( "Full adder (5 gates) under multiple faults (Ass. A)" );
        taskQBestIndID.add( new Integer( 1574 ) );
        int avgTPLen = 8;   int usedEls = 7;
        int effort = 3;
        taskQEffort.add( new Integer( effort ) );
    }
    
    
    protected static void addDK27() throws IOException
    {
        String[][] inputs4ResetState = { { "0","1","0","0" } }; // for dk27
        int[] permanentEdges = { 9,11,12,14,16,17,18 }; // for dk27
        String resetStateName = "START"; // for dk27
        String kissFileName = "dk27";
        int bestID = 1985; // 23 * 2 + 1 = 47.  1 - 47/(64-1) = 0.25397
        int avgTPLen = 35; // avtTP
        addKISSL2BenchmarkLockedFull
        (
            "/home/mmg20/eh/benchmarks/dk27.kiss2",
            "/home/mmg20/eh/benchmarks/dk27.sout", 
            resetStateName, inputs4ResetState, permanentEdges, "DK27L2",
            "Locked Sequential Benchmark: DK27 (20 gates, 3 latches).  <strong>Largest Sequential Circuit Evolution ever undertaken!</strong>",
            bestID, avgTPLen
         );
    }            
    
    protected static void addMC() throws IOException
    {
        int[] permEdges = { 8,10,12,15 }; // for mc
        String[][] resetIns = { {"001","001","001" },{"011", "011", "011" } }; // for mc
        int bestID = 1338; // L2 => 8 ?? This may be BEECOUNT
        String resetStateName = "HG"; // for mc
        int avgTPLen = 155; // avtTP
        addKISSL4BenchmarkUnlockedFull
        (
            "/home/mmg20/eh/benchmarks/mc.kiss2",
            "/home/mmg20/eh/benchmarks/mcL4.sout", 
            resetStateName, resetIns, permEdges, "MCF32",
            "Sequential Benchmark: MC (8 four-input LUTs, 2 D-latches)",
            bestID, avgTPLen
         );
    }
    
    protected static void addBeecount() throws IOException
    {
        String[][] resetIns = { {"001"},{"011"},{"101"},{"111"} }; // for beecount
        int[] permEdges = { 10,14,17,19,21 }; // for beecount        
        int bestID = 1869;
        int avgTPLen = 220; // avtTP
        addKISSL4BenchmarkUnlockedFull
        (
            "/home/mmg20/eh/benchmarks/beecountSimp.kiss2",
            "/home/mmg20/eh/benchmarks/beecountL4.sout", 
            "S2", resetIns, permEdges, "BeecountL4",
            "Locked Sequential Benchmark BEECOUNT (9 four-input LUTs, 2 latches)",
            bestID, avgTPLen
         );
    }
    

    protected static void addKISSL4BenchmarkUnlockedFull( String kissFileName, String sisOutputFileName, String resetStateName, String[][] inputs4ResetState, int[] permanentEdges, String dirName, String descr, int bestIndID, int avgTPLen ) throws IOException
    {
        int time2Reset = -1;
        for( int pl = 0; pl < inputs4ResetState.length; pl++ )
        {
            time2Reset = Math.max( time2Reset, inputs4ResetState[ pl ].length );
        }
        final int INPUT_SAMPLE_SEP = 40;    final double T_SETUP = 0.45;   final int LUT_INPUTS = 4;
        boolean generateClock = false;      int cyclesPerSample = 1;
        int nrELines = 1;        boolean fpga = true;        boolean voter = true;
        KISSFSMExperiment inExp = new KISSFSMExperiment( T_SETUP, new File( kissFileName ), resetStateName, inputs4ResetState, permanentEdges, generateClock );
        AddClockCSRIExperiment experiment = new AddClockCSRIExperiment( inExp, cyclesPerSample );
        SisOutputReader sor = new SisOutputReader( new File( sisOutputFileName ), nrELines, LUT_INPUTS, fpga, voter );
        FullOrderGenotype seed = new FullOrderGenotype ( sor.getGenotype() );
        int bitsPerVar = sor.getBitsPerVar();        int usedEls = sor.getTotalEls();
        int bitsPerAdd = bitsPerVar + 1;
        final int POP_SIZE = 21;    final int GENOTYPE_MUT = 1; final int NUM_OF_ELITES = 1;
        int DUMP_POP_EVERY = 2000;
        ElementDelayModel delayModel = new CoinDelayModel( );
        CircuitMapping circuitMapping = new FaultyOptimizedMapping( new FPGALUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + nrELines, bitsPerVar, LUT_INPUTS, delayModel ) );
        int DQTol = 3;        int eSize = 19;     int startAt = 20;
        SimulatorFaultyCircuit circuit = new SimulatorFaultyCircuit( circuitMapping );
        boolean alwaysResetBeforeRun = true;
        SimulatorDeployment deployment = new SimulatorDeployment( circuit, alwaysResetBeforeRun );
        SingleFaultModel faultModel = new SingleUsedFaultModel( circuit ); // Should take in whole circuit every time??
        int nrAddCLBs = ( 1 << bitsPerVar ) - experiment.getNumOfInputs();
        int lutSize = 1 << LUT_INPUTS;
        int blockSize = lutSize + ( LUT_INPUTS + 1 ) * bitsPerAdd;
        int qDefSize = ( experiment.getNumOfOutputs() + nrELines ) * bitsPerAdd;
        int genotypeLength = qDefSize + nrAddCLBs * blockSize;
        Genotype[] seeds = new Genotype[ POP_SIZE ];
        seeds[ 0 ] = seed;
        for( int pl = 0; pl < POP_SIZE; pl++ )
        {   seeds[ pl ] = ( FullOrderGenotype ) seed.clone();
            for( int bl = qDefSize + usedEls * blockSize; bl < seeds[ pl ].length(); bl++ )
                if( Math.random() < 0.5 ) seeds[ pl ].set( bl );
        }
        int fixedAlignments = 0;        int howManyBunches = 1;
        //GeneticOperator m = new SAGAMutator( 1, genotypeLength / 50, 0, fixedAlignments * blockSize, -1 );
        ExactGenotypeMutator m = new ExactGenotypeMutator( GENOTYPE_MUT );
        GeneticOperator spxo = new SinglePointXOver();
        GeneticOperator bmin0 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize, fixedAlignments, qDefSize );
        GeneticOperator bmin1 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerAdd, fixedAlignments, qDefSize );
        GeneticOperator bmin2 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + 2 * bitsPerAdd, fixedAlignments, qDefSize );
        GeneticOperator bmin3 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + 3 * bitsPerAdd, fixedAlignments, qDefSize );
        GeneticOperator bc = new BlockCopy ( blockSize, blockSize, 0, fixedAlignments, qDefSize );
        GeneticOperator[] geneticOps ={ m,      spxo,   bmin0,  bmin1,  bmin2,  bmin3,  bc      };
        double[] opsProbs =          {  0.3,    0.2,    0.1,    0.1  ,  0.1  ,  0.1  ,  0.1     };
        Selector selector = new RankSelector(  );
        Evolver evolver = new StandardEvolver( POP_SIZE, genotypeLength, geneticOps, opsProbs, selector, NUM_OF_ELITES, seeds );        
        PopulationLogReader.fullOrderGenotypes = true;

        int nrEvals = 5;        boolean overdetecting = true;
        CircuitPainterObject painter = new CircuitPainterObject( new CircuitPainter(), new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + nrELines, bitsPerVar, LUT_INPUTS, new ConstantDelayModel( 0 ) ) ); 
        BISTPIMSeqOnlineFull inIm = new BISTPIMSeqOnlineFull( evolver, deployment, circuit, experiment, INPUT_SAMPLE_SEP, faultModel, eSize, DQTol, painter, startAt, time2Reset );
        int[] numProps = { 2 };
        InteractionModel noisyIM = new NoisyPIM( inIm, deployment, experiment, numProps, nrEvals, NoisyPIM.AVERAGE );
        double maxSize = nrAddCLBs * 2;
        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 ) );
        int effort = (int) ( avgTPLen * INPUT_SAMPLE_SEP * nrEvals * ( usedEls * 1.5 ) * ( usedEls * 1.5 * 2 ) / 1000000 );
        taskQEffort.add( new Integer( effort ) );
        ControlLib.writeGNUPlotScript( dirName, logDir, logFileName, 3, false );        
        ControlLib.writeWebGraphDaemon( dirName, logDir, logFileName, 3, false, new File(".").getCanonicalPath() + File.separator );
    }
    
    
    protected static void addKISSL2BenchmarkLockedFull( String kissFileName, String sisOutputFileName, String resetStateName, String[][] inputs4ResetState, int[] permanentEdges, String dirName, String descr, int bestIndID, int avgTPLen ) throws IOException
    {
        int time2Reset = -1;
        for( int pl = 0; pl < inputs4ResetState.length; pl++ )
        {
            time2Reset = Math.max( time2Reset, inputs4ResetState[ pl ].length );
        }
        final int INPUT_SAMPLE_SEP = 40;    final double T_SETUP = 0.45;   final int LUT_INPUTS = 2;
        boolean generateClock = false;      int cyclesPerSample = 1;
        int nrELines = 1;        boolean fpga = true;        boolean voter = true;
        KISSFSMExperiment inExp = new KISSFSMExperiment( T_SETUP, new File( kissFileName ), resetStateName, inputs4ResetState, permanentEdges, generateClock );
        AddClockCSRIExperiment experiment = new AddClockCSRIExperiment( inExp, cyclesPerSample );
        SisOutputReader sor = new SisOutputReader( new File( sisOutputFileName ), nrELines, LUT_INPUTS, fpga, voter );
        FullOrderGenotype seed = new FullOrderGenotype ( sor.getGenotype() );
        int bitsPerVar = sor.getBitsPerVar();        int usedEls = sor.getTotalEls();
        int bitsPerAdd = bitsPerVar + 1;
        final int POP_SIZE = 15;    final int GENOTYPE_MUT = 1; final int NUM_OF_ELITES = 1;
        int DUMP_POP_EVERY = 1000;
        ElementDelayModel delayModel = new CoinDelayModel( );
        CircuitMapping circuitMapping = new FaultyOptimizedMapping( new FPGALUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + nrELines, bitsPerVar, LUT_INPUTS, delayModel ) );
        int DQTol = 5;        int eSize = 14;     int startAt = 25;
        SimulatorFaultyCircuit circuit = new SimulatorFaultyCircuit( circuitMapping );
        boolean alwaysResetBeforeRun = true;
        SimulatorDeployment deployment = new SimulatorDeployment( circuit, alwaysResetBeforeRun );
        SingleFaultModel faultModel = new SingleUsedFaultModel( circuit ); // Should take in whole circuit every time??
        int nrAddCLBs = ( 1 << bitsPerVar ) - experiment.getNumOfInputs();
        int lutSize = 1 << LUT_INPUTS;
        int blockSize = lutSize + ( LUT_INPUTS + 1 ) * bitsPerAdd;
        int qDefSize = ( experiment.getNumOfOutputs() + nrELines ) * bitsPerAdd;
        int genotypeLength = qDefSize + nrAddCLBs * blockSize;
        Genotype[] seeds = new Genotype[ POP_SIZE ];
        seeds[ 0 ] = seed;
        for( int pl = 0; pl < POP_SIZE; pl++ )

⌨️ 快捷键说明

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