nrc.fuzzy
Class FuzzyRule

java.lang.Object
  |
  +--nrc.fuzzy.FuzzyRule
All Implemented Interfaces:
java.io.Serializable

public class FuzzyRule
extends java.lang.Object
implements java.io.Serializable

A FuzzyRule holds three sets FuzzyValues for the antecedents, conclusions and input values of a rule. A rule might be written as follows:

   if antecedent1 and
      antecedent2 and
          ...
      antecedentn
   then
      conclusion1 and
      conclusion2 and
          ...
      conclusionm
 
Attaching a set of fuzzy value inputs to the rule that correspond to actual values for the antecedents, a set of actual conclusions can be determined by executing (firing) the rule, using the FuzzyRuleExecutor that is associated with a the rule. The executor will generally implement one of the common algorithms for fuzzy inferencing such as the Mamdani min inference operator with the Max-Min composition operator.

Note that this allows only very simple rules that have only fuzzy values on the left hand side and right hand side. The fuzzy package is integrate with the Jess expert system shell and provides the ability to create much more complex rules, combining crisp and fuzzy values. It also provides a simpler way to build the rule systems.

An very simple example of Java code that implements a rule and its firing follows:

        // some values used to describe fuzzy terms 
                double xHot[] = {25, 35};
                double yHot[] = {0, 1};
                double xCold[] = {5, 15};
                double yCold[] = {1, 0};
                // A few FuzzyValues
            FuzzyValue fval = null;
            FuzzyValue fval2 = null;
            FuzzyValue fval3 = null;
        FuzzyValue fvals[] = new FuzzyValue[2];
        // define our temperature fuzzy variable
        FuzzyVariable temp = new FuzzyVariable("temperature", 0, 100, "C");
            temp.addTerm("hot", xHot, yHot, 2);
            temp.addTerm("cold", xCold, yCold, 2);
            temp.addTerm("veryHot", "very hot");
            temp.addTerm("medium", "(not hot and (not cold))");
        // define our pressure fuzzy variable
        FuzzyVariable pressure = new FuzzyVariable("pressure", 0, 10, "kilo-pascals");
            pressure.addTerm("low", new ZFuzzySet(2.0, 5.0));
            pressure.addTerm("medium", new PIFuzzySet(5.0, 2.5));
            pressure.addTerm("high", new SFuzzySet(5.0, 8.0)); 
        // let's try some rules --- 
        FuzzyRule rule1 = new FuzzyRule();
        fval = new FuzzyValue( temp, "hot");
        fval2 = new FuzzyValue( pressure, "low or medium");
        fval3 = new FuzzyValue( temp, "very medium");
        rule1.addAntecedent(fval);
        rule1.addConclusion(fval2);
        rule1.addInput(fval3);
        // execute this simple rule with a single antecedent and 
        // a single consequent using default rule executor --
        // MamdaniMinMaxMinRuleExecutor
        FuzzyValueVector fvv = rule1.execute();
        // show the results
            fvals[0] = fval;
            fvals[1] = fval3;
            System.out.println(FuzzyValue.plotFuzzyValues("*+", 0, 50, fvals));
            System.out.println(fval2.plotFuzzyValue("*", 0, 10));
            System.out.println(fvv.fuzzyValueAt(0).plotFuzzyValue("*", 0, 10));
            // execute again with a different rule executor -- 
            // LarsenProductMaxMinRuleExecutor
        fvv = rule1.execute(new LarsenProductMaxMinRuleExecutor());
        // and show results
            System.out.println(fvv.fuzzyValueAt(0).plotFuzzyValue("*", 0, 10));
        
        the above would produce the following graphs as output
        
        The Antecedent (hot) and the input (very medium) fuzzy values
        
    Fuzzy Value: temperature
    Linguistic Value: hot (*),  very medium (+)

     1.00               +++++++++++         ****************
     0.95
     0.90                                  *
     0.85
     0.80              +           +      *
     0.75
     0.70                                *
     0.65             +             +
     0.60                               *
     0.55
     0.50            +               + *
     0.45
     0.40                             *
     0.35           +                 +
     0.30                            *
     0.25          +                   +
     0.20                           *
     0.15         +                     +
     0.10        +                 *     +
     0.05       +                         +
     0.00+++++++*******************        +++++++++++++++++
         |----|----|----|----|----|----|----|----|----|----|
        0.00     10.00     20.00     30.00     40.00     50.00

    The conclusion fuzzy value.

    Fuzzy Value: pressure
    Linguistic Value: low or medium (*)

     1.00************            ***
     0.95            *          *   *
     0.90             *        *     *
     0.85              *
     0.80                     *       *
     0.75               *
     0.70                    *
     0.65                *             *
     0.60
     0.55                 * *           *
     0.50
     0.45                  *
     0.40                   *            *
     0.35
     0.30
     0.25                                 *
     0.20
     0.15                                  *
     0.10                                   *
     0.05                                    *
     0.00                                     **************
         |----|----|----|----|----|----|----|----|----|----|
        0.00      2.00      4.00      6.00      8.00     10.00

    The output using MamdaniMinMaxMinRuleExecutor
    
    Fuzzy Value: pressure
    Linguistic Value: ??? (*)

     1.00
     0.95
     0.90
     0.85
     0.80
     0.75
     0.70
     0.65
     0.60
     0.55
     0.50
     0.45
     0.40*********************************
     0.35
     0.30
     0.25                                 *
     0.20
     0.15                                  *
     0.10                                   *
     0.05                                    *
     0.00                                     **************
         |----|----|----|----|----|----|----|----|----|----|
        0.00      2.00      4.00      6.00      8.00     10.00

    The conclusion using LarsenProductMaxMinRuleExecutor.
     
    Fuzzy Value: pressure
    Linguistic Value: ??? (*)

     1.00
     0.95
     0.90
     0.85
     0.80
     0.75
     0.70
     0.65
     0.60
     0.55
     0.50
     0.45
     0.40************             *
     0.35            ***       *** ***
     0.30               *     *       *
     0.25                *   *         *
     0.20                 * *           *
     0.15                  **            *
     0.10                                 *
     0.05                                  **
     0.00                                    ***************
         |----|----|----|----|----|----|----|----|----|----|
        0.00      2.00      4.00      6.00      8.00     10.00	
 

