📄 bistpimseqonlinefull.java~
字号:
//TI//longStory += "\nMoving to state " + sl + "(" + currNode + ") at " + stateEnterPos[ sl ] ;
// 2.2.1) Save state
currentState = circuit.getState();
circuitStates.put( currNode, currentState );
// 2.2.2) Save no faults behaviour in current state for all inputs
BitSet[] TPSBits = ( BitSet[] ) TPS.get( currNode );
BitSet[] shuffledTPSBits = ExperimentLib.shuffleTest( TPSBits );
shuffledTPS.put( currNode, shuffledTPSBits );
SampleData[] currTPS = ExperimentLib.generateInputFromTest( shuffledTPSBits, 1, shuffledTPSBits[ 0 ].length(), inputSampleSeparation );
int nrInputCombinations = currTPS[ 0 ].length();
SampleData[] currStateQs = circuit.run( currTPS );
TPQS.put( currNode, currStateQs );
//TI//longStory += "\nBehaviour " + ESLib.sampleDatasToString( currTPS, currStateQs );
// 2.3) Iterate through faults
faultModel.reset();
while( faultModel.hasMoreElements() )
{
java.awt.Point currFault = ( java.awt.Point ) faultModel.nextElement();
if( used[ currFault.x ] ) // Skipping faults in unused elements.
{
circuit.setFault( currFault );
SampleData[] currStateFaultQs = circuit.run( currTPS );
int[] eBehaviour = new int[ nrInputCombinations ];
int newInstances = BISTLib.countDiagnoses( currStateQs, currStateFaultQs, eBehaviour, eSize, nrEs, inputSampleSeparation, EStartAt, DQTol );
Vector currStateFaultKey = new Vector();
currStateFaultKey.add( currNode );
currStateFaultKey.add( currFault );
EBehaviour.put( currStateFaultKey, eBehaviour );
diagInstances += newInstances;
nrInstances += nrInputCombinations;
// TI // longStory += currFault + ": " + newInstances + " out of " + nrInputCombinations;
circuit.removeFault( currFault );
circuit.setState( currentState );
}
}
}
f_b = 1d / ( ( nrInstances - diagInstances ) / 25d + 1d );
// 3) Compute f_b_t transitions
// For now only evalaute f_b_t if f_t = f_b = 1
if( f_e > 0.9999 && f_b > 0.9999 )
{
int incorrectTransitions = 0;
// 3.1) At every state
for( int sl = 0; sl < nrStates; sl++ )
{
MealyFSMNode currNode = stateEnterNodes[ sl ];
BitSet[] TP = ( BitSet[] ) shuffledTPS.get( currNode );
CircuitState currState = ( CircuitState ) circuitStates.get( currNode );
// 3.2 Under each fault
faultModel.reset();
while( faultModel.hasMoreElements() )
{
java.awt.Point currFault = ( java.awt.Point ) faultModel.nextElement();
if( used[ currFault.x ] ) // Skipping faults in unused elements.
{
//TI//longStory += "\nChecking transitions from state " + sl + " under fault " + currFault + " node is " + currNode;
Vector stateFaultKey = new Vector();
stateFaultKey.add( currNode );
stateFaultKey.add( currFault );
int[] eBehaviour = ( int[] ) EBehaviour.get( stateFaultKey );
for( int itpl = 0; itpl < eBehaviour.length; itpl++ )
{
switch( eBehaviour[ itpl ] )
{
case E_LOW_ERROR:
incorrectTransitions++; break;
case E_HIGH:
break;
case E_LOW_OK:
{
//TI//longStory += "\nInput Pattern " + itpl + " was E_LOW_OK";
// 1. Restore state & Set Fault
circuit.setState( currState );
circuit.setFault( currFault );
// 2. Clock in the input for which E was low to force state transition
int nrInputs = TP.length;
SampleData[] clockInWithCurrInput = new SampleData[ nrInputs ];
for( int il = 0; il < nrInputs; il++ )
{
clockInWithCurrInput[ il ] = new SampleData( inputSampleSeparation, 2 );
}
int currInputPattern = ESLib.getLine( TP, itpl );
ESLib.setLine( clockInWithCurrInput, 0, currInputPattern );
ESLib.setLine( clockInWithCurrInput, 1, currInputPattern + 1 ); // with clock high
SampleData[] transitionQ = circuit.run( clockInWithCurrInput ); // should now be at next state
circuit.removeFault( currFault );
//TI//longStory += "\nJust ran" + ESLib.sampleDatasToString( clockInWithCurrInput, temp );
if( !BISTLib.getE( transitionQ, eSize, nrEs, inputSampleSeparation, EStartAt ) )
{
// 3. Test to see if we have really moved to this new state
MealyFSMNode nextNode = currNode.nextStates[ currInputPattern / 2 ].dest;
BitSet[] TPNS = ( BitSet[] ) shuffledTPS.get( nextNode );
SampleData[] TPQNS = ( SampleData[] ) TPQS.get( nextNode );
SampleData[] nextTPS = ExperimentLib.generateInputFromTest( TPNS, 1, TPNS[ 0 ].length(), inputSampleSeparation );
int nrInputCombinations = nextTPS[ 0 ].length();
SampleData[] TPQNS2 = circuit.run( nextTPS );
int[] nextEBehaviour = new int[ nrInputCombinations ];
int correctDiagnoses = BISTLib.countDiagnoses( TPQNS, TPQNS2, nextEBehaviour, eSize, nrEs, inputSampleSeparation, EStartAt, DQTol );
if( correctDiagnoses < nrInputCombinations )
{
incorrectTransitions++;
//TI//longStory += "\nBad transition at state " + sl + " fault " + currFault + " ins " + currInputPattern;
//TI//shortStory += "\nBad transition at state " + sl + " fault " + currFault + " ins " + currInputPattern;
//TI//longStory += "\nQ vs Q2\n " + ESLib.sampleDatasToString( TPQNS, TPQNS2 );
}
} // end if E low
} // end case LOW_OK
} // end switch
} // end for input patterns of e behaviour
} // end if fault used
} // end while fault loop
} // end for state loop
f_b_t = 1d / ( incorrectTransitions / 50d + 1d );
} // end F_B_T if
}
ind.setProperty( 0, new Double( f_b ) );
ind.setProperty( 1, new Double( f_b_t ) );
houseWork( ind, f_e );
double[] rv = { f_e };
return rv;
}
public String toString()
{
String narrator = "BIST Sequential Online Full Test Interaction Model with:";
narrator += "\n Threshold = " + threshold;
narrator += "\n Error Line Start At = " + EStartAt;
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 = jaga.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 + -