Class KnowledgeBase

  • All Implemented Interfaces:
    java.io.Serializable

    public class KnowledgeBase
    extends java.lang.Object
    implements java.io.Serializable
    Implements a KnowledgeBase that stores properties and predicates about the world. Provides a very fast method of searching for the information stored inside it. At the moment this KnowledgeBase also provides a limited kind of forward inference that can be applyed to generate new properties and predicates. This logical inference is performed by specific inference operators that must be explicitly added to the KB. This KB works as an efficient information repository. You cannot create a KB, since there is one and only one KB for the agent. If you want to access it use KnowledgeBase.GetInstance() method.
    Author:
    Joao Dias
    See Also:
    Serialized Form
    • Constructor Detail

      • KnowledgeBase

        public KnowledgeBase()
        Creates a new Empty KnowledgeBase
    • Method Detail

      • AddInferenceOperator

        public void AddInferenceOperator​(Step op)
        Adds an InferenceOperator to the KnowledgeBase
        Parameters:
        op - - the inference operator to Add
      • Ask

        public java.lang.Object Ask​(Name name)
      • Clear

        public void Clear()
        Empties the KnowledgeBase
      • Count

        public int Count()
        Gets the number of elements (predicates or properties) stored in the KnowledgeBase
        Returns:
        the number of elements stored in the KB
      • GetFactList

        public java.util.ArrayList<KnowledgeSlot> GetFactList()
      • GetInferenceOperators

        public java.util.ArrayList<Step> GetInferenceOperators()
        Gets the inference operators
        Returns:
        the inference operators
      • Retract

        public void Retract​(Name predicate)
        Removes a predicate from the KnowledgeBase
        Parameters:
        predicate - - the predicate to be removed
      • Tell

        public void Tell​(Name property,
                         java.lang.Object value)
        Adds a new property or sets its value (if already exists) in the KnowledgeBase
        Parameters:
        property - - the property to be added/changed
        value - - the value to be stored in the property
      • GetPossibleBindings

        public java.util.ArrayList<SubstitutionSet> GetPossibleBindings​(Name name)
      • GetObjectDetails

        public KnowledgeSlot GetObjectDetails​(java.lang.String objectName)
      • GetObjectProperty

        public KnowledgeSlot GetObjectProperty​(java.lang.String objectName,
                                               java.lang.String property)
      • toString

        public java.lang.String toString()
        Converts the Information stored in the KB to one String
        Overrides:
        toString in class java.lang.Object
        Returns:
        the converted String
      • toXML

        public java.lang.String toXML()