See Also:
MamdaniMinMaxMinRuleExecutor, LarsenProductMaxMinRuleExecutor, FuzzyValue, FuzzyVariable, FuzzySet, Serialized Form

Constructor Summary
FuzzyRule()
          Create a FuzzyRule with a default FuzzyRuleExecutor.
FuzzyRule(nrc.fuzzy.AntecedentCombineOperator combineOperator)
          Create a FuzzyRule with a specified antecedentCombineOperator.
FuzzyRule(nrc.fuzzy.FuzzyRuleExecutor exec)
          Create a FuzzyRule with a specified FuzzyRuleExecutor.
FuzzyRule(nrc.fuzzy.FuzzyRuleExecutor exec, nrc.fuzzy.AntecedentCombineOperator combineOperator)
          Create a FuzzyRule with a specified FuzzyRuleExecutor and an antecedentCombineOperator.
 
Method Summary
 void addAntecedent(nrc.fuzzy.FuzzyValue fval)
          Add an antecedent FuzzyValue to the to the end of the set of antecedents for this rule.
 void addConclusion(nrc.fuzzy.FuzzyValue fval)
          Add a conclusion FuzzyValue to the to the end of the set of conclusions for this rule.
 void addInput(nrc.fuzzy.FuzzyValue fval)
          Add an input FuzzyValue to the to the end of the set of inputs for this rule.
 nrc.fuzzy.FuzzyValue antecedentAt(int i)
          Get the antecedent FuzzyValue from the set of antecedents for this rule at the position indicated.
 int antecedentsSize()
          Return the size of the set of antecedents (the number of antecedents in the rule.
 nrc.fuzzy.FuzzyValue conclusionAt(int i)
          Get the conclusion FuzzyValue from the set of conclusions for this rule at the position indicated.
 int conclusionsSize()
          Return the size of the set of conclusions (the number of conclusions in the rule.
 boolean doTestRuleMatching(double threshold, nrc.fuzzy.FuzzyValueVector antecedents, nrc.fuzzy.FuzzyValueVector inputs)
          Does the work for the testRuleMatching methods.
 nrc.fuzzy.FuzzyValueVector execute()
          Execute (fire) the rule.
 nrc.fuzzy.FuzzyValueVector execute(nrc.fuzzy.FuzzyRuleExecutor exec)
          Execute (fire) the rule.
 nrc.fuzzy.FuzzyValueVector execute(nrc.fuzzy.FuzzyRuleExecutor exec, nrc.fuzzy.FuzzyValueVector inputs)
          Execute (fire) the rule.
 nrc.fuzzy.FuzzyValueVector execute(nrc.fuzzy.FuzzyValueVector inputs)
          Execute (fire) the rule.
 nrc.fuzzy.AntecedentCombineOperator getAntecedentCombineOperator()
          Get the rule's current antecedent combine operator.
 nrc.fuzzy.FuzzyValueVector getAntecedents()
          Return the set of antecedents in a FuzyValueVector.
 nrc.fuzzy.FuzzyValueVector getConclusions()
          Return the set of conclusions in a FuzzyValueVector.
static nrc.fuzzy.AntecedentCombineOperator getDefaultAntecedentCombineOperator()
          Get the default antecedent combine operator for FuzzyRules.
static nrc.fuzzy.FuzzyRuleExecutor getDefaultRuleExecutor()
          Get the default executor for FuzzyRules.
 nrc.fuzzy.FuzzyValueVector getInputs()
          Return the set of inputs in a FuzyValueVector.
 nrc.fuzzy.FuzzyRuleExecutor getRuleExecutor()
          Get the rule's current rule executor.
 nrc.fuzzy.FuzzyValue inputAt(int i)
          Get the input FuzzyValue from the set of inputs for this rule at the position indicated.
 int inputSize()
          Return the size of the set of inputs (the number of inputs in the rule.
 void insertAntecedentAt(nrc.fuzzy.FuzzyValue fval, int i)
          Insert an antecedent FuzzyValue into the set of antecedents for this rule at the position indicated.
 void insertConclusionAt(nrc.fuzzy.FuzzyValue fval, int i)
          Insert a conclusion FuzzyValue into the set of conclusions for this rule at the position indicated.
 void insertInputAt(nrc.fuzzy.FuzzyValue fval, int i)
          Insert an input FuzzyValue into the set of inputs for this rule at the position indicated.
 boolean isAntecedentsChanged()
          Get of change status of the antecedents.
 boolean isAntecendentCombineOperatorChanged()
          Get of change status of the antecedent combine operator.
 boolean isConclusionsChanged()
          Get of change status of the conclusions.
 boolean isInputsChanged()
          Get of change status of the inputs.
 void removeAllAntecedents()
          Remove all antecedent FuzzyValues from the set of antecedents for this rule.
 void removeAllConclusions()
          Remove all conclusion FuzzyValues from the set of conclusions for this rule.
 void removeAllInputs()
          Remove all input FuzzyValues from the set of inputs for this rule.
 void removeAntecedentAt(int i)
          Remove an antecedent FuzzyValue from the set of antecedents for this rule at the position indicated.
 void removeConclusionAt(int i)
          Remove a conclusion FuzzyValue from the set of conclusions for this rule at the position indicated.
 void removeInputAt(int i)
          Remove an input FuzzyValue from the set of inputs for this rule at the position indicated.
 void setAntecedentCombineOperator(nrc.fuzzy.AntecedentCombineOperator combineOperator)
          Set the rule's antecedent combine operator to the one provided.
static void setDefaultAntecedentCombineOperator(nrc.fuzzy.AntecedentCombineOperator combineOperator)
          Set the rule's default antecedent combine operator to the one provided.
static void setDefaultRuleExecutor(nrc.fuzzy.FuzzyRuleExecutor exec)
          Set the rule's default executor to the one provided.
 void setRuleExecutor(nrc.fuzzy.FuzzyRuleExecutor exec)
          Set the rule's executor to the one provided.
 boolean testRuleMatching()
          Test to see if the rule antecedents match the rule inputs with enough overlap to ensure rule will fire with meaninful outputs.
 boolean testRuleMatching(double threshold)
          Test to see if the rule antecedents match the rule inputs with enough overlap to ensure rule will fire with meaninful outputs.
 boolean testRuleMatching(double threshold, nrc.fuzzy.FuzzyValueVector inputs)
          Test to see if the rule antecedents match the rule inputs with enough overlap to ensure rule will fire with meaninful outputs.
 boolean testRuleMatching(nrc.fuzzy.FuzzyValueVector inputs)
          Test to see if the rule antecedents match the rule inputs with enough overlap to ensure rule will fire with meaninful outputs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FuzzyRule

public FuzzyRule()
Create a FuzzyRule with a default FuzzyRuleExecutor. Currently the initial default executor is the MamdaniMinMaxMinRuleExecutor. This can be changed with the method setDefaultRuleExecutor. Note that each FuzzyRule that is constructed actually gets it own rule executor. To ensure this the default FuzzyRuleExecutor is copied. This provides the rule executors with the option to remember state from one rule execution to another that will possibly allow it to be more efficient. For example, the MamdaniMinMaxMinRuleExecutor calculates the DOF (degree of matching/fulfillment) of all of the input/antecedent pairs. If only the outputs change then the DOF is still valid and the overhead of generating the outputs is considerably reduced.
The DOF for all input/antecedent pairs can be calculated in many ways. This is determined by the rule's antecedentCombineOperator setting. Supported operations include the minimum of the matching value for all of the pairs and the product of the values.


FuzzyRule

public FuzzyRule(nrc.fuzzy.FuzzyRuleExecutor exec)
Create a FuzzyRule with a specified FuzzyRuleExecutor. Note that each FuzzyRule that is constructed actually gets it own rule executor. To ensure this the FuzzyRuleExecutor supplied to this constructor is copied. This provides the rule executors with the option to remember state from one rule execution to another that will possibly allow it to be more efficient. For example, the MamdaniMinMaxMinRuleExecutor calculates the DOF (degree of matching/fulfillment) of all of the input/antecedent pairs. If only the outputs change then the DOF is still valid and the overhead of generating the outputs is considerably reduced.
The DOF for all input/antecedent pairs can be calculated in many ways. This is determined by the rule's antecedentCombineOperator setting. Supported operations include the minimum of the matching value for all of the pairs and the product of the values.

Parameters:
exec - the rule executor to use with this rule

FuzzyRule

public FuzzyRule(nrc.fuzzy.FuzzyRuleExecutor exec,
                 nrc.fuzzy.AntecedentCombineOperator combineOperator)
Create a FuzzyRule with a specified FuzzyRuleExecutor and an antecedentCombineOperator. Note that each FuzzyRule that is constructed actually gets it own rule executor. To ensure this the FuzzyRuleExecutor supplied to this constructor is copied. This provides the rule executors with the option to remember state from one rule execution to another that will possibly allow it to be more efficient. For example, the MamdaniMinMaxMinRuleExecutor calculates the DOF (degree of matching/fulfillment) of all of the input/antecedent pairs. If only the outputs change then the DOF is still valid and the overhead of generating the outputs is considerably reduced.
The DOF for all input/antecedent pairs can be calculated in many ways. This is determined by the rule's antecedentCombineOperator setting. Supported operations include the minimum of the matching value for all of the pairs and the product of the values.

Parameters:
exec - the rule executor to use with this rule
combineOperator - the operator to use to combine the match values of the antecedent/input pairs of the rule

FuzzyRule

public FuzzyRule(nrc.fuzzy.AntecedentCombineOperator combineOperator)
Create a FuzzyRule with a specified antecedentCombineOperator. Note that each FuzzyRule that is constructed actually gets it own rule executor. To ensure this the FuzzyRuleExecutor supplied to this constructor is copied. This provides the rule executors with the option to remember state from one rule execution to another that will possibly allow it to be more efficient. For example, the MamdaniMinMaxMinRuleExecutor calculates the DOF (degree of matching/fulfillment) of all of the input/antecedent pairs. If only the outputs change then the DOF is still valid and the overhead of generating the outputs is considerably reduced.
The DOF for all input/antecedent pairs can be calculated in many ways. This is determined by the rule's antecedentCombineOperator setting. Supported operations include the minimum of the matching value for all of the pairs and the product of the values.

Parameters:
combineOperator - the operator to use to combine the match values of the antecedent/input pairs of the rule
Method Detail

addAntecedent

public void addAntecedent(nrc.fuzzy.FuzzyValue fval)
Add an antecedent FuzzyValue to the to the end of the set of antecedents for this rule.

Parameters:
fval - The FuzzyValue to add.

insertAntecedentAt

public void insertAntecedentAt(nrc.fuzzy.FuzzyValue fval,
                               int i)
Insert an antecedent FuzzyValue into the set of antecedents for this rule at the position indicated.

Parameters:
fval - The FuzzyValue to add.
i - The index (position) at which to add the FuzzyValue (zero based).

removeAntecedentAt

public void removeAntecedentAt(int i)
Remove an antecedent FuzzyValue from the set of antecedents for this rule at the position indicated.

Parameters:
i - The index (position) from which the FuzzyValue should be removed (zero based).

removeAllAntecedents

public void removeAllAntecedents()
Remove all antecedent FuzzyValues from the set of antecedents for this rule.


antecedentAt

public nrc.fuzzy.FuzzyValue antecedentAt(int i)
Get the antecedent FuzzyValue from the set of antecedents for this rule at the position indicated.

Parameters:
i - The index (position) at which to get the FuzzyValue (zero based).

antecedentsSize

public int antecedentsSize()
Return the size of the set of antecedents (the number of antecedents in the rule.


getAntecedents

public nrc.fuzzy.FuzzyValueVector getAntecedents()
Return the set of antecedents in a FuzyValueVector.


addConclusion

public void addConclusion(nrc.fuzzy.FuzzyValue fval)
Add a conclusion FuzzyValue to the to the end of the set of conclusions for this rule.

Parameters:
fval - The FuzzyValue to add.

insertConclusionAt

public void insertConclusionAt(nrc.fuzzy.FuzzyValue fval,
                               int i)
Insert a conclusion FuzzyValue into the set of conclusions for this rule at the position indicated.

Parameters:
fval - The FuzzyValue to add.
i - The index (position) at which to add the FuzzyValue (zero based).

removeConclusionAt

public void removeConclusionAt(int i)
Remove a conclusion FuzzyValue from the set of conclusions for this rule at the position indicated.

Parameters:
i - The index (position) from which the FuzzyValue should be removed (zero based).

removeAllConclusions

public void removeAllConclusions()
Remove all conclusion FuzzyValues from the set of conclusions for this rule.


conclusionAt

public nrc.fuzzy.FuzzyValue conclusionAt(int i)
Get the conclusion FuzzyValue from the set of conclusions for this rule at the position indicated.

Parameters:
i - The index (position) at which to get the FuzzyValue (zero based).

conclusionsSize

public int conclusionsSize()
Return the size of the set of conclusions (the number of conclusions in the rule.


getConclusions

public nrc.fuzzy.FuzzyValueVector getConclusions()
Return the set of conclusions in a FuzzyValueVector.


addInput

public void addInput(nrc.fuzzy.FuzzyValue fval)
Add an input FuzzyValue to the to the end of the set of inputs for this rule.

Parameters:
fval - The FuzzyValue to add.

insertInputAt

public void insertInputAt(nrc.fuzzy.FuzzyValue fval,
                          int i)
Insert an input FuzzyValue into the set of inputs for this rule at the position indicated.

Parameters:
fval - The FuzzyValue to add.
i - The index (position) at which to add the FuzzyValue (zero based).

removeInputAt

public void removeInputAt(int i)
Remove an input FuzzyValue from the set of inputs for this rule at the position indicated.

Parameters:
i - The index (position) from which the FuzzyValue should be removed (zero based).

removeAllInputs

public void removeAllInputs()
Remove all input FuzzyValues from the set of inputs for this rule.


inputAt

public nrc.fuzzy.FuzzyValue inputAt(int i)
Get the input FuzzyValue from the set of inputs for this rule at the position indicated.

Parameters:
i - The index (position) at which to get the FuzzyValue (zero based).

getInputs

public nrc.fuzzy.FuzzyValueVector getInputs()
Return the set of inputs in a FuzyValueVector.


inputSize

public int inputSize()
Return the size of the set of inputs (the number of inputs in the rule.


isAntecendentCombineOperatorChanged

public boolean isAntecendentCombineOperatorChanged()
Get of change status of the antecedent combine operator. The value will be true if the operator is changed between rule firings.


isAntecedentsChanged

public boolean isAntecedentsChanged()
Get of change status of the antecedents. The value will be true if any antecedent is added or removed between rule firings.


isConclusionsChanged

public boolean isConclusionsChanged()
Get of change status of the conclusions. The value will be true if any conclusion is added or removed between rule firings.


isInputsChanged

public boolean isInputsChanged()
Get of change status of the inputs. The value will be true if any input is added or removed between rule firings.


setRuleExecutor

public void setRuleExecutor(nrc.fuzzy.FuzzyRuleExecutor exec)
Set the rule's executor to the one provided. This allows one to change the method of rule inferencing dynamically -- simple to fire it several times in a row with different executors. Note that changing the rule executor will also set all 'changed' flags to true since the impact is severe enough that any state saved by an executor will not be valid.

Parameters:
exec - The FuzzyRuleExecutor that will now be used to execute the rule.

getRuleExecutor

public nrc.fuzzy.FuzzyRuleExecutor getRuleExecutor()
Get the rule's current rule executor.

Returns:
Returns the rule's FuzzyRuleExecutor.

setDefaultRuleExecutor

public static void setDefaultRuleExecutor(nrc.fuzzy.FuzzyRuleExecutor exec)
Set the rule's default executor to the one provided. This allows one to change the default method of rule inferencing dynamically.

Parameters:
exec - The FuzzyRuleExecutor that will now be used to as the default when a rule is created and an executor is not specified.

getDefaultRuleExecutor

public static nrc.fuzzy.FuzzyRuleExecutor getDefaultRuleExecutor()
Get the default executor for FuzzyRules. This is the FuzzyRuleExecutor assigned to the rule when it is create by a constructor with no arguments.

Returns:
Returns the default rule Executor for fuzzy rules.

setAntecedentCombineOperator

public void setAntecedentCombineOperator(nrc.fuzzy.AntecedentCombineOperator combineOperator)
Set the rule's antecedent combine operator to the one provided. This allows one to change the method of combining the match values of the antecedent/input pairs in a rule. Note that changing the operator will also set all 'changed' flags to true since the impact is severe enough that any state saved by an executor will not be valid.

Parameters:
combineOperator - The operator that will now be used to combine match values of the antecedent/input pairs in the rule.

getAntecedentCombineOperator

public nrc.fuzzy.AntecedentCombineOperator getAntecedentCombineOperator()
Get the rule's current antecedent combine operator.

Returns:
Returns the rule's antecedentCombineOperator.

setDefaultAntecedentCombineOperator

public static void setDefaultAntecedentCombineOperator(nrc.fuzzy.AntecedentCombineOperator combineOperator)
Set the rule's default antecedent combine operator to the one provided.

Parameters:
combineOperator - The operator that will now be used.

getDefaultAntecedentCombineOperator

public static nrc.fuzzy.AntecedentCombineOperator getDefaultAntecedentCombineOperator()
Get the default antecedent combine operator for FuzzyRules. This is the operator assigned to the rule when it is create by a constructor with no arguments or with only the rule executor specified.

Returns:
Returns the default rule antecedent combine operator.

testRuleMatching

public boolean testRuleMatching()
                         throws IncompatibleRuleInputsException
Test to see if the rule antecedents match the rule inputs with enough overlap to ensure rule will fire with meaninful outputs. The test is that all of the antecedent/input pairs overlap at least to degree as specified by the default tolerance or a specified tolerance.

Returns:
Returns true if the antecedent and input pairs of the rule match within the specified or default tolerance
Throws:
IncompatibleRuleInputsException

testRuleMatching

public boolean testRuleMatching(double threshold)
                         throws IncompatibleRuleInputsException
Test to see if the rule antecedents match the rule inputs with enough overlap to ensure rule will fire with meaninful outputs. The test is that all of the antecedent/input pairs overlap at least to degree as specified by the default tolerance or a specified tolerance.

Parameters:
threshold - The threshold for matching fuzzy values
Returns:
Returns true if the antecedent and input pairs of the rule match within the specified or default tolerance
Throws:
IncompatibleRuleInputsException

testRuleMatching

public boolean testRuleMatching(nrc.fuzzy.FuzzyValueVector inputs)
                         throws IncompatibleRuleInputsException
Test to see if the rule antecedents match the rule inputs with enough overlap to ensure rule will fire with meaninful outputs. The test is that all of the antecedent/input pairs overlap at least to degree as specified by the default tolerance or a specified tolerance. In this case the rule's inputs are ignored and the inputs provided in the paramter list are used.

Parameters:
inputs - The inputs to be used in the test for the rule
Returns:
Returns true if the antecedent and input pairs of the rule match within the specified or default tolerance
Throws:
IncompatibleRuleInputsException

testRuleMatching

public boolean testRuleMatching(double threshold,
                                nrc.fuzzy.FuzzyValueVector inputs)
                         throws IncompatibleRuleInputsException
Test to see if the rule antecedents match the rule inputs with enough overlap to ensure rule will fire with meaninful outputs. The test is that all of the antecedent/input pairs overlap at least to degree as specified by the default tolerance or a specified tolerance. In this case the rule's inputs are ignored and the inputs provided in the paramter list are used.

Parameters:
threshold - The threshold for matching fuzzy values.
inputs - The inputs to be used in the test for the rule.
Returns:
Returns true if the antecedent and input pairs of the rule match within the specified or default tolerance.
Throws:
IncompatibleRuleInputsException

doTestRuleMatching

public boolean doTestRuleMatching(double threshold,
                                  nrc.fuzzy.FuzzyValueVector antecedents,
                                  nrc.fuzzy.FuzzyValueVector inputs)
                           throws IncompatibleRuleInputsException
Does the work for the testRuleMatching methods.

Parameters:
threshold - The threshold for matching fuzzy values.
antecedents - The antecedents for the rule.
inputs - The inputs for the rule.
Returns:
True if the matching passed the threshold, else false.
Throws:
IncompatibleRuleInputsException

execute

public nrc.fuzzy.FuzzyValueVector execute()
                                   throws IncompatibleRuleInputsException
Execute (fire) the rule. In order to be successful the number of antecedents and inputs must be the same and the corresponding fuzzy variable types of the antecedent/input pairs must be the same. The method calls the execute method of the associated FuzzyRuleExecutor that is associated with the rule and returns a vector of the output FuzzyValues determined by the rule execution.

Returns:
A vector of the output FuzzyValues determined by the rule execution. If there are no outputs then a vector with size of zero will result.
Throws:
IncompatibleRuleInputsException

execute

public nrc.fuzzy.FuzzyValueVector execute(nrc.fuzzy.FuzzyRuleExecutor exec)
                                   throws IncompatibleRuleInputsException
Execute (fire) the rule. In order to be successful the number of antecedents and inputs must be the same and the corresponding fuzzy variable types of the antecedent/input pairs must be the same. The method calls the execute method of the sup[plied FuzzyRuleExecutor that is associated with the rule and returns a vector of the output FuzzyValues determined by the rule execution.

Parameters:
exec - The rule executor to use rather than the one associated with the rule.
Returns:
A vector of the output FuzzyValues determined by the rule execution. If there are no outputs then a vector with size of zero will result.
Throws:
IncompatibleRuleInputsException

execute

public nrc.fuzzy.FuzzyValueVector execute(nrc.fuzzy.FuzzyValueVector inputs)
                                   throws IncompatibleRuleInputsException
Execute (fire) the rule. In order to be successful the number of antecedents and inputs must be the same and the corresponding fuzzy variable types of the antecedent/input pairs must be the same. The method calls the execute method of the associated FuzzyRuleExecutor that is associated with the rule and returns a vector of the output FuzzyValues determined by the rule execution. In this case the rule is fired using a specified set of inputs rather than those associated with the rule.

Parameters:
inputs - The rule is executed with the specified inputs (rather than with the inputs currently associated with the rule)
Returns:
A vector of the output FuzzyValues determined by the rule execution. If there are no outputs then a vector with size of zero will result.
Throws:
IncompatibleRuleInputsException

execute

public nrc.fuzzy.FuzzyValueVector execute(nrc.fuzzy.FuzzyRuleExecutor exec,
                                          nrc.fuzzy.FuzzyValueVector inputs)
                                   throws IncompatibleRuleInputsException
Execute (fire) the rule. In order to be successful the number of antecedents and inputs must be the same and the corresponding fuzzy variable types of the antecedent/input pairs must be the same. The method calls the execute method of the sup[plied FuzzyRuleExecutor that is associated with the rule and returns a vector of the output FuzzyValues determined by the rule execution. In this case the rule is fired using a specified set of inputs rather than those associated with the rule.

Parameters:
exec - The rule executor to use rather than the one associated with the rule.
inputs - The rule is executed with the specified inputs (rather than with the inputs currently associated with the rule)
Returns:
A vector of the output FuzzyValues determined by the rule execution. If there are no outputs then a vector with size of zero will result.
Throws:
IncompatibleRuleInputsException