|
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 | +--com.ibm.able.rules.AblePredicateEngine
This class provides the control code and inferencing algorithm for processing a set of Predicate rules in a ruleblock using backward chaining with backtracking (similar to Prolog).
The AblePredicateEngine processes AbleAssertionRules and AblePredicateRules and ignores all others. The control property ARL.Goal must be set to point to a predicate referenced in the head of one or more predicate facts or 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.
AbleRuleSet
,
AbleRuleBlock
,
AbleAssertionRule
,
AblePredicateRule
, Serialized FormField Summary | |
---|---|
protected java.util.Hashtable |
cutTable
|
protected boolean |
findAllSolutions
True if we are to find all possible solutions False if we are to find first solution only |
protected java.util.Vector |
globalClauseLists
|
protected AblePredicateQuery |
myGoal
The PredicateGoal() specified in the ruleset |
protected java.util.Vector |
myGoalList
Predicates from the predicate query |
protected java.util.Vector |
solutionList
Set of all solutions found for the query |
Fields inherited from class com.ibm.able.rules.AbleInferenceEngine |
---|
myDebugLevel, myRuleBlock, myRuleSet, myRulesFiredCount, myTracer, myWorkingMemory |
Constructor Summary | |
---|---|
AblePredicateEngine(AbleRuleSet theRuleSet,
AbleLogger theTracer,
AbleRuleBlock theRuleBlock)
Create a new inference engine. |
Method Summary | |
---|---|
protected void |
applyGoalBindings(java.util.Vector bindings)
Apply the value of match variables to any unbound goal variables Remove the binding from the list once it is applied |
protected boolean |
assert_1(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
asserta_1(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
assertz_1(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
atom_chars_2(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
atom_concat_3(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
atom_length_2(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
atom_number_2(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
backwardChain(java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
Given a goal variable, apply inverse moves and work toward the intial state: |
protected boolean |
call_1(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
consult_1(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
static java.lang.String |
Copyright()
Determine the copyright of this class. |
protected boolean |
functor_3(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
java.lang.Object |
getControlParameter(java.lang.String theControlParameter)
Returns the specified control parameter on the associated inference engine. |
AblePredicateQuery |
getPredicateQuery()
|
java.util.Vector |
getSolutionList()
|
void |
infer(AbleRuleBlock theRuleBlock)
Fire the rules in the ruleblock using Predicate rules of backward chaining inferencing: given a goal variable, apply inverse moves and work toward the intial state. |
void |
init()
Initialize the predicate inference engine by adding all predicate facts and rules to the working memory. |
protected boolean |
isList_1(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
boolean |
isRuleBlockValid(AbleRuleBlock theRuleBlock)
Make sure the current ruleblock is "executable" by this inference engine. |
protected boolean |
match(java.lang.Object term1,
java.lang.Object term2,
java.util.Vector bindings,
java.util.Vector goalBindings)
This is the major method in this inference engine It unifies two predicates, binds local variables as required and returns a list of goalBindings (when both vars are unbound) Note: this method causes side-effects, local variables are bound, so they must be unbound to restore predicates to initial condition in case of failure Returns true if term1 matches (unifies) with term2, false otherwise |
protected boolean |
matchLists(AblePredicate list1,
AblePredicate list2,
java.util.Vector bindings,
java.util.Vector goalBindings)
See if list1 matches (unifies) with list2 Uses standard list notation .(X .(Y, [])) etc. |
protected boolean |
member_2(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
nonvar_1(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
retract_1(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
retractall_1(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
void |
setControlParameter(java.lang.String theControlParameter,
java.lang.Object theValue)
Set the specified control parameter on the associated inference engine. |
protected boolean |
sub_atom_5(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
unify_2(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
univ_2(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
protected boolean |
var_1(AblePredicate theGoal,
java.util.Vector goalList,
java.util.Vector goalBindings,
int level)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected AblePredicateQuery myGoal
protected java.util.Vector solutionList
protected boolean findAllSolutions
protected java.util.Vector myGoalList
protected java.util.Vector globalClauseLists
protected java.util.Hashtable cutTable
Constructor Detail |
public AblePredicateEngine(AbleRuleSet theRuleSet, AbleLogger theTracer, AbleRuleBlock theRuleBlock)
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 |
public boolean isRuleBlockValid(AbleRuleBlock theRuleBlock)
The ruleblock is invalid if any of the following are present in the ruleblock:
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.
isRuleBlockValid
in class AbleInferenceEngine
public void init() throws AbleException
init
in class AbleInferenceEngine
public void infer(AbleRuleBlock theRuleBlock) throws AbleDataException
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:
infer
in class AbleInferenceEngine
theRuleBlock
- The ruleblock containing the rules to be processed.
AbleDataException
- When any error occurs.protected boolean matchLists(AblePredicate list1, AblePredicate list2, java.util.Vector bindings, java.util.Vector goalBindings) throws AbleDataException
protected boolean match(java.lang.Object term1, java.lang.Object term2, java.util.Vector bindings, java.util.Vector goalBindings) throws AbleDataException
protected boolean backwardChain(java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
theGoal
- Must be an AblePredicateQuery object, containing one or more
AblePredicates.
protected void applyGoalBindings(java.util.Vector bindings) throws AbleDataException
public final java.util.Vector getSolutionList()
public void setControlParameter(java.lang.String theControlParameter, java.lang.Object theValue) throws AbleDataException
setControlParameter
in class AbleInferenceEngine
public java.lang.Object getControlParameter(java.lang.String theControlParameter) throws AbleDataException
getControlParameter
in class AbleInferenceEngine
public AblePredicateQuery getPredicateQuery()
protected boolean isList_1(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean call_1(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean atom_chars_2(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean atom_concat_3(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean sub_atom_5(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean atom_number_2(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean atom_length_2(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean functor_3(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean unify_2(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean consult_1(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean assert_1(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean asserta_1(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean assertz_1(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean retract_1(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean retractall_1(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean member_2(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean var_1(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean nonvar_1(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
protected boolean univ_2(AblePredicate theGoal, java.util.Vector goalList, java.util.Vector goalBindings, int level) throws AbleDataException
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 |