Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
| ABLE 2.3.0 07/13/2005 14:21:00
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.ibm.able.rules
Class AbleBackwardChainInferenceEngine

    java.lang.Object
      com.ibm.able.rules.AbleInferenceEngine
          com.ibm.able.rules.AbleBackwardChainInferenceEngine

All Implemented Interfaces:
  java.io.Serializable

public class AbleBackwardChainInferenceEngine
extends AbleInferenceEngine
implements java.io.Serializable

This class provides the inferencing algorithm for processing conditional rules in a ruleblock using goal-driven or backward chaining.

The AbleBackwardChainInferenceEngine processes AbleAssertionRules and AbleConditionalRules and ignores all others. The control property ARL.Goal must be set to point to a global variable referenced in the consequent of one or more conditional rules in the ruleblock.

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
`protected java.util.Stack` | `myGoalClauseStack` For goals (consequent clauses) and subgoals.
`protected AbleVariable` | `myGoalVariable`

Fields inherited from class com.ibm.able.rules.AbleInferenceEngine
`myDebugLevel, myRuleBlock, myRuleSet, myRulesFiredCount, myTracer, myWorkingMemory`

Constructor Summary
`AbleBackwardChainInferenceEngine(AbleRuleSet theRuleSet, AbleLogger theTracer, AbleRuleBlock theRuleBlock)` Create a new Backward chain inference engine.

Method Summary
`java.lang.Object` | `getControlParameter(java.lang.String theControlParameter)` Returns the specified control parameter on the associated inference engine.
`AbleVariable` | `getGoalVariable()`
`void` | `infer(AbleRuleBlock theRuleBlock)` Fire the rules in the ruleblock using boolean rules of backward chaining inferencing: given a goal variable, apply inverse moves and work toward the intial state.
`boolean` | `isRuleBlockValid(AbleRuleBlock theRuleBlock)` Make sure the current ruleblock is "executable" by examining the rule types and rule object configurations.
`protected void` | `reevaluateClausesWithChangedVariable(AbleClauseReferences theClauseReferences)` Re-evaluate, if necessary, the specified clauses that contain a reference to a variable whose current value has just changed.
`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, reset, 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`

Field Detail

### myGoalClauseStack

    protected java.util.Stack myGoalClauseStack

  For goals (consequent clauses) and subgoals.

### myGoalVariable

    protected AbleVariable myGoalVariable

Constructor Detail

### AbleBackwardChainInferenceEngine

    public AbleBackwardChainInferenceEngine(AbleRuleSet theRuleSet,
                                            AbleLogger theTracer,
                                            AbleRuleBlock theRuleBlock)

  Create a new Backward chain 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:

  - IfThenElse rules
  - Predicate rule
  - PatternMatch rules
  - Iteration rules
  - Multiple consequents in an If/Then Conditional 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`
  Parameters:
    `theRuleBlock` - The set of rules to validate
  Returns:
    true, if the ruleblock is OK; false, if the ruleblock is not executable.

### infer

    public void infer(AbleRuleBlock theRuleBlock)
               throws AbleDataException

  Fire the rules in the ruleblock using boolean rules of backward chaining inferencing: given a goal variable, apply inverse moves and work toward the intial state.

  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 process all assertion rules in the ruleblock.
  2. Evaluate all enabled conditional rules using backward chaining until the goal is reached or inferencing fails to find the goal.

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

  Throws:
    `AbleDataException` - When any error occurs.
  See Also:
    `AbleRuleBlock`

### reevaluateClausesWithChangedVariable

    protected void reevaluateClausesWithChangedVariable(AbleClauseReferences theClauseReferences)
                                                 throws AbleDataException

  Re-evaluate, if necessary, the specified clauses that contain a reference to a variable whose current value has just changed. This engine processes only antecedent clauses.

  Parameters:
    `theClauseReferences` - A collection of clauses that reference some variable whose current value has just changed.

  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`

### getGoalVariable

    public AbleVariable getGoalVariable()

Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
| ABLE 2.3.0 07/13/2005 14:21:00
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

(C) Copyright IBM Corporation 1999, 2005