?? evorobotech2.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.util.Random;
import java.rmi.*;
import java.io.*;
import java.awt.Point;
/**
*
* @author Michael Garvie
* @version
*/
public abstract class EvoRobotech_1
{
static Vector taskQ = new Vector();
static Vector taskQNames = new Vector();
static String logDir;
static final String logFileName = "robotech.txt";
static final double migrationRate = 0.5;
public static void main( String[] args )
{
logDir = args[ 0 ];
//DebugLib.trcLogger.isLogging = true;
DebugLib.logFileName = logFileName;
//add2MultBISTpF( new SingleFullFaultModel( 28 ) );
try
{
// I - Two bit mult Single Fault repair
int usedEls = 4;
int N = 2;
FaultModel faultModel = new SingleFullFaultModel( usedEls );
for( int nl = 0; nl < N; nl++ )
{
while( faultModel.hasMoreElements() )
{
Point fault = ( Point ) faultModel.nextElement();
addRepair2MultSingle( nl, fault );
}
faultModel.reset();
}
// II - Multiple faults
IslandsEvolutionServer ms = new IslandsEvolutionServer( "Robotech", taskQ, taskQNames, logDir, migrationRate );
ms.bindServer();
//MonicaServer ms = new MonicaServer( "MonicaServer", taskQ, taskQNames, args[ 0 ], 0.5 );
}catch( Exception e )
{
e.printStackTrace();
}
}
private static void addRepairb1Single( int ix, Point fault ) throws IOException
{
// A - Genetic Algorithms Properties
final int POP_SIZE = 2;
final int GENOTYPE_MUT = 1;
final int NUM_OF_ELITES = 1;
final double[] RANK_PROBS = { 1d, 0d };
// D - Circuit Structure Properties
final int LUT_INPUTS = 4;
// 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
String blifFileName = "/home/mmg20/eh/benchmarks/b1.blif";
ConfigurableRandomInputExperiment experiment = new CombinationalBLIFExperiment( blifFileName, T_SETUP );
// A - Load Seed
String sisOutputFileName = "/home/mmg20/eh/benchmarks/b1L4.sout";
int resQ = 0;
boolean fpga = true;
boolean voter = false;
SisOutputReader sor = new SisOutputReader( new File( sisOutputFileName ), resQ, LUT_INPUTS, fpga, voter );
Genotype seed = new Genotype( sor.getGenotype() );
int bitsPerVar = sor.getBitsPerVar();
int usedEls = sor.getTotalEls();
// D - DEPLOYMENT set up
//ElementDelayModel delayModel = new CoinDelayModel( ); // Noise 1
double minmu = 0;
double maxmu = 4;
double sigma = 0.1;
int muD = 50 * 60 * 60 * 3;
int muS = 50 * 60 * 60 * 1;
DriftingGaussianDelayModel delayModel = new DriftingGaussianDelayModel( minmu,maxmu,sigma,muD,muS ); // Noise 1
//ElementDelayModel delayModel = new ConstantDelayModel( 0 ); // No Noise 1
CircuitMapping circuitMapping = new FPGALUTAbsoluteMapping( experiment.getNumOfInputs(), experiment.getNumOfOutputs(), bitsPerVar, LUT_INPUTS, delayModel );
SimulatorFaultyCircuit circuit = new SimulatorFaultyCircuit( circuitMapping );
int[] fPos = { fault.x };
int[] fVal = { fault.y };
circuit.setPersistentFaults( fPos, fVal );
SimulatorDeployment deployment = new SimulatorDeployment( circuit );
// A - Genetic Operators Set up
int genotypeLength = seed.length();
//( ( 1 << bitsPerVar ) - experiment.getNumOfInputs() ) * ( ( 1 << LUT_INPUTS ) + LUT_INPUTS * bitsPerVar );
int lutSize = 1 << LUT_INPUTS;
int blockSize = lutSize + LUT_INPUTS * bitsPerVar;
final Genotype[] SEEDS = { seed };
GeneticOperator m = new ExactGenotypeMutator( GENOTYPE_MUT );
GeneticOperator[] geneticOps = { m };
double[] opsProbs = { 1 };
Selector selector = new RankSelector( RANK_PROBS );
Evolver evolver = new StandardEvolver( POP_SIZE, genotypeLength, geneticOps, opsProbs, selector, NUM_OF_ELITES, SEEDS );
InteractionModel interactionModel = new StandardInteractionModel( evolver, deployment, experiment );
Monica monica = new Monica( interactionModel, DUMP_POP_EVERY, java.lang.Integer.MAX_VALUE );
String fs = File.separator;
String faultDesc = "SSA" + fault.x + "." + fault.y;
String dirName = "Repair" + fs + "2Mult" + fs + faultDesc + fs + ix ;
monica.setName( dirName );
taskQ.add( monica );
taskQNames.add( dirName );
ControlLib.writeGNUPlotScript( dirName, logDir, logFileName );
}
/*
private static void addRepair2MultMultiple( int M ) throws IOException
{
// bpv = 4. 16 - 5 (i + clk ) - 4 (used) = 7 free LUTs. ( els 4 to 10 incl. )
// + 16 - 5 = 11 Latches. (els 16 to 26 incl. )
// Total free = 18. Fail up to 16 of them with max Gen =
String narrator = "Repairing two-bit multiplier under multiple faults.\n";
narrator += "bpv = 4. 16 - 5 (i + clk ) - 4 (used) = 7 free LUTs. ( els 4 to 10 incl. )\n";
narrator += "+ 16 - 5 = 11 Latches. (els 16 to 26 incl. )\n";
narrator += "Total free = 18. Fail up to 18 of them with max Gen = 129.6M (1 month at 50g/s)\n";
narrator += "Max Generations = 50 * 3600 * 24 * 40 ( a month ).\n";
narrator += "\nOrderings:\n";
int[] faultPos = { 4,5,6,7,8,9,10,16,17,18,19,20,21,22,23,24,25,26 };
int seqLen = 18;
Vector[] orders = new Vector[ M ];
Random rnd = new Random();
for( int ml = 0; ml < M; ml++ )
{
orders[ ml ] = new Vector();
Vector allFaults = new Vector();
for( int flp = 0; flp < faultPos.length; flp++ )
{
allFaults.add( new Integer( faultPos[ flp ] ) );
}
for( int flp = 0; flp < seqLen; flp++ )
{
int ix = rnd.nextInt( allFaults.size() );
Integer currFPos = ( Integer ) allFaults.remove( ix );
int currFVal = rnd.nextInt( 2 ); // SSA0 or 1
orders[ ml ].add( new Point( currFPos.intValue(), currFVal ) );
}
narrator += ml+": " + orders[ ml ] + "\n";
}
String fs = File.separator;
String dirName = "Repair" + fs + "2Mult" + fs + "Multiple" + fs;
File orderFile = new File( dirName + "orders.txt" );
BufferedWriter bw = new BufferedWriter( new FileWriter( orderFile ) );
bw.write( narrator );
bw.flush();
bw.close();
for( int ml = 0; ml < M; ml++ )
{
addRepair2MultSequence( ml, orders[ ml ] );
}
}
/*
private static void addRepair2MultSequence( int ix, Vector seq ) throws IOException
{
Vector currFaults = new Vector();
for( int sl = 0; sl < seq.size(); sl++ )
{
currFaults.add( seq.get( sl ) );
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -