jeops.engine
Class RuleBase

java.lang.Object
  |
  +--jeops.engine.RuleBase

public class RuleBase
extends java.lang.Object

Class that models the heart of the inference engine. It will decide when the rules are fired, filling their symbolic tables with the objects needed for the decision making.

Version:
0.05 23 May 1999 The first version with comments in English. There was also a major change in this class: now the fireable rules are stored in a conflict set, which will define the policy for the ordering of the rules being fired.
Author:
Carlos Figueira Filho (csff@di.ufpe.br)
See Also:
Rule

Constructor Summary
RuleBase(ObjectBase base)
          Creates a new rule base, given its object base.
RuleBase(ObjectBase base, RuleSorter ruleSorter)
          Creates a new rule base, given its object base and a rule sorter to define the conflict resolution policy.
 
Method Summary
 void addRule(Rule r)
          Adds a new rule to this rule base.
 void assertObject(java.lang.Object obj)
          Tells this base that a new object was inserted into its object base, so that the rules can be checked against this object.
 void dump()
          Prints a tree representation of this base.
 void dump(int spaces)
          Prints a tree representation of this base.
 boolean fireSingleRule(KnowledgeBase knowledgeBase)
          Fires a single rule in the rule base, if there is such one in the conflict set.
 void modifyObject(java.lang.Object obj)
          Tells this base that an object was modified in its object base, so that the rules with instantiations for that object are retested, and new cases can be added to the conflict set.
 void reset()
          Removes all rules from this rule base.
 void retractObject(java.lang.Object obj)
          Tells this base that an object was removed from its object base, so that the rules with instantiations for that object are removed from the object base
 void setRuleSorter(RuleSorter ruleSorter)
          Defines a conflict set policy for this rule base.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuleBase

public RuleBase(ObjectBase base)
Creates a new rule base, given its object base.
Parameters:
base - the object base over which it will work.

RuleBase

public RuleBase(ObjectBase base,
                RuleSorter ruleSorter)
Creates a new rule base, given its object base and a rule sorter to define the conflict resolution policy.
Parameters:
base - the object base.
ruleSorter - the sorter that will define this base's conflict resolution policy.
Method Detail

addRule

public void addRule(Rule r)
Adds a new rule to this rule base.
Parameters:
r - the rule being added to this base.

assertObject

public void assertObject(java.lang.Object obj)
Tells this base that a new object was inserted into its object base, so that the rules can be checked against this object.
Parameters:
obj - the object that was inserted.

dump

public void dump()
Prints a tree representation of this base. Useful for debugging.

dump

public void dump(int spaces)
Prints a tree representation of this base. Useful for debugging.
Parameters:
spaces - the identation of the information to be printed.

fireSingleRule

public boolean fireSingleRule(KnowledgeBase knowledgeBase)
                       throws RuleNotFiredException
Fires a single rule in the rule base, if there is such one in the conflict set.
Parameters:
knowledgeBase - the knowledge base that owns this rule base.
Returns:
true if a rule has been fired; false otherwise.
Throws:
RuleNotFiredException - if the rule didn't fire despite its preconditions being true, due to some error during its actions execution.

modifyObject

public void modifyObject(java.lang.Object obj)
Tells this base that an object was modified in its object base, so that the rules with instantiations for that object are retested, and new cases can be added to the conflict set.
Parameters:
obj - the object that was modified in this base.

reset

public void reset()
Removes all rules from this rule base.

retractObject

public void retractObject(java.lang.Object obj)
Tells this base that an object was removed from its object base, so that the rules with instantiations for that object are removed from the object base
Parameters:
obj - the object that was removed from this base.

setRuleSorter

public void setRuleSorter(RuleSorter ruleSorter)
Defines a conflict set policy for this rule base.
Parameters:
ruleSorter - the sorter that implements the needed policy.