infosapient.system
Class FzyTorquemada

java.lang.Object
  |
  +--infosapient.system.ObservableImpl
        |
        +--infosapient.system.FzySystemComponent
              |
              +--infosapient.system.FzyTorquemada

public class FzyTorquemada
extends FzySystemComponent
implements java.lang.Runnable

Class FzyTorquemada is responsible for controlling the execution of the rules within the knowledgebase.

Explaination system is built into FzyTorquemada to help explain:

Note: The explaination facility is not implemented. Scheduled for version BOSON.

Version:
$Revision: 1.1.1.1 $
See Also:
Serialized Form

Field Summary
private  FzyCorrelation corrMth
           
private  FzyResolutionMethod defuzzMth
           
private  FzyAttribute endGoal
          The goal to be solved during the consultation session.
private  FzyImplicationMethod implicMth
           
private  FzyAttribute outputAttribute
           
private  FzySolutionSet outputSpace
           
private  double[] result
           
private  FSEvent runTimeEvent
           
(package private) static long serialVersionUID
           
private  boolean suppressNotification
          Used to suppress explainatory messages, warnings, etc, when being used in Server mode.
private  java.util.Date theDate
           
private  FzyKnowledgebase theKB
           
 
Fields inherited from class infosapient.system.FzySystemComponent
DEBUG_, myID, name, pcs, serialVersionUID, trace, vcs
 
Fields inherited from class infosapient.system.ObservableImpl
arr, changed, obs, serialVersionUID
 
Constructor Summary
FzyTorquemada()
          Default constructor for this executive
FzyTorquemada(FzyKnowledgebase kb)
          Constructor used to execute within visual environment
FzyTorquemada(FzyKnowledgebase kb, boolean rt)
          Constructor used to notify Executive that no information messages will be output during rule processing.
 
Method Summary
private  FzyAttribute buildOutputSpace()
           
private  FzyClauseComponent evaluateComponent(FzyClauseComponent fcc)
          Attempt to evaluate the FzyClauseComponent.
private  void evaluateRule(FzyRule aRule)
          Evaluate the premise to see if we can determine the consequent.
 void run()
           Determine the value of the knowledgebase current goal.
private  FzyAttribClause solveGoal(FzyAttribClause currentGoal)
          Attempt to find the solution of the currentGoal by finding out which rules solve for this goal and then executing those rules.
 
Methods inherited from class infosapient.system.FzySystemComponent
addPropertyChangeListener, addVetoableChangeListener, equals, getID, getName, getPropertyChangeSupport, getVetoableChangeSupport, hashCode, printOn, removePropertyChangeListener, removeVetoableChangeListener, setID, setName
 
Methods inherited from class infosapient.system.ObservableImpl
addObserver, clearChanged, containsObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

result

private double[] result

serialVersionUID

static final long serialVersionUID

theKB

private FzyKnowledgebase theKB

outputSpace

private FzySolutionSet outputSpace

outputAttribute

private FzyAttribute outputAttribute

theDate

private transient java.util.Date theDate

corrMth

private FzyCorrelation corrMth

defuzzMth

private FzyResolutionMethod defuzzMth

implicMth

private FzyImplicationMethod implicMth

endGoal

private FzyAttribute endGoal
The goal to be solved during the consultation session.

runTimeEvent

private FSEvent runTimeEvent

suppressNotification

private boolean suppressNotification
Used to suppress explainatory messages, warnings, etc, when being used in Server mode.
Constructor Detail

FzyTorquemada

public FzyTorquemada()
Default constructor for this executive

FzyTorquemada

public FzyTorquemada(FzyKnowledgebase kb)
              throws java.lang.IllegalArgumentException
Constructor used to execute within visual environment

FzyTorquemada

public FzyTorquemada(FzyKnowledgebase kb,
                     boolean rt)
Constructor used to notify Executive that no information messages will be output during rule processing. Typically used for runtime only.
Method Detail

buildOutputSpace

private FzyAttribute buildOutputSpace()

evaluateComponent

private FzyClauseComponent evaluateComponent(FzyClauseComponent fcc)
                                      throws java.lang.CloneNotSupportedException,
                                             FzySystemException
Attempt to evaluate the FzyClauseComponent. A rule may have one or more separate premise clauses. If it does it is represented by the tree:

FzyOperator
/ \
(FzyAttribClause | FzyOperator) (FzyAttribClause)
/ \
(etc.) (FzyAttribClause)
 

If the FzyClauseComponent has a solution, return the FzyClauseComponent.

If the FzyClauseComponent instanceof FzyOperator, evaluate the tree, using evaluateComponent(FzyClauseComponent).

If the FzyClauseComponent isNOT an instance of FzyOperator, the FzyClauseComponent will be an instance of FzyAttribClause. Evaluate FzyAttribClause by invoking solveGoal(FzyAttribClause).

