?? evobist.java~
字號:
package jaga.pj.circuits.control;
import jaga.control.*;import jaga.deploy.*;import jaga.evolve.*;import jaga.experiment.*;import jaga.*;
import jaga.pj.circuits.*;import jaga.pj.circuits.experiment.*;import jaga.pj.circuits.fpgaft.*;import jaga.pj.gral.*;
import islandev.IslandsEvolutionServer;import debug.DebugLib;import distrit.*;
import java.util.Vector;import java.rmi.*;import java.io.*;import java.util.ArrayList;
public class EvoBIST implements InteractiveTaskServer
{
// Configuration constants
protected final double MIGRATION_RATE = 1;
// Working
protected Vector taskQ = new Vector(), taskQNames = new Vector(), taskQDescr = new Vector();
protected Vector taskQBestIndID = new Vector(), taskQEffort = new Vector();
protected String logDir, logFileName; protected IslandsEvolutionServer ies;
public EvoBIST( ArrayList extraArgs ) throws IOException
{
logDir = ( String ) extraArgs.get( 0 ); logFileName = ( String ) extraArgs.get( 1 );
boolean logToDatabase = true, logTopology = true;
if( extraArgs.size() >= 3 )
{
if( ( ( String ) extraArgs.get( 2 ) ).equalsIgnoreCase( "-L" ) )
{
logToDatabase = false;
}else if( ( ( String ) extraArgs.get( 2 ) ).equalsIgnoreCase( "-T" ) )
{
logTopology = false;
}
}
//addTTC17();
addBWL4();
ies = new IslandsEvolutionServer( taskQ, taskQNames, logDir, logFileName, MIGRATION_RATE, logToDatabase, taskQDescr, taskQBestIndID, taskQEffort, logTopology );
}
// -------------- FROM HERE ON METHODS TO ADD TASKS TO THE QUEUE --------------
protected void addBWL4() throws IOException
{
String blifFN = "/home/mmg20/eh/benchmarks/bw.blif";
String sisQFN = "/home/mmg20/eh/benchmarks/bwL4.sout";
String dirName = "BWL4BPV8";
String descr = "Locked Benchmark: BW (144 four-input LUTs)";
int bestHD = 2370;
int LUTInputs = 4;
boolean voter = false;
boolean locking = false;
addCombBLIFBenchmark( blifFN, sisQFN, dirName, descr, bestHD, LUTInputs, voter, locking );
}
protected void addCombBLIFBenchmark( String blifFileName, String sisOutputFileName, String dirName, String descr, int bestIndID ) throws IOException
{
int defaultLUTInputs = 2;
boolean defaultVoter = true;
boolean defaultLocking = true;
addCombBLIFBenchmark( blifFileName, sisOutputFileName, dirName, descr, bestIndID, defaultLUTInputs,defaultVoter,defaultLocking );
}
protected void addCombBLIFBenchmark( 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 = 500; final int E_LINES = 1;
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.getGenotype() );
int bitsPerVar = sor.getBitsPerVar(); int usedEls = sor.getTotalEls();
int nrAddUnits = ( 1 << bitsPerVar ) - experiment.getNumOfInputs();
SingleFaultModel faultModel = new SingleFullFaultModel( nrAddUnits );
ElementDelayModel delayModel = new CoinDelayModel( );
CircuitMapping circuitMapping = new FaultyOptimizedMapping( new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + E_LINES, bitsPerVar, LUTInputs, delayModel ) );
SimulatorFaultyCircuit circuit = new SimulatorFaultyCircuit( circuitMapping );
SimulatorDeployment deployment = new SimulatorDeployment( circuit );
final int POP_SIZE = 32; final int NUM_OF_ELITES = 2;
int lutSize = 1 << LUTInputs;
int blockSize = lutSize + LUTInputs * 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 = locking ? usedEls : 0;
int minMutationRate = genotypeLength / 1000 + 1; int maxMutationRate = genotypeLength / 50 + 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 );
GeneticOperator bmin1 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerVar, fixedAlignments );
GeneticOperator bmin2 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerVar * 2, fixedAlignments );
GeneticOperator bmin3 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + bitsPerVar * 3, fixedAlignments );
GeneticOperator bc = new BlockCopy ( blockSize, blockSize, 0, fixedAlignments );
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;
final boolean OVERDETECTING = true;
CircuitPainterObject painter = new CircuitPainterObject( new CircuitPainter(), new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + E_LINES, bitsPerVar, LUTInputs, new ConstantDelayModel( 0 ) ) );
BISTPIM inIm = new BISTPIM( evolver, deployment, circuit, experiment, faultModel, E_SIZE, E_START_AT, OVERDETECTING, 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, 60 * 12 );
}
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;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -