SmartSwitch/sswSlowClassifier.cpp
//******************************************************************************
//******************************************************************************
//******************************************************************************
// Classify the input variable according to the thresholder bank.
// The change flag is true if the output above flag is different
// from its previous value.
Classify the input variable according to the thresholder bank.
The change flag is true if the output above flag is different
from its previous value.
Classify the input variable according to the thresholder bank . The change flag is true if the output above flag is different from its previous value .
void SlowClassifier::doClassify(
   float  aValue,          
   int&   aClass,          
   bool&  aChangeFlag)     
{
   mValue = aValue;
   mLastClass = mClass;
   mThresholderM2.doUpdate(mValue, mAboveFlagM2, mChangeFlagM2);
   mThresholderM1.doUpdate(mValue, mAboveFlagM1, mChangeFlagM1);
   mThresholderP1.doUpdate(mValue, mAboveFlagP1, mChangeFlagP1);
   mThresholderP2.doUpdate(mValue, mAboveFlagP2, mChangeFlagP2);
   mChangeFlag = mChangeFlagM2 || mChangeFlagM1 || mChangeFlagP1 || mChangeFlagP2;
   mFuzzyConfidence = (
      mThresholderM2.mFuzzyConfidence &&
      mThresholderM1.mFuzzyConfidence &&
      mThresholderP1.mFuzzyConfidence &&
      mThresholderP2.mFuzzyConfidence);
   if (!mAboveFlagM2)
   {
      mClass = -2;
   }
   else if (mAboveFlagM2 && !mAboveFlagM1)
   {
      mClass = -1;
   }
   else if (mAboveFlagM1 && !mAboveFlagP1)
   {
      mClass = 0;
   }
   else if (mAboveFlagP1 && !mAboveFlagP2)
   {
      mClass = 1;
   }
   else if (mAboveFlagP2)
   {
      mClass = 2;
   }
   else
   {
      mClass = -99;
   }
   mCount++;
   mChangeFlag = mClass != mLastClass;
   aClass = mClass;
   aChangeFlag = mChangeFlag;
}
void SlowClassifier :: doClassify ( float aValue , int & aClass , bool & aChangeFlag ) { mValue = aValue ; mLastClass = mClass ; mThresholderM2 . doUpdate ( mValue , mAboveFlagM2 , mChangeFlagM2 ) ; mThresholderM1 . doUpdate ( mValue , mAboveFlagM1 , mChangeFlagM1 ) ; mThresholderP1 . doUpdate ( mValue , mAboveFlagP1 , mChangeFlagP1 ) ; mThresholderP2 . doUpdate ( mValue , mAboveFlagP2 , mChangeFlagP2 ) ; mChangeFlag = mChangeFlagM2 || mChangeFlagM1 || mChangeFlagP1 || mChangeFlagP2 ; mFuzzyConfidence = ( mThresholderM2 . mFuzzyConfidence && mThresholderM1 . mFuzzyConfidence && mThresholderP1 . mFuzzyConfidence && mThresholderP2 . mFuzzyConfidence ) ; if ( ! mAboveFlagM2 ) { mClass = -2 ; } else if ( mAboveFlagM2 && ! mAboveFlagM1 ) { mClass = -1 ; } else if ( mAboveFlagM1 && ! mAboveFlagP1 ) { mClass = 0 ; } else if ( mAboveFlagP1 && ! mAboveFlagP2 ) { mClass = 1 ; } else if ( mAboveFlagP2 ) { mClass = 2 ; } else { mClass = -99 ; } mCount ++ ; mChangeFlag = mClass != mLastClass ; aClass = mClass ; aChangeFlag = mChangeFlag ; }
Classify the input variable according to the thresholder bank.
Classify the input variable according to the thresholder bank .
// Input // Output // Output //*************************************************************************** //*************************************************************************** //*************************************************************************** // Do this first. //*************************************************************************** //*************************************************************************** //*************************************************************************** // Thresholder tests. // Update the thresholder bank with the input value. // Update the change flag. // Update the fuzzy confidence. //*************************************************************************** //*************************************************************************** //*************************************************************************** // Classify. // Classify the input according to the threshold bank test results. //*************************************************************************** //*************************************************************************** //*************************************************************************** // Write to output variables.