Parameters:
FzyClauseComponent - -- the clause component to be evaluated.
Returns:
FzyClauseComponent -- the clause component WITH a solution.
Throws:
java.lang.CloneNotSupportedException - -- if object fails to support Cloneable interface. (Should NEVER occur.)
FzySystemException - -- if FzyAttribClause.getGoal() fails
See Also:
FzyClauseComponent, FzyAttribClause, FzyAttribClause.getGoal(), FzyOperator

evaluateRule

private void evaluateRule(FzyRule aRule)
                   throws java.lang.IllegalArgumentException
Evaluate the premise to see if we can determine the consequent. This is done by invoking solveGoal to put the current unknown premise attribute on the solveGoal agenda.

Invoke evaluateComponent to get the DOM(degree of membership) of the premise goal. We check for DOM > 0.0 because we don't need to do any work if the premise DOM is 0.0.

We check for dm < 1.0 because if dm == 1.0 there will be no correlation/implication/resolution needed. We check altConseqGoal() != null.

If above checks succeed: Apply the inverse of the degree of membership (1.0 - dm) of the primary consequent goal to the alternateConsequentGoal. This is done because the alternate goal has membership only to the extent that the primary goal does NOT have membership.

Parameters:
FzyRule - the rule to be evaluated.
Throws:
java.lang.IllegalArgumentException - -- FzyRule == null

run

public void run()
Determine the value of the knowledgebase current goal. Do this by invoking (private) method solveGoal on the FzyAttribClause of the goal attribute. Procedure solveGoal begins a recursive chain to determine what attributes affect the current goal; the rules whose consequents determine those attributes; solve for those attributes successively until the current attribute is determined.
Procedure solveGoal (FzyAttribClause goal)
FzyAttribClause goal: the FzyAttribClause containing the attribute we need to solve.

if FzyAttribClause{goal} has a solution

Return  FzyAttribClause{goal}.
end if
Get the list of all rules within the knowledgebase who's consequent solves the current goal attribute.

if the rule list is not empty
 

for each rule whose consequent determines the goal attribute

do

invoke evaluateRule(aFuzzyRule) with the rule
end do
else (the rule list is empty)
Ask the user for the value of the goal attribute. Set the current domain value of the goal attribute to the value supplied by the user.
end if

Return the FzyAttribClause.

end procedure

procedure evaluateRule(FzyRule aRule)

aRule: the rule to be attempted by evaluateRule

for each component (FzyClauseComponent) in the premise of aRule do

invoke evaluateComponent with FzyClauseComponent fcc

if the degree of membership of the solution of  FzyClauseComponent{fcc} is >0.0

then

  1. correlate the degree of membership of the solution of fcc with the goal of the consequent
  2. use the selected implication method to add the correlated set of the consequents goal
  3. apply the selected resolution method to obtain the degree of membership for the consequents goal.
end if

if the degree of membership of the solution of FzyClauseComponent{fcc} is  < 1.0

then

  1.  correlate (1.0 - DOM of fcc) with the alternate consequent goal
  2. use the selected implication method to add the correlated set to the alternate consequents goal
  3. apply the selected resolution method to obtain the degree of membership for the alternate consequents goal.
    end if

end for
 

end procedure

procedure evaluateComponent(FzyClauseComponent fcc)

FzyClauseComponent fcc: The clause component to be evaluated. A FzyClauseComponent can be an instance of FzySet, FzyAttribute, FzyAttribClause, or FzyOperator.

    if FzyClauseComponent{fcc} has a solution
    then
        return FzyClauseComponent{fcc}
    end if
 
    if FzyClauseComponent{fcc} is instanceof FzyOperator
    then
        if (FzyOperator) fcc left child DOES NOT have a solution
        then
            invoke evaluateComponent((FzyOperator) fcc.leftchild);
        end if
        if (FzyOperator) fcc right child DOES NOT have a solution
        then
            invoke evaluateComponent((FzyOperator) fcc.rightchild);
        end if

        invoke (FzyOperator) fcc.apply(fcc.leftChild, fcc.rightChild);
 
    else

        invoke solveGoal(FzyClauseComponent{fcc})
 
    end if
 
    return FzyClauseComponent{fcc};
end procedure

 

Specified by:
run in interface java.lang.Runnable

solveGoal

private FzyAttribClause solveGoal(FzyAttribClause currentGoal)
                           throws java.lang.IllegalArgumentException
Attempt to find the solution of the currentGoal by finding out which rules solve for this goal and then executing those rules.
Parameters:
infosapient.system.FzyAttribClause - the goal to be solved for.
Throws:
java.lang.IllegalArgumentException - - if the currentGoal is null.

License to use this program is provided under the TERMS OF THE COMMON PUBLIC LICENSE 0.5. ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.

Copyright (c) 2001, Workplace Performance Tools, All Rights Reserved