📄 evodrevilbist.java~
字号:
package es.pj.circuits.control;
import es.control.*;
import es.deploy.*;
import es.evolve.*;
import es.experiment.*;
import es.*;
import es.pj.circuits.*;
import es.pj.circuits.experiment.*;
import es.pj.circuits.fpgaft.*;
import es.pj.gral.*;
import islandev.IslandsEvolutionServer;
import debug.DebugLib;
import java.util.Vector;
import java.rmi.*;
import java.io.*;
/**
*
* @author Michael Garvie
* @version
*/
public abstract class EvoDrEvilBIST
{
static Vector taskQ = new Vector();
static Vector taskQNames = new Vector();
static String logDir;
static final String logFileName = "DrEvil_log.txt";
static final double migrationRate = 0.5;
public static void main( String[] args )
{
logDir = args[ 0 ];
//DebugLib.trcLogger.isLogging = true;
DebugLib.logFileName = logFileName;
//add2MultBIST( new SingleFullFaultModel( 28 ) );
addAdd1( new SingleFullFaultModel( 13 ) );
try
{
IslandsEvolutionServer ms = new IslandsEvolutionServer( "DrEvil", taskQ, taskQNames, logDir, migrationRate );
ms.bindServer();
//MonicaServer ms = new MonicaServer( "MonicaServer", taskQ, taskQNames, args[ 0 ], 0.5 );
}catch( java.rmi.RemoteException e )
{
System.out.println( e );
}
}
private static void addAdd1( SingleFaultModel faultModel )
{
// A - Genetic Algorithms Properties
// Standard
final int POP_SIZE = 32;
final int GENOTYPE_MUT = 1;
final double XOVER_PROB = 0.4;
final double MUTATION_PROB = 0.6;
final int NUM_OF_ELITES = 2;
/* 1+1
final int POP_SIZE = 2;
final int GENOTYPE_MUT = 2;
final double XOVER_PROB = 0;
final double MUTATION_PROB = 1;
final int NUM_OF_ELITES = 1;
final double[] RANK_PROBS = { 1d, 0d };
*/
// D - Circuit Structure Properties
final int BITS_PER_VARIABLE = 4;
final int LUT_INPUTS = 2;
// D - Simulator Properties
final int SIMULATOR_GATE_DELAY = 1;
final double T_SETUP = 0.45;
// M - Log Properties
int DUMP_POP_EVERY = 100;
// E - EXPERIMENT set up
BooleanFunction boolFunQ = new Add1bitQFun();
BooleanFunction boolFunC = new Add1bitCFun();
// BooleanFunction boolFun = new MUXFunction( 2 , 4 );
// BooleanFunction boolFun = new VertorHorizFun();
// BooleanFunction boolFun = new FLEXToneDetectFun();
ConfigurableRandomInputExperiment experimentQ = new ArbitraryFunctionExperiment( boolFunQ, T_SETUP );
ConfigurableRandomInputExperiment experimentC = new ArbitraryFunctionExperiment( boolFunC, T_SETUP );
ConfigurableRandomInputExperiment[] exps = { experimentQ, experimentC };
ConfigurableRandomInputExperiment experiment = new ConfigurableRandomInputMultiOutputExperiment( exps );
// D - DEPLOYMENT set up
ElementDelayModel delayModel = new GaussianDelayModel( 0.5, 0.5 );
CircuitMapping circuitMapping = new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + 1, BITS_PER_VARIABLE, LUT_INPUTS, delayModel );
SimulatorFaultyCircuit circuit = new SimulatorFaultyCircuit( circuitMapping );
SimulatorDeployment deployment = new SimulatorDeployment( circuit );
// A - Genetic Operators Set up
int genotypeLength = ( ( 1 << BITS_PER_VARIABLE ) - experiment.getNumOfInputs() ) * ( ( 1 << LUT_INPUTS ) + LUT_INPUTS * BITS_PER_VARIABLE );
int lutSize = 1 << LUT_INPUTS;
int blockSize = lutSize + LUT_INPUTS * BITS_PER_VARIABLE;
final Genotype SEED0 = new FullOrderGenotype( "011011110011011101000111011101010110011011101101010000001111011000001000011000011011000111101101011011111001011011101101010010001111011110101100000111101101" );
//final Genotype SEED0 = new FullOrderGenotype( genotypeLength );
// final Genotype SEED0 = new FullOrderGenotype( "H8ZldgKBW~~CtVhodvhhiWv[DX5ZSOcUA3uTJ^IPhiNFkID3uNFll9LMVoNLd`pTt57OtV", genotypeLength, 6 );
//final Genotype[] SEEDS = { };
Genotype[] SEEDS = new Genotype[ POP_SIZE ];
SEEDS[ 0 ] = SEED0;
for( int pl = 1; pl < POP_SIZE; pl++ )
{
SEEDS[ pl ] = ( FullOrderGenotype ) SEED0.clone();
for( int bl = 0; bl < SEEDS[ pl ].length(); bl++ )
{
if( Math.random() < 0.5 )
{
SEEDS[ pl ].set( bl );
}
}
}
GeneticOperator m = new SAGAMutator( 1, 10 );
GeneticOperator spxo = new SinglePointXOver();
GeneticOperator bmin0 = new BunchMutator( BITS_PER_VARIABLE, 1, blockSize, lutSize );
GeneticOperator bmin1 = new BunchMutator( BITS_PER_VARIABLE, 1, blockSize, lutSize + BITS_PER_VARIABLE );
GeneticOperator bc = new BlockCopy ( blockSize, blockSize );
GeneticOperator[] geneticOps = { m, spxo, bmin0, bmin1, bc };
double[] opsProbs = { 0.3, 0.1, 0.2, 0.2, 0.2 };
/* 1+1
GeneticOperator[] geneticOps = { m };
double[] opsProbs = { MUTATION_PROB };
*/
// Selector selector = new FitnessProportionateSelector();
Selector selector = new RankSelector( );
Evolver evolver = new StandardEvolver( POP_SIZE, genotypeLength, geneticOps, opsProbs, selector, NUM_OF_ELITES, SEEDS );
//SingleFaultModel faultModel = new SingleStaticFaultModel( fPos );
//InteractionModel interactionModel = new StandardInteractionModel( evolver, deployment, experiment );
PopulationLogReader.fullOrderGenotypes = true;
int eSize = 10;
int nrEvals = 10;
boolean overdetecting = true;
InteractionModel inIm = new BISTPIM( evolver, deployment, circuit, experiment, faultModel, eSize, overdetecting );
int[] numProps = { 2 };
InteractionModel noisyIM = new NoisyPIM( inIm, deployment, experiment, numProps, nrEvals );
InteractionModel interactionModel = new CircuitParsimonyPIM( noisyIM, circuit );
Monica monica = new Monica( interactionModel, DUMP_POP_EVERY, java.lang.Integer.MAX_VALUE );
String dirName = "Add1PostVote";
monica.setName( dirName );
taskQ.add( monica );
taskQNames.add( dirName );
ControlLib.writeGNUPlotScript( dirName, logDir, logFileName, 3, false );
}
private static void add2MultBIST( SingleFaultModel faultModel )
{
// A - Genetic Algorithms Properties
// Standard
final int POP_SIZE = 32;
final int GENOTYPE_MUT = 1;
final double XOVER_PROB = 0.4;
final double MUTATION_PROB = 0.6;
final int NUM_OF_ELITES = 2;
/* 1+1
final int POP_SIZE = 2;
final int GENOTYPE_MUT = 2;
final double XOVER_PROB = 0;
final double MUTATION_PROB = 1;
final int NUM_OF_ELITES = 1;
final double[] RANK_PROBS = { 1d, 0d };
*/
// D - Circuit Structure Properties
final int BITS_PER_VARIABLE = 5;
final int LUT_INPUTS = 2;
// D - Simulator Properties
final int SIMULATOR_GATE_DELAY = 1;
final double T_SETUP = 0.45;
// M - Log Properties
int DUMP_POP_EVERY = 100;
// E - EXPERIMENT set up
ConfigurableRandomInputExperiment experiment = new MultiplierExperiment( 2, T_SETUP );
// D - DEPLOYMENT set up
ElementDelayModel delayModel = new GaussianDelayModel( 0.5, 0.5 );
CircuitMapping circuitMapping = new LUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs() + 1, BITS_PER_VARIABLE, LUT_INPUTS, delayModel );
SimulatorFaultyCircuit circuit = new SimulatorFaultyCircuit( circuitMapping );
SimulatorDeployment deployment = new SimulatorDeployment( circuit );
// A - Genetic Operators Set up
int genotypeLength = ( ( 1 << BITS_PER_VARIABLE ) - experiment.getNumOfInputs() ) * ( ( 1 << LUT_INPUTS ) + LUT_INPUTS * BITS_PER_VARIABLE );
int lutSize = 1 << LUT_INPUTS;
int blockSize = lutSize + LUT_INPUTS * BITS_PER_VARIABLE;
//final Genotype SEED0 = new FullOrderGenotype( "011011011011011010010011000100011000110101011110000000000000100100101111000000000000000000000000000100000101001000001101000000000000011011111110000000000000" ); // SF8 from log
final Genotype SEED0 = new FullOrderGenotype( genotypeLength );
// final Genotype SEED0 = new FullOrderGenotype( "H8ZldgKBW~~CtVhodvhhiWv[DX5ZSOcUA3uTJ^IPhiNFkID3uNFll9LMVoNLd`pTt57OtV", genotypeLength, 6 );
//final Genotype[] SEEDS = { };
Genotype[] SEEDS = new Genotype[ POP_SIZE ];
//SEEDS[ 0 ] = SEED0;
for( int pl = 0; pl < POP_SIZE; pl++ )
{
SEEDS[ pl ] = ( FullOrderGenotype ) SEED0.clone();
for( int bl = 0; bl < SEEDS[ pl ].length(); bl++ )
{
if( Math.random() < 0.5 )
{
SEEDS[ pl ].set( bl );
}
}
}
GeneticOperator m = new SAGAMutator( 1, 10 );
GeneticOperator spxo = new SinglePointXOver();
GeneticOperator bmin0 = new BunchMutator( BITS_PER_VARIABLE, 1, blockSize, lutSize );
GeneticOperator bmin1 = new BunchMutator( BITS_PER_VARIABLE, 1, blockSize, lutSize + BITS_PER_VARIABLE );
GeneticOperator bc = new BlockCopy ( blockSize, blockSize );
GeneticOperator[] geneticOps = { m, spxo, bmin0, bmin1, bc };
double[] opsProbs = { 0.3, 0.1, 0.2, 0.2, 0.2 };
/* 1+1
GeneticOperator[] geneticOps = { m };
double[] opsProbs = { MUTATION_PROB };
*/
// Selector selector = new FitnessProportionateSelector();
Selector selector = new RankSelector( );
Evolver evolver = new StandardEvolver( POP_SIZE, genotypeLength, geneticOps, opsProbs, selector, NUM_OF_ELITES, SEEDS );
//SingleFaultModel faultModel = new SingleStaticFaultModel( fPos );
//InteractionModel interactionModel = new StandardInteractionModel( evolver, deployment, experiment );
PopulationLogReader.fullOrderGenotypes = true;
int eSize = 9;
int nrEvals = 7;
boolean overdetecting = true;
InteractionModel inIm = new BISTPIM( evolver, deployment, circuit, experiment, faultModel, eSize, overdetecting );
int[] numProps = { 2 };
InteractionModel noisyIM = new NoisyPIM( inIm, deployment, experiment, numProps, nrEvals );
InteractionModel interactionModel = new CircuitParsimonyPIM( noisyIM, circuit );
Monica monica = new Monica( interactionModel, DUMP_POP_EVERY, java.lang.Integer.MAX_VALUE );
String dirName = "2MultBISTPars";
monica.setName( dirName );
taskQ.add( monica );
taskQNames.add( dirName );
ControlLib.writeGNUPlotScript( dirName, logDir, logFileName, 3, false );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -