?? evoafs.java
字號:
//int windowSize = 10; InteractionModel interactionModel = new HistoryWindowIM( windowSize, parsIM );
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 avgCirSize = ( int ) ( 1.5 * usedEls );
int tpLen = 1 << experiment.getNumOfInputs(); int effort = tpLen * nrEvals * avgCirSize * INPUT_SAMPLE_SEP * sumBinCo( avgCirSize, faultDepth ) / 1000000;
taskQEffort.add( new Integer( effort ) );
ControlLib.writeGNUPlotScript( dirName, logDir, logFileName, faultDepth, false );
ControlLib.writeWebGraphDaemon( dirName, logDir, logFileName, 3, false, new File(".").getCanonicalPath() + File.separator );
}
protected int sumBinCo( int n, int maxR )
{
int rv = 0;
for( int r = 1; r < maxR; r++ )
{
rv += ESLib.binomialCoefficient( n, r );
}
return rv;
}
protected void addTTAdd1( String dirName ) throws IOException
{
final int INPUT_SAMPLE_SEP = 30; final int SAMPLE_START = 15;
BooleanFunction functionC = new Add1bitCFun(); BooleanFunction functionQ = new Add1bitQFun();
FitnessFunction corrFF = new CorrelationFitnessFunction();
FitnessFunction tSetupFF = new SampleWindowFitnessFunction( corrFF, SAMPLE_START );
ArbitraryFunctionExperiment expC = new ArbitraryFunctionExperiment ( functionC, tSetupFF );
ArbitraryFunctionExperiment expQ = new ArbitraryFunctionExperiment ( functionQ, tSetupFF );
ConfigurableRandomInputExperiment[] exps = { expQ, expC }; ConfigurableRandomInputMultiOutputExperiment experiment = new ConfigurableRandomInputMultiOutputExperiment( exps );
final int LUT_INPUTS = 2; final int E_LINES = 1; int bitsPerVar = 4;
final int POP_SIZE = 31; final int NUM_OF_ELITES = 1;
final int GENOTYPE_MUT = 1; int DUMP_POP_EVERY = 2000;
ElementDelayModel delayModel = new CoinDelayModel( );
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 );
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 ];
Genotype seed = new FullOrderGenotype( genotypeLength );
//FullOrderGenotype seed = new FullOrderGenotype( "011011011011011010010011011001000001011111111110011010000010101001011110011101100101000010010000100110101100001000001101000111101111011011111110001011010000" );
//FullOrderGenotype seed = new FullOrderGenotype( "RRQNQ1faOcALlfVu][8D7uRuBG", genotypeLength, 6 );
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; int qDefSize = 0; int fixedAlignments = 0;
ExactGenotypeMutator m = new ExactGenotypeMutator( GENOTYPE_MUT );
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 + 2 * bitsPerVar, fixedAlignments, qDefSize );
//GeneticOperator bmin3 = new BunchMutator( bitsPerVar, howManyBunches, blockSize, lutSize + 3 * bitsPerVar, fixedAlignments, qDefSize );
GeneticOperator bc = new BlockCopy ( blockSize, blockSize, 0, fixedAlignments, qDefSize );
//GeneticOperator[] geneticOps ={ m, spxo, bmin0, bmin1, bmin2, bmin3, bc };
//double[] opsProbs = { 0.3, 0.2, 0.1, 0.1 , 0.1 , 0.1 , 0.1 };
GeneticOperator[] geneticOps ={ m, spxo, bmin0, bmin1, bc };
double[] opsProbs = { 0.3, 0.2, 0.2, 0.2 , 0.1 };
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 = 3; int startAt = 3;
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 simpleMode = 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, simpleMode, 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 = ( 1 << bitsPerVar ) - experiment.getNumOfInputs();
InteractionModel parsIM = new CircuitParsimonyPIM( noisyIM, circuit, maxSize );
//int windowSize = 10;
//InteractionModel interactionModel = new HistoryWindowIM( windowSize, parsIM );
InteractionModel interactionModel = parsIM;
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( "Full adder (5 gates) under multiple faults" );
taskQBestIndID.add( new Integer( 1574 ) );
int avgTPLen = 8; int usedEls = 7;
int effort = 3;
taskQEffort.add( new Integer( effort ) );
ControlLib.writeGNUPlotScript( dirName, logDir, logFileName, 3, false );
ControlLib.writeWebGraphDaemon( dirName, logDir, logFileName, 3, false, new File(".").getCanonicalPath() + File.separator );
}
/** Called by clients the first time they connect.
* @param initialParameters Initial parameters from client local configuration.
* The current client implementation, see
* InteractiveTaskClient, provides the ip address of
* the client and the command line paramaters used to
* launch the client. These are packaged in a Vector.
* @return The ID of this client will from now on used for
* interaction with the server.
*/
public Object getID(Object initialParameters) throws RemoteException {
return ies.getID( initialParameters );
}
/** This will provide the client with the InteractiveTask
* it should run.
* @param id The ID provided by the getID method by which the
* client will always refer to itself.
* @return The task this client should run. This could be
* exactly the same as the one all other clients are
* running or tailored to this particular client.
*/
public InteractiveTask getTask(Object id) throws RemoteException {
return ies.getTask( id );
}
/** Called by clients when they wish to interact.
* @param ID the client's ID
* @param clientTaskOutput the outputs of the client obtained by task.get( null ) on the client task
* @return whatever should be sent into the client through task.set( )
*/
public Object interact(Object ID, Object clientTaskOutput) throws RemoteException {
return ies.interact( ID, clientTaskOutput );
}
public String toString()
{
String rv = "EvoBIST with IES: " + ies;
return rv;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -