|
ABLE 2.0.0 07/02/2003 10:25:01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.able.rules.AbleInferenceEngine
This class is an abstract base class for all inference engines used by an AbleRuleSet. An inference engine provides the control code and inferencing algorithms for processing a ruleblock (consisting of one or more rules and an optional working memory) in an Able ruleset.
One function performed by an inference engine is to validate the rules in the associated ruleblock to insure they are are of the appropriate type and contain the correct elements to be processed by the inference engine.
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.
AbleRuleSet
,
AbleRuleBlock
,
AbleRule
, Serialized FormField Summary | |
---|---|
protected int |
myDebugLevel
The debug level for this inference engine (passed through from RuleSet) |
protected AbleRuleBlock |
myRuleBlock
myRuleBlock is the ruleblock whose rules are used for inferencing |
protected AbleRuleSet |
myRuleSet
myRuleSet is the ruleset providing the context for this inference engine |
protected int |
myRulesFiredCount
The number of rules fired during the last infer() call Note: this value is reset on each infer() call |
protected AbleLogger |
myTracer
myTracer may be null, but if present, allows the inference engine to trace its evaluation steps. |
protected AbleWorkingMemory |
myWorkingMemory
|
Constructor Summary | |
---|---|
AbleInferenceEngine()
Create a new base inference engine. |
|
AbleInferenceEngine(AbleLogger theTracer)
Create a new base inference engine. |
|
AbleInferenceEngine(AbleRuleSet theRuleSet,
AbleLogger theTracer)
Create a new base inference engine over the specified ruleset. |
|
AbleInferenceEngine(AbleRuleSet theRuleSet,
AbleLogger theTracer,
AbleRuleBlock theRuleBlock)
Create a new base inference engine over the specified ruleset. |
Method Summary | |
---|---|
void |
askUser(AbleVariable theVariable)
If the askUser() UDF has been defined, prompt a user to provide a value for specific variable during backward inferencing. |
protected static boolean |
conditionalRulesValid(AbleRuleSet ruleSet,
AbleRuleBlock theRuleBlock)
Make sure the conditional rules in a ruleblock are "executable". |
static java.lang.String |
Copyright()
Determine the copyright of this class. |
static java.lang.Boolean |
evalAntecedentClause(AbleAntecedentClause theClause)
Evaluate the specified antecedent clause and update the clause with a new truth value. |
static java.lang.Boolean |
evalAntecedentExpression(AbleExpression theExpression)
Evaluate the specified antecedent expression |
protected void |
evalAssertionClause(AbleAssertionClause theClause)
|
protected void |
evalAssertionRule(AbleAssertionRule theRule)
|
protected void |
evalConditionalRule(AbleConditionalRule theRule)
Evaluate a conditional (if-then) rule. |
protected void |
evalConsequentClause(AbleConsequentClause theClause)
Evaluate the specified consequent clause. |
protected void |
evalDoUntilRule(AbleDoUntilRule theRule)
Evaluate a do-until rule. |
protected void |
evalDoWhileRule(AbleDoWhileRule theRule)
Evaluate a do-while rule. |
protected void |
evalForLoopRule(AbleForLoopRule theRule)
Evaluate a for-loop rule. |
protected void |
evalIfThenElseRule(AbleIfThenElseRule theRule)
Evaluate an if (expr) then-else rule. |
protected void |
evalPatternMatchRule(AblePatternMatchRule theRule)
Evaluate a pattern-match (when-do) rule. |
protected void |
evaluateDoActions(AbleRule theRule)
|
protected void |
evalWhileDoRule(AbleWhileDoRule theRule)
Evaluate a while-do rule. |
protected void |
fireEngineBreakpoint()
Call out to the DebugLib to handle an Inference Engine breakpoint |
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Fire a property change through the ruleset object |
abstract java.lang.Object |
getControlParameter(java.lang.String theControlParameter)
Returns the specified control parameter on the associated inference engine. |
AbleRuleSet |
getRuleSet()
Retrieve a reference to the current ruleset. |
int |
getRulesFiredCount()
Returns the number of rules fired during the last infer() call |
AbleWorkingMemory |
getWorkingMemory()
Retrieve the workingMemory object (may be null). |
abstract void |
infer(AbleRuleBlock theRuleBlock)
Inference over the set of rules in the specified ruleblock object. |
void |
init()
Initialize the inference engine |
abstract boolean |
isRuleBlockValid(AbleRuleBlock theRuleBlock)
Make sure the current ruleblock is "executable" when examined from a static viewpoint. |
protected void |
processAssertions(AbleRuleBlock theRuleBlock)
Fire all enabled assertion rules. |
protected void |
processConsequent(AbleConditionalRule theRule)
Evaluate the specified rule's consequent clauses and update the rule with a new truth value. |
void |
processRuleBlock(AbleRuleBlock theRuleBlock)
Fire all rules in the specified rule block in sequential order. |
void |
resetRuleSet()
Reset the current ruleset for another round of inferencing. |
abstract void |
setControlParameter(java.lang.String theControlParameter,
java.lang.Object theValue)
Set the specified control parameter on the associated inference engine. |
void |
setControlParameters(java.util.Hashtable theControlParameters)
Set the (possibly empty) set of control parameters passed to the associated inference engine. |
void |
setDebugLevel(int theDebugLevel)
|
void |
setRuleSet(AbleRuleSet theRuleSet)
Set the ruleset over which inferencing will take place. |
void |
setWorkingMemory(AbleWorkingMemory theWorkingMemory)
Set the workingMemory object to the specified value. |
protected void |
startDebugConsole()
Call out to the DebugLib to start the Debug console |
protected void |
stopDebugConsole()
Call out to the DebugLib to stop the Debug console and end debugging. |
java.lang.String |
toString()
Returns a string containing the describing the engine. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected AbleRuleSet myRuleSet
protected AbleLogger myTracer
protected AbleRuleBlock myRuleBlock
protected int myDebugLevel
protected AbleWorkingMemory myWorkingMemory
protected int myRulesFiredCount
Constructor Detail |
public AbleInferenceEngine(AbleRuleSet theRuleSet, AbleLogger theTracer, AbleRuleBlock theRuleBlock)
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.
public AbleInferenceEngine(AbleRuleSet theRuleSet, AbleLogger theTracer)
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.
public AbleInferenceEngine(AbleLogger theTracer)
theTracer
- A tracer object to which this inference engine can log
information. This may be null, in which case no
information is logged.
public AbleInferenceEngine()
Method Detail |
public final void setRuleSet(AbleRuleSet theRuleSet)
theRuleSet
- A ruleset that replaces the current ruleset, if there is
one.
public final AbleRuleSet getRuleSet()
public void resetRuleSet() throws AbleException
public void setControlParameters(java.util.Hashtable theControlParameters) throws AbleDataException
setControlParameter(java.lang.String, java.lang.Object)
public abstract void setControlParameter(java.lang.String theControlParameter, java.lang.Object theValue) throws AbleDataException
public abstract java.lang.Object getControlParameter(java.lang.String theControlParameter) throws AbleDataException
public abstract boolean isRuleBlockValid(AbleRuleBlock theRuleBlock) throws AbleDataException
protected static boolean conditionalRulesValid(AbleRuleSet ruleSet, AbleRuleBlock theRuleBlock)
public void init() throws AbleException
public abstract void infer(AbleRuleBlock theRuleBlock) throws AbleDataException
theRuleBlock
- The ruleblock to be processed by the engine.
public void processRuleBlock(AbleRuleBlock theRuleBlock) throws AbleDataException
This method is called from a ruleset's invokeRuleBlock()
method, and that method is called when a rule that uses the
built-in invokeRuleBlock("name") call literal is evaluated.
theRuleBlock
- The rule block from which rules are to be processed.
AbleDataException
- when the data types are incompatible, or when the
relational operator is invalid for the current
situation or unrecognized.
protected void processAssertions(AbleRuleBlock theRuleBlock) throws AbleDataException
For assertions, the evaluation must result in an assignment from the right-hand side to the left-hand side. Any other operation (such as a comparison) is meaningless and results in an exception.
theRuleBlock
- The rule block from which rules are to be processed.
AbleDataException
- when the data types are incompatible, or when the
relational operator is invalid for the current
situation or unrecognized.protected void evalAssertionRule(AbleAssertionRule theRule) throws AbleDataException
protected void evalConditionalRule(AbleConditionalRule theRule) throws AbleDataException
Procesing is as follows:
AbleDataException
- when the data types are incompatible, or when the
relational operator is invalid for the current
situation or unrecognized.protected void evalIfThenElseRule(AbleIfThenElseRule theRule) throws AbleDataException
Procesing is as follows:
AbleDataException
- when the data types are incompatible, or when the
relational operator is invalid for the current
situation or unrecognized.protected void evalPatternMatchRule(AblePatternMatchRule theRule) throws AbleDataException
Procesing is as follows:
AbleDataException
- when the data types are incompatible, or when the
relational operator is invalid for the current
situation or unrecognized.protected void evalWhileDoRule(AbleWhileDoRule theRule) throws AbleDataException
Procesing is as follows:
AbleDataException
- when the data types are incompatible, or when the
relational operator is invalid for the current
situation or unrecognized.protected void evalDoWhileRule(AbleDoWhileRule theRule) throws AbleDataException
Procesing is as follows:
AbleDataException
- when the data types are incompatible, or when the
relational operator is invalid for the current
situation or unrecognized.protected void evalDoUntilRule(AbleDoUntilRule theRule) throws AbleDataException
Procesing is as follows:
AbleDataException
- when the data types are incompatible, or when the
relational operator is invalid for the current
situation or unrecognized.protected void evalForLoopRule(AbleForLoopRule theRule) throws AbleDataException
Procesing is as follows:
AbleDataException
- when the data types are incompatible, or when the
relational operator is invalid for the current
situation or unrecognized.protected void evaluateDoActions(AbleRule theRule) throws AbleDataException
protected void evalAssertionClause(AbleAssertionClause theClause) throws AbleDataException
public static java.lang.Boolean evalAntecedentClause(AbleAntecedentClause theClause) throws AbleDataException
theClause
- an antecedent clause to evaluate.
AbleDataException
- when the clause's data objects are incompatible, or
when the relational operator is invalid for the
current situation or unrecognized.public static java.lang.Boolean evalAntecedentExpression(AbleExpression theExpression) throws AbleDataException
theExpression
- an antecedent expression to evaluate.
AbleDataException
- when the expression's data objects are incompatible, or
when the relational operator is invalid for the
current situation or unrecognized.protected void processConsequent(AbleConditionalRule theRule) throws AbleDataException
theRule
- a rule whose consequent clauses are to be evaluated.
AbleDataException
- when the clause's data objects are incompatible, or
when the relational operator is invalid for the
current situation or unrecognized.protected void evalConsequentClause(AbleConsequentClause theClause) throws AbleDataException
theClause
- a consequent clause to evaluate.
AbleDataException
- when the clause's data objects are incompatible, or
when the relational operator is invalid for the
current situation or unrecognized.public final void setDebugLevel(int theDebugLevel)
protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
propertyName
- A String name of the property that changedoldValue
- The Object representing the old valuenewValue
- The Object representing the new valueprotected void fireEngineBreakpoint() throws AbleDataException
protected void startDebugConsole()
protected void stopDebugConsole()
This method is called at the end of each infer() cycle to cleanup the debugger. There may not be one, so any error is perfectly normal: don't log anything!
public void askUser(AbleVariable theVariable)
If askUser() as not been defined, then set the variable value to null.
theVariable
- a variable whose value cannot be determined any other way.
public int getRulesFiredCount()
public void setWorkingMemory(AbleWorkingMemory theWorkingMemory)
theWorkingMemory
- The working memory.
public final AbleWorkingMemory getWorkingMemory()
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String Copyright()
|
ABLE 2.0.0 07/02/2003 10:25:01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |