📄 evotsc.java
字号:
GeneticOperator bmin0 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize, fixedAlignments, qDefSize );
GeneticOperator bmin1 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerVar, fixedAlignments, qDefSize );
GeneticOperator bmin2 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerVar * 2, fixedAlignments, qDefSize );
GeneticOperator bmin3 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerVar * 3, fixedAlignments, qDefSize );
GeneticOperator bc = new BlockCopy ( blockSize, blockSize, 0, fixedAlignments, qDefSize );
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( LUTInputs == 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[] numProps = { 2 }; double maxSize = nrAddUnits;
CircuitPainterObject painter = new CircuitPainterObject( new CircuitPainter(), new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + E_LINES, bitsPerVar, LUTInputs, new ConstantDelayModel( 0 ) ) );
TSCCombinationalIM inIm = new TSCCombinationalIM( evolver, deployment, circuit, experiment, faultModel, E_SIZE, E_START_AT, INPUT_SAMPLE_SEP, painter);
InteractionModel noisyIM = new NoisyPIM( inIm, deployment, experiment, numProps, NO_EVALS );
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 avgSize = ( int )( usedEls * 1.45 );
int effort = NO_EVALS * INPUT_SAMPLE_SEP * avgSize * avgSize * ( 1 << experiment.getNumOfInputs() );
taskQEffort.add( new Integer( effort ) );
ControlLib.writeGNUPlotScript( dirName, logDir, logFileName, 3, false );
ControlLib.writeWebGraphDaemon( dirName, logDir, logFileName, 3, false, new File(".").getCanonicalPath() + File.separator, getIntConfig( IX_GRAPH_REFRESH_MIN ) );
}
protected void oldAddCombBLIFBenchmark( String blifFileName, String sisOutputFileName, String dirName, String descr, int bestIndID, int LUTInputs, boolean spaceForVoter, boolean locking ) throws IOException
{
final int INPUT_SAMPLE_SEP = 30; final int SAMPLE_WINDOW_START = 20;
final int DUMP_POP_EVERY = getIntConfig( IX_DUMP_POP_EVERY ); final int E_LINES = 2;
final int NO_EVALS = 1;
final int E_SIZE = INPUT_SAMPLE_SEP - SAMPLE_WINDOW_START;
final int E_START_AT = SAMPLE_WINDOW_START;
FitnessFunction corrFF = new CorrelationFitnessFunction();
FitnessFunction tSetupFF = new SampleWindowFitnessFunction( corrFF, SAMPLE_WINDOW_START );
TestPatternGenerator tpg = new CompleteShuffledTPG();
CombinationalBLIFExperiment experiment = new CombinationalBLIFExperiment( blifFileName, tSetupFF, tpg );
final boolean FPGA = false;
SisOutputReader sor = new SisOutputReader( new File( sisOutputFileName ), E_LINES, LUTInputs, FPGA, spaceForVoter );
FullOrderGenotype seed = new FullOrderGenotype ( sor.getVassilevGenotype() );
int bitsPerVar = sor.getBitsPerVar(); int usedEls = sor.getTotalEls();
int nrAddUnits = ( 1 << bitsPerVar ) - experiment.getNumOfInputs();
int lutSize = 1 << LUTInputs;
int blockSize = lutSize + LUTInputs * bitsPerVar;
int qDefSize = ( experiment.getNumOfOutputs() + E_LINES ) * bitsPerVar;
int genotypeLength = qDefSize + nrAddUnits * blockSize;
ElementDelayModel delayModel = new CoinDelayModel( );
CircuitMapping inMapping = new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + E_LINES, bitsPerVar, LUTInputs, delayModel );
CircuitMapping circuitMapping = new VassilevMapping( inMapping, experiment.getNumOfOutputs() + E_LINES, bitsPerVar );
int[] inputDefWithinGene = new int[ LUTInputs ];
for( int il = 0; il < LUTInputs; il++ )
{
inputDefWithinGene[ il ] = lutSize + il * bitsPerVar;
}
circuitMapping = new FaultyOptimizedMapping( circuitMapping );
SimulatorFaultyCircuit circuit = new SimulatorFaultyCircuit( circuitMapping );
SimulatorDeployment deployment = new SimulatorDeployment( circuit );
SingleFaultModel faultModel = new SingleUsedFaultModel( circuit );
final int POP_SIZE = 32; final int NUM_OF_ELITES = 2;
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 = locking ? usedEls : 0;
int minMutationRate = 1;//genotypeLength / 500 + 1;
int maxMutationRate = genotypeLength / 25 + 1;
// was 1000, 50
int SAGAFitnessIndex = 1; int howManyBunches = 1;
GeneticOperator m = new SAGAMutator( minMutationRate, maxMutationRate, SAGAFitnessIndex, 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, qDefSize );
GeneticOperator bmin1 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerVar, fixedAlignments, qDefSize );
GeneticOperator bmin2 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerVar * 2, fixedAlignments, qDefSize );
GeneticOperator bmin3 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerVar * 3, fixedAlignments, qDefSize );
GeneticOperator bc = new BlockCopy ( blockSize, blockSize, 0, fixedAlignments, qDefSize );
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( LUTInputs == 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[] numProps = { 2 }; double maxSize = nrAddUnits;
CircuitPainterObject painter = new CircuitPainterObject( new CircuitPainter(), new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + E_LINES, bitsPerVar, LUTInputs, new ConstantDelayModel( 0 ) ) );
TSCCombinationalIM inIm = new TSCCombinationalIM( evolver, deployment, circuit, experiment, faultModel, E_SIZE, E_START_AT, INPUT_SAMPLE_SEP, painter);
InteractionModel noisyIM = new NoisyPIM( inIm, deployment, experiment, numProps, NO_EVALS );
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 avgSize = ( int )( usedEls * 1.45 );
int effort = NO_EVALS * INPUT_SAMPLE_SEP * avgSize * avgSize * ( 1 << experiment.getNumOfInputs() );
taskQEffort.add( new Integer( effort ) );
ControlLib.writeGNUPlotScript( dirName, logDir, logFileName, 3, false );
ControlLib.writeWebGraphDaemon( dirName, logDir, logFileName, 3, false, new File(".").getCanonicalPath() + File.separator, getIntConfig( IX_GRAPH_REFRESH_MIN ) );
}
protected void addTTC17() throws IOException
{
String blifFN = "/home/mmg20/eh/benchmarks/C17.blif";
String sisQFN = "/home/mmg20/eh/benchmarks/C17L4.sout";
String dirName = "TTC17L4OM4SBPV5";
String descr = "Benchmark C17 (2 four-input LUTs) under multiple faults (Osc.)";
int bestHD = 1530;
addCombBLIFBenchmarkNoLockingTT( blifFN, sisQFN, dirName, descr, bestHD );
}
protected void addTTCM42() throws IOException
{
String blifFN = "/home/mmg20/eh/benchmarks/cm42a.blif";
String sisQFN = "/home/mmg20/eh/benchmarks/cm42a.sout";
String dirName = "TTCM42AD";
String descr = "Benchmark CM42A (22 gates) under multiple faults (Ass. A, Dual Rail)";
int bestHD = 1661;
addCombBLIFBenchmarkNoLockingTT( blifFN, sisQFN, dirName, descr, bestHD );
}
protected void addCombBLIFBenchmarkNoLockingTT( String blifFileName, String sisOutputFileName, String dirName, String descr, int bestIndID ) throws IOException
{
final double T_SETUP = 0.45;
final int INPUT_SAMPLE_SEP = 30;
// D - Circuit Structure Properties
final int LUT_INPUTS = 4;
// B - BENCHMARK STUFF
FitnessFunction corrFF = new CorrelationFitnessFunction();
FitnessFunction tSetupFF = new SampleWindowFitnessFunction( corrFF, 15 );
TestPatternGenerator tpg = new CompleteShuffledTPG();
CombinationalBLIFExperiment experiment = new CombinationalBLIFExperiment( blifFileName, tSetupFF, tpg );
final int E_LINES = 1;
final boolean FPGA = false;
final boolean VOTER = true;
final int EXTRA_BPV = 1;
final boolean VARSIZED = false;
SisOutputReader sor = new SisOutputReader( new File( sisOutputFileName ), E_LINES, LUT_INPUTS, FPGA, VOTER, EXTRA_BPV, VARSIZED );
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 = 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 SimulatorFaultyCircuitAsynchronous( circuitMapping );
boolean randomResetBeforeEveryEval = true; SimulatorDeployment deployment = new SimulatorDeployment( circuit, randomResetBeforeEveryEval );
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( GENOTYPE_MUT );
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 );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -