ABLE 2.3.0 07/13/2005 14:21:00

com.ibm.able.rules
Class AbleDecisionTreeEngine

java.lang.Object
  extended bycom.ibm.able.rules.AbleInferenceEngine
      extended bycom.ibm.able.rules.AbleDecisionTreeEngine
All Implemented Interfaces:
java.io.Serializable

public class AbleDecisionTreeEngine
extends AbleInferenceEngine
implements java.io.Serializable

This class provides the algorithm for processing a decision tree or table represented by a single tree rule or by a set of if-then rules.

The AbleDecisionTreeEngine processes AbleAssertionRules and either a single AbleTreeRule, a single AbleIfThenElseRule or a set of AbleConditionalRules and ignores all others.

The major processing method is infer() which is called by the AbleRuleSet bean as part of the normal bean process() method.

Instances of this class are not directly constructed by the user but are dynamically created by the AbleRuleBlock init() method.

See Also:
AbleRuleSet, AbleRuleBlock, AbleAssertionRule, AbleConditionalRule, Serialized Form

Field Summary
 
Fields inherited from class com.ibm.able.rules.AbleInferenceEngine
myDebugLevel, myRuleBlock, myRuleSet, myRulesFiredCount, myTracer, myWorkingMemory
 
Constructor Summary
AbleDecisionTreeEngine(AbleRuleSet theRuleSet, AbleLogger theTracer)
          Create a new inference engine.
AbleDecisionTreeEngine(AbleRuleSet theRuleSet, AbleLogger theTracer, AbleRuleBlock theRuleBlock)
          Create a new inference engine.
 
Method Summary
 boolean evalTree(AbleTreeNode theRootNode)
          Evaluate the decision tree structure directly via depth-first search of the tree When a leaf node is reached, perform all of the actions in the action node.
 java.lang.Object getControlParameter(java.lang.String theControlParameter)
          Returns the specified control parameter on the associated inference engine.
 void infer(AbleRuleBlock theRuleBlock)
          Fires the rules in the ruleset as if they were a decision tree.
 boolean isRuleBlockValid(AbleRuleBlock theRuleBlock)
          Make sure the current ruleblock is "executable" by examining the rule types and rule object configurations.
 void reset()
          Reset the rule block so that rules can be fired again: all rules are set to their original state.
 void setControlParameter(java.lang.String theControlParameter, java.lang.Object theValue)
          Set the specified control parameter on the associated inference engine.
 
Methods inherited from class com.ibm.able.rules.AbleInferenceEngine
allocateWorkingMemory, askUser, conditionalRulesValid, evalAntecedentClause, evalAntecedentExpression, evalAssertionClause, evalAssertionRule, evalConditionalRule, evalConsequentClause, evalDoUntilRule, evalDoWhileRule, evalForLoopRule, evalIfThenElseRule, evalPatternMatchRule, evalSwitchRule, evaluateDoActions, evalWhileDoRule, fireEngineBreakpoint, firePropertyChange, getRuleSet, getRulesFiredCount, getWorkingMemory, init, processAssertions, processConsequent, processConsequent, processConsequentClauses, processRuleBlock, resetRuleSet, setControlParameters, setDebugLevel, setInferenceContext, setInferenceContext, setInferenceContext, setRuleSet, setWorkingMemory, startDebugConsole, stopDebugConsole, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbleDecisionTreeEngine

public AbleDecisionTreeEngine(AbleRuleSet theRuleSet,
                              AbleLogger theTracer)
Create a new inference engine.

Parameters:
theRuleSet - A ruleset whose rules are to be used for inferencing by this inference engine.

theTracer - A tracer object to which this inference engine can log information. This may be null, in which case no information is logged.


AbleDecisionTreeEngine

public AbleDecisionTreeEngine(AbleRuleSet theRuleSet,
                              AbleLogger theTracer,
                              AbleRuleBlock theRuleBlock)
Create a new inference engine.

Parameters:
theRuleSet - A ruleset whose context is used for inferencing by this inference engine.

theTracer - A tracer object to which this inference engine can log information. This may be null, in which case no information is logged.

theRuleBlock - A ruleblock whose rules are to be used for inferencing by this inference engine.

Method Detail

isRuleBlockValid

public boolean isRuleBlockValid(AbleRuleBlock theRuleBlock)
Make sure the current ruleblock is "executable" by examining the rule types and rule object configurations.

The ruleblock is invalid if any of the following are present in the ruleblock:

  • Predicate rule
  • Iteration rule
  • Pattern match rule

    All reasons for validation failures are appended to the AbleRuleSet's myIsExReason variable. If validation fails, the inference engine must call myRuleSet.addIsExReason(java.lang.String) to append the reason.

    Specified by:
    isRuleBlockValid in class AbleInferenceEngine
    Returns:
    true, if the ruleset is OK; false, if the ruleset is not executable.

  • infer

    public void infer(AbleRuleBlock theRuleBlock)
               throws AbleDataException
    Fires the rules in the ruleset as if they were a decision tree.

    The infer() method is called by the AbleRuleSet process() method as part of the overall ruleset bean processing sequence.

    The order of processing is as follows:

    1. Sequentially evaluate all assertion rules in declaration order.
    2. Evaluate all enabled conditional rules in sequential order, and fire the first triggered rule.

    Specified by:
    infer in class AbleInferenceEngine
    Parameters:
    theRuleBlock - The ruleblock to be processed.

    Throws:
    AbleDataException - When any error occurs.

    evalTree

    public boolean evalTree(AbleTreeNode theRootNode)
                     throws AbleDataException
    Evaluate the decision tree structure directly via depth-first search of the tree When a leaf node is reached, perform all of the actions in the action node.

    Throws:
    AbleDataException

    setControlParameter

    public void setControlParameter(java.lang.String theControlParameter,
                                    java.lang.Object theValue)
                             throws AbleDataException
    Set the specified control parameter on the associated inference engine.

    Specified by:
    setControlParameter in class AbleInferenceEngine
    Throws:
    AbleDataException

    getControlParameter

    public java.lang.Object getControlParameter(java.lang.String theControlParameter)
                                         throws AbleDataException
    Returns the specified control parameter on the associated inference engine.

    Specified by:
    getControlParameter in class AbleInferenceEngine
    Throws:
    AbleDataException

    reset

    public void reset()
    Reset the rule block so that rules can be fired again: all rules are set to their original state. Note that the "processed" flag is not reset.

    This is a no-op in this engine.

    Overrides:
    reset in class AbleInferenceEngine

    ABLE 2.3.0 07/13/2005 14:21:00

    (C) Copyright IBM Corporation 1999, 2005