?? evoafs.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 EvoAFS 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 EvoAFS(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;
}
}
addTTAdd1( "Add1AFS" );
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 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 int INPUT_SAMPLE_SEP = 30; final int SAMPLE_START = 15;
// D - Circuit Structure Properties
final int LUT_INPUTS = 4;
// B - BENCHMARK STUFF
FitnessFunction corrFF = new CorrelationFitnessFunction();
FitnessFunction tSetupFF = new SampleWindowFitnessFunction( corrFF, SAMPLE_START );
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 );
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 = 2; int eSize = 3; int startAt = 10;
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 assumptionA = false; int getEMode = BISTLib.E_MODE_OSCILLATING;
TestingTesterBISTPIMComb inIm = new TestingTesterBISTPIMComb( evolver, deployment, experiment, circuit, thresholds, eSize, E_LINES, avgRound, faultDepth, startAt, getEMode, INPUT_SAMPLE_SEP, assumptionA, 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 = nrAddUnits;
InteractionModel interactionModel = new CircuitParsimonyPIM( noisyIM, circuit, maxSize, faultDepth );
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -