jeops
Class AbstractKnowledgeBase

java.lang.Object
  |
  +--jeops.AbstractKnowledgeBase

public abstract class AbstractKnowledgeBase
extends java.lang.Object
implements InternalConflictSetListener

The main class of JEOPS. This class models the knowledge the agent has about the world. In it are stored the facts (objects) and (production) rules that act on the first. This class must be subclassed by a concrete knowledge base so that it is provided with the object and rule base needed for work.

Version:
0.01 12 Mar 2000 Class adapted from previous version of JEOPS.
Author:
Carlos Figueira Filho (csff@di.ufpe.br)

Constructor Summary
AbstractKnowledgeBase(ConflictSet conflictSet)
          Creates a new knowledge base.
 
Method Summary
 void addConflictSetListener(RuleFireListener l)
          Adds the specified conflict set listener to receive events from this knowledge base.
 void addRuleFireListener(RuleFireListener l)
          Adds the specified rule fire listener to receive events from this knowledge base.
 void assert(java.lang.Object obj)
          Inserts a new object in this knowledge base.
 void flush()
          Remove all facts (objects) of the object base.
 AbstractRuleBase getRuleBase()
          Returns the (production) rule base of this knowledge base.
 void internalElementAdded(InternalConflictSetEvent e)
          Invoked when an element is added to the conflict set.
 void internalElementRemoved(InternalConflictSetEvent e)
          Invoked when an element is removed from the conflict set.
 java.util.Vector objects(java.lang.String className)
          Returns the objects of a given class.
 void removeConflictSetListener(RuleFireListener l)
          Removes the specified conflict set listener so that it no longer receives conflict set events from this knowledge base.
 void removeRuleFireListener(RuleFireListener l)
          Removes the specified rule fire listener so that it no longer receives rule fire events from this knowledge base.
 boolean retract(java.lang.Object obj)
          Removes a given object of this knowledge base.
 void run()
          Fires the rules in the rule base with the objects present in the object base, until no rule is fireable anymore.
 void setConflictSet(ConflictSet conflictSet)
          Defines a conflict set policy for this knowledge base.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractKnowledgeBase

public AbstractKnowledgeBase(ConflictSet conflictSet)
Creates a new knowledge base. The superclass must set the rule base of this kb prior to using it.
Parameters:
conflictSet - the conflict set associated with this knowledge base.
Method Detail

getRuleBase

public AbstractRuleBase getRuleBase()
Returns the (production) rule base of this knowledge base.
Returns:
the (production) rule base of this knowledge base.

addRuleFireListener

public void addRuleFireListener(RuleFireListener l)
Adds the specified rule fire listener to receive events from this knowledge base.
Parameters:
l - the rule base listener

removeRuleFireListener

public void removeRuleFireListener(RuleFireListener l)
Removes the specified rule fire listener so that it no longer receives rule fire events from this knowledge base.
Parameters:
l - the rule fire listener

addConflictSetListener

public void addConflictSetListener(RuleFireListener l)
Adds the specified conflict set listener to receive events from this knowledge base.
Parameters:
l - the conflict set listener

removeConflictSetListener

public void removeConflictSetListener(RuleFireListener l)
Removes the specified conflict set listener so that it no longer receives conflict set events from this knowledge base.
Parameters:
l - the conflict set listener

internalElementAdded

public void internalElementAdded(InternalConflictSetEvent e)
Invoked when an element is added to the conflict set.
Specified by:
internalElementAdded in interface InternalConflictSetListener
Parameters:
e - the conflict set event.

internalElementRemoved

public void internalElementRemoved(InternalConflictSetEvent e)
Invoked when an element is removed from the conflict set.
Specified by:
internalElementRemoved in interface InternalConflictSetListener
Parameters:
e - the conflict set event.

assert

public void assert(java.lang.Object obj)
Inserts a new object in this knowledge base.
Parameters:
obj - the object being inserted.

flush

public void flush()
Remove all facts (objects) of the object base.

objects

public java.util.Vector objects(java.lang.String className)
Returns the objects of a given class.
Parameters:
className - the name of the class.

retract

public boolean retract(java.lang.Object obj)
Removes a given object of this knowledge base.
Parameters:
obj - the object being removed.
Returns:
true if the given object belonged to this base; false otherwise.

run

public void run()
Fires the rules in the rule base with the objects present in the object base, until no rule is fireable anymore.

setConflictSet

public void setConflictSet(ConflictSet conflictSet)
Defines a conflict set policy for this knowledge base.
Parameters:
conflictSet - the new conflict set that implements its associated conflict resolution policy.