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

📄 evorobotech2.java~

📁 Java遗传算法库
💻 JAVA~
📖 第 1 页 / 共 2 页
字号:
            addRepair2MultCollection( ix, ( Vector ) currFaults.clone() );
        }
    }
    /*
    private static void addRepair2MultCollection( int ix, Vector coll ) 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
         boolean alwaysRandom = true; // Noise 2
         boolean useSumFit = true;
        ConfigurableRandomInputExperiment experiment = new MultiplierExperiment( 2, T_SETUP, alwaysRandom, useSumFit );
        
        // 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() );
        int bitsPerVar = sor.getBitsPerVar();
        int usedEls = sor.getTotalEls();
        

        // D - DEPLOYMENT set up
        //ElementDelayModel delayModel = new CoinDelayModel( ); // Noise 1
        double minmu = 0;
        double maxmu = 4;
        double sigma = 0.1;
        int muD = 50 * 60 * 60 * 3;
        int muS = 50 * 60 * 60 * 1;
        DriftingGaussianDelayModel delayModel = new DriftingGaussianDelayModel( minmu,maxmu,sigma,muD,muS ); // Noise 1
        //ElementDelayModel delayModel = new ConstantDelayModel( 0 ); // No Noise 1
        CircuitMapping circuitMapping = new FPGALUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs(), bitsPerVar, LUT_INPUTS, delayModel );
        SimulatorFaultyCircuit circuit = new SimulatorFaultyCircuit( circuitMapping );
        
        int nFaults = coll.size();
        int[] fPos = new int[ nFaults ];
        int[] fVal = new int[ nFaults ];
        for( int flp = 0; flp < nFaults; flp++ )
        {
            Point f = ( Point ) coll.get( flp );
            fPos[ flp ] = f.x;
            fVal[ flp ] = f.y;
        }
            
        circuit.setPersistentFaults( fPos, fVal );
        SimulatorDeployment deployment = new SimulatorDeployment( circuit );

        // A - Genetic Operators Set up
         int genotypeLength = seed.length();
         //( ( 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 );
        int maxGens = 50 * 3600 * 24 * 30; // a month's time
        Monica monica = new Monica( interactionModel, DUMP_POP_EVERY, maxGens );

        String fs = File.separator;
        String dirName = "Repair" + fs + "2Mult" + fs + "Multiple" + fs + ix;
        monica.setName( dirName );
        taskQ.add( monica );
        taskQNames.add( dirName );
        ControlLib.writeGNUPlotScript( dirName, logDir, logFileName );
    }        
    */
    private static void addRepair2MultSingle( int ix, Point fault ) throws IOException
    {
        int GENOTYPE_MUT = 1;  int POP_SIZE = 2;  int NUM_OF_ELITES = 1;  double[] RANK_PROBS = { 1,0 };
        double T_SETUP = 0.75; int ISS = 40;
        double MIN_MU = 1;     double MAX_MU = 3;     double SIGMA = 0.1;
        int HOUR = 50 * 60 * 60;  int MU_D = 48 * HOUR;   int MU_S = 1 * HOUR;
        int LUT_INPUTS = 4;    int DUMP_POP_EVERY = 1000;
        // E - EXPERIMENT set up
        boolean alwaysRandom = true; // Noise 2
        int N = 2;  int errTh = 2;
        FitnessFunction inFF = new SimpleCorrelationFitnessFunction();
        FitnessFunction fitFun = new SingleSampleAvgFitnessFunction( inFF );
        ConfigurableRandomInputExperiment multexp = new MultiplierExperiment( 2, T_SETUP, alwaysRandom, fitFun );
        ConfigurableRandomInputExperiment experiment = new AddClockCRIExperiment( multexp );        
        // 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() );
        int bitsPerVar = sor.getBitsPerVar();        int usedEls = sor.getTotalEls();
        // D - DEPLOYMENT set up
        //ElementDelayModel delayModel = new DriftingGaussianDelayModel( MIN_MU,MAX_MU,SIGMA,MU_D,MU_S ); // Noise 1
        ElementDelayModel delayModel = new GaussianDelayModel( 0, 0.1 ); // mu,s
        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 = seed.length();         //( ( 1 << bitsPerVar ) - experiment.getNumOfInputs() ) * ( ( 1 << LUT_INPUTS ) + 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 );
        // M - Monica
        InteractionModel interactionModel = new StandardInteractionModel( evolver, deployment, experiment,ISS );
        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 );
    }   
    /*
    private static void addRepair2MultSingleNoLatches( 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 double T_SETUP = 0.9;
        // M - Log Properties
        int DUMP_POP_EVERY = 1000;
        // E - EXPERIMENT set up
        boolean alwaysRandom = true; // Noise 2
        boolean useSumFit = true;
        boolean totRndFit = true;
        ConfigurableRandomInputExperiment experiment = new MultiplierExperiment( 2, T_SETUP, alwaysRandom, useSumFit, totRndFit );
        
        // A - Load Seed
        String sisOutputFileName = "/home/mmg20/eh/benchmarks/2multL4.sout";
        int resQ = 0;
        boolean fpga = false;
        boolean voter = false;
        SisOutputReader sor = new SisOutputReader( new File( sisOutputFileName ), resQ, LUT_INPUTS, fpga, voter );
        Genotype seed = new Genotype( sor.getGenotype() );
        int bitsPerVar = sor.getBitsPerVar();
        int usedEls = sor.getTotalEls();

        // D - DEPLOYMENT set up
        // Gate Delays - Noise 1
        double minmu = 6;
        double maxmu = 9;
        double sigma = 0.1;
        int muD = 50 * 60 * 60 * 3;
        int muS = 50 * 60 * 60 * 1;
        DriftingGaussianDelayModel delayModel = new DriftingGaussianDelayModel( minmu,maxmu,sigma,muD,muS ); // Noise 1
        CircuitMapping circuitMapping = new VassilevMapping( 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 = seed.length();         //( ( 1 << bitsPerVar ) - experiment.getNumOfInputs() ) * ( ( 1 << LUT_INPUTS ) + 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 );
        
        // M - Monica
        int iss = 100;
        InteractionModel interactionModel = new StandardInteractionModel( evolver, deployment, experiment, iss );
        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 + "2MultNoLatch" + 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 + -