evokingkongbist.java~
来自「Java遗传算法库」· JAVA~ 代码 · 共 745 行 · 第 1/4 页
JAVA~
745 行
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 static void addCombBLIFBenchmark( String blifFileName, String sisOutputFileName, String dirName, String descr, int bestIndID ) throws IOException
{
final double T_SETUP = 0.95;
final int INPUT_SAMPLE_SEP = 30;
// D - Circuit Structure Properties
final int LUT_INPUTS = 2;
// B - BENCHMARK STUFF
CombinationalBLIFExperiment experiment = new CombinationalBLIFExperiment( blifFileName, T_SETUP );
final int E_LINES = 1;
final boolean FPGA = false;
final boolean VOTER = true;
SisOutputReader sor = new SisOutputReader( new File( sisOutputFileName ), E_LINES, LUT_INPUTS, FPGA, VOTER );
FullOrderGenotype seed = new FullOrderGenotype ( sor.getGenotype() );
int bitsPerVar = sor.getBitsPerVar();
int usedEls = sor.getTotalEls();
SingleFaultModel faultModel = new SingleFullFaultModel( usedEls );
// A - Genetic Algorithms Properties
// Standard
final int POP_SIZE = 32;
final int GENOTYPE_MUT = 1;
final int NUM_OF_ELITES = 2;
// M - Log Properties
int DUMP_POP_EVERY = 1000;
// 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 );
// 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 = 0; pl < POP_SIZE; pl++ )
{
seeds[ pl ] = ( FullOrderGenotype ) seed.clone();
for( int bl = usedEls * blockSize; bl < seeds[ pl ].length(); bl++ )
{
if( Math.random() < 0.5 )
{
seeds[ pl ].set( bl );
}
}
}
int fixedAlignments = usedEls;
int howManyBunches = 1;
//GeneticOperator m = new SAGAMutator( 1, genotypeLength / 50, 0, fixedAlignments * blockSize, -1 );
ExactGenotypeMutator m = new ExactGenotypeMutator( ( int ) ( genotypeLength / 500 ) + 1 ); // For real biggies
m.setRange( fixedAlignments * blockSize, -1 );
GeneticOperator spxo = new SinglePointXOver();
GeneticOperator bmin0 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize, fixedAlignments );
GeneticOperator bmin1 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerVar, fixedAlignments );
GeneticOperator bc = new BlockCopy ( blockSize, blockSize, 0, fixedAlignments );
GeneticOperator[] geneticOps = { m, spxo, bmin0, bmin1, bc };
double[] opsProbs = { 0.2, 0.3, 0.1, 0.1, 0.2 };
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 = 15;
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, 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 );
int avgSize = ( int )( usedEls * 1.45 );
int effort = nrEvals * INPUT_SAMPLE_SEP * avgSize * avgSize * ( 1 << experiment.getNumOfInputs() );
taskQEffort.add( new Integer( effort ) );
}
protected static void addCombBLIFBenchmarkNoLocking( String blifFileName, String sisOutputFileName, String dirName, String descr, int bestIndID ) throws IOException
{
final double T_SETUP = 0.45;
final int INPUT_SAMPLE_SEP = 100;
// D - Circuit Structure Properties
final int LUT_INPUTS = 2;
// B - BENCHMARK STUFF
CombinationalBLIFExperiment experiment = new CombinationalBLIFExperiment( blifFileName, T_SETUP );
final int E_LINES = 1;
final boolean FPGA = false;
final boolean VOTER = true;
SisOutputReader sor = new SisOutputReader( new File( sisOutputFileName ), E_LINES, LUT_INPUTS, FPGA, VOTER );
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
int DUMP_POP_EVERY = 50;
// 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( 1, genotypeLength / 100, 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 bc = new BlockCopy ( blockSize, blockSize, 0 );
GeneticOperator[] geneticOps = { m, spxo, bmin0, bmin1, bc };
double[] opsProbs = { 0.2, 0.2, 0.2, 0.2, 0.2 };
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 = 30;
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, 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 );
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?