?? bistpimseqonlinestochastic.java~
字號:
/*
* BISTIM.java
*
* Created on 19 May 2002, 18:56
package es.pj.circuits.control;
import es.evolve.Evolver;
import es.deploy.Deployment;
import es.experiment.*;
import es.control.StandardInteractionModel;
import es.*;
import es.pj.circuits.fpgaft.*;
import es.pj.circuits.SimulatorLogicElement;
import es.pj.circuits.experiment.ConfigurableSequentialCircuitExperiment;
import java.util.Random;
import java.util.Vector;
import islandev.SnapshotPainter;
import islandev.EmptySnapshotPainter;
/** Like BISTPIM but:
* <ul><li>Only On-Line BIST evaluated (must report first fault affecting outputs)</li>
* <li>Optimization in SimulatorFaultyCircuitOpt used for sequenial circuits</li>
* <li>For combinational circuits use BISTPIM</li>
* <li>Overdetecting always good.
* </ul>
*
*/
public class BISTPIMSeqOnline extends StandardInteractionModel
{
// Config Vars
// Variables for finding E
protected int startAt = 0; // For each input cycle, start at ...
protected int eSize;
protected int inputResetLength = 0;
// Variable for extracting value of output (kind of inverse of t_setup)
protected double threshold = 0.1;
//Working Vars
protected double currMaxF_e = -1;
protected SingleFaultModel faultModel;
protected SingleRandomFaultModel srfm = null; // If its randomness, its randomness will need to be controlled
protected ConfigurableSequentialCircuitExperiment scexp;
protected SimulatorFaultyCircuitOpt circuit;
public BISTPIMSeqOnline(Evolver evo, Deployment dep, SimulatorFaultyCircuitOpt cir, ConfigurableSequentialCircuitExperiment exp, int iss, SingleFaultModel fm, int es,SnapshotPainter painter, int startAt, int inputResetLength ) {
this( evo, dep, cir, exp, iss, fm, es );
this.painter = painter;
this.startAt = startAt;
this.inputResetLength = inputResetLength;
}
public BISTPIMSeqOnline(Evolver evo, Deployment dep, SimulatorFaultyCircuitOpt cir, ConfigurableSequentialCircuitExperiment exp, int iss, SingleFaultModel fm, int es) {
super( evo, dep, exp, iss );
scexp = exp;
circuit = cir;
faultModel = fm;
if( faultModel instanceof SingleRandomFaultModel )
{
srfm = ( SingleRandomFaultModel ) fm;
}
eSize = es;
}
public void evolve()
{
super.evolve();
if( srfm != null )
{
srfm.nextRandomSeries(); // Same for all per generation, but != 'tween generations.
}
currMaxF_e = -1;
}
/** Evaluates these individuals using the deployment and experiments and
* procedure of this model.
*/
synchronized public double[] evaluate(Genotype[] inds)
{
Genotype ind = inds[ 0 ];
// 1) Evaluate Ind with no faults.
deployment.program( ind );
SampleData[] input = experiment.generateInput( inputSampleSeparation );
int insertFaultAt = scexp.rndStatePos();
//TI//if( !stateNoise )
//TI//{
//TI//circuit.reset();
//TI//}else
//TI//{
circuit.randomReset();
//TI//}
SampleData[] noFQWithE = deployment.run( input );
int nrOuts = noFQWithE.length - 1;
SampleData[] noFQNoE = ESLib.getLines( noFQWithE, 0, nrOuts );
double f_e = experiment.getFitness( input, noFQNoE );
double f_b = 0;
boolean mainTaskOK = f_e > currMaxF_e - threshold;
// 2) Compute f_b now.
if( mainTaskOK && !getE( noFQWithE ) ) // Check that E low for no faults! If it isn't, then discard.
{
currMaxF_e = Math.max( f_e, currMaxF_e );
// 2.1) Init variables.
boolean[] used = getUsed( nrOuts ); // Skipping faults in unused elements.
int nrFaults = 1; // how many faults tested for
int diagFaults = 1; // how many correctly diagnosed, including no faults.
int[] rv2 = { 0 };
// 2) Check if faults are detected at the right moment. Ie: if
// at the first moment the circuit gives out a wrong output the
// error line is high.
// 2.2) Iterate through faults
faultModel.reset();
while( faultModel.hasMoreElements() )
{
java.awt.Point fPosVal = ( java.awt.Point ) faultModel.nextElement();
if( used[ fPosVal.x ] ) // Skipping faults in unused elements.
{
//circuit.setFault( fPosVal.x, fPosVal.y );// Set it during run so randomize state inserted at
//TI//if( !stateNoise )
//TI//{
//TI//circuit.reset();
//TI//}else
//TI//{
circuit.randomReset();
//TI//}
// 2.2.2) Run Circuit with Fault.
circuit.run( input, noFQWithE, rv2, fPosVal, insertFaultAt );
if( rv2[ 0 ] == SimulatorFaultyCircuitOpt.NORMAL )
{
circuit.run( input, noFQWithE, rv2, insertFaultAt ); // Run again because fault hasn't affected Q
}
switch( rv2[ 0 ] )
{
case SimulatorFaultyCircuitOpt.LINE_HIGH:
{
// Fault detected, score point
};
case SimulatorFaultyCircuitOpt.NORMAL:
{
// No Fault, No detection, score point
diagFaults++;
}
case SimulatorFaultyCircuitOpt.OUTPUT_DIFFERENT:
{
// Undetected Fault, no points
};
}
nrFaults++;
circuit.removeFault( fPosVal ); // clear fault
}
}
f_b = 1d / ( ( nrFaults - diagFaults ) / 25d + 1d );
}
ind.setProperty( 0, new Double( f_b ) );
ind.setProperty( 1, new Double( f_b ) );
houseWork( ind, f_e );
double[] rv = { f_e };
return rv;
}
/** Returns the value of E for this segment */
protected boolean getE( SampleData[] output )
{
SampleData E = output[ output.length - 1 ];
int outLen = E.length();
int inputCycles = outLen / inputSampleSeparation;
for( int idl = inputResetLength; idl < inputCycles; idl++ )
{
int conc = 0;
for( int odl = startAt; odl < inputSampleSeparation; odl++ )
{
if( E.get( idl * inputSampleSeparation + odl ) )
{
conc++;
if( conc == eSize )
{
return true;
}
}else
{
conc = 0;
}
}
}
return false;
}
public String toString()
{
String narrator = "BIST Sequential Online Interaction Model with:";
narrator += "\n Threshold = " + threshold;
narrator += "\n Error Line Start At = " + startAt;
narrator += "\n Error High Minimum Size = " + eSize;
narrator += "\n Input Reset Pattern Length = " + inputResetLength;
narrator += "\n Fault Model: " + faultModel;
narrator += "\n\nExperiment: " + experiment;
narrator += "\n\nDeployment: " + deployment;
narrator += "\n\nEvolver: " + evolver;
narrator += "\n";
return narrator;
}
// Snapshot so far does normal thing
protected boolean[] getUsed( int outs )
{
SimulatorLogicElement[] els = circuit.getElements();
boolean[] rv = new boolean[ els.length ];
for( int ol = 0; ol < outs; ol++ )
{
addConnectedGates( rv, els[ ol ], els );
}
return rv;
}
protected void addConnectedGates( boolean[] added, SimulatorLogicElement el, SimulatorLogicElement[] els )
{
int elinels = es.ESLib.indexOf( el, els );
if( elinels >= 0 && !added[ elinels ] )
{
added[ elinels ] = true;
SimulatorLogicElement[] ins = el.getInputs();
if( ins != null )
{
for( int il = 0; il < ins.length; il++ )
{
addConnectedGates( added, ins[ il ], els );
}
}
}
}
public Genotype getMaxFitness()
{
Genotype rv = super.getMaxFitness();
rv.setProperty( 0, new Double( 1 ) );
rv.setProperty( 1, new Double( 1 ) );
return rv;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -