Package jason.bb

Class BeliefBase

java.lang.Object
jason.bb.BeliefBase
All Implemented Interfaces:
ToDOM, java.lang.Cloneable, java.lang.Iterable<Literal>
Direct Known Subclasses:
ChainBBAdapter, DefaultBeliefBase

public abstract class BeliefBase
extends java.lang.Object
implements java.lang.Iterable<Literal>, java.lang.Cloneable, ToDOM
Common interface for all kinds of Jason Belief bases, even those customised by the user.
  • Field Summary

    Fields
    Modifier and Type Field Description
    static Term APercept  
    static Term ASelf  
    (package private) java.lang.Object lock  
    static Term TPercept
    represents the structure 'source(percept)'
    static Term TSelf
    represents the structure 'source(self)'
  • Constructor Summary

    Constructors
    Constructor Description
    BeliefBase()  
  • Method Summary

    Modifier and Type Method Description
    boolean abolish​(Atom namespace, PredicateIndicator pi)  
    boolean abolish​(PredicateIndicator pi)
    Removes all believes with some functor/arity in the default namespace
    boolean add​(int index, Literal l)
    Adds a belief in the BB at index position, returns true if succeed
    boolean add​(Literal l)
    Adds a belief in the end of the BB, returns true if succeed.
    void clear()
    removes all beliefs from BB
    abstract BeliefBase clone()  
    Literal contains​(Literal l)
    Returns the literal l as it is in BB, this method does not consider annotations in the search.
    org.w3c.dom.Element getAsDOM​(org.w3c.dom.Document document)
    Gets the BB as XML
    java.util.Iterator<Literal> getCandidateBeliefs​(Literal l, Unifier u)
    Returns an iterator for all literals relevant for l's predicate indicator, if l is a var, returns all beliefs.
    The unifier u may contain values for variables in l.
    abstract java.util.Iterator<Literal> getCandidateBeliefs​(PredicateIndicator pi)
    Returns an iterator for all literals in the default namespace of the BB that match the functor/arity of the parameter.
    java.lang.Object getLock()
    Gets a lock for the BB
    java.util.Set<Atom> getNameSpaces()  
    java.util.Iterator<Literal> getPercepts()
    Returns all beliefs that have "percept" as source
    void init​(Agent ag, java.lang.String[] args)
    Called before the MAS execution with the agent that uses this BB and the args informed in .mas2j project.
    Example in .mas2j:
    agent BeliefBaseClass(1,bla);
    the init args will be ["1", "bla"].
    abstract java.util.Iterator<Literal> iterator()
    Returns an iterator for all beliefs.
    private void readObject​(java.io.ObjectInputStream inputStream)  
    boolean remove​(Literal l)
    Removes a literal from BB, returns true if succeed
    int size()
    Returns the number of beliefs in BB
    void stop()
    Called just before the end of MAS execution

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • ASelf

      public static final Term ASelf
    • APercept

      public static final Term APercept
    • TPercept

      public static final Term TPercept
      represents the structure 'source(percept)'
    • TSelf

      public static final Term TSelf
      represents the structure 'source(self)'
    • lock

      transient java.lang.Object lock
  • Constructor Details

    • BeliefBase

      public BeliefBase()
  • Method Details

    • init

      public void init​(Agent ag, java.lang.String[] args)
      Called before the MAS execution with the agent that uses this BB and the args informed in .mas2j project.
      Example in .mas2j:
      agent BeliefBaseClass(1,bla);
      the init args will be ["1", "bla"].
    • stop

      public void stop()
      Called just before the end of MAS execution
    • clear

      public void clear()
      removes all beliefs from BB
    • getNameSpaces

      public java.util.Set<Atom> getNameSpaces()
    • add

      public boolean add​(Literal l)
      Adds a belief in the end of the BB, returns true if succeed. The annots of l may be changed to reflect what was changed in the BB, for example, if l is p[a,b] in a BB with p[a], l will be changed to p[b] to produce the event +p[b], since only the annotation b is changed in the BB.
    • add

      public boolean add​(int index, Literal l)
      Adds a belief in the BB at index position, returns true if succeed
    • iterator

      public abstract java.util.Iterator<Literal> iterator()
      Returns an iterator for all beliefs.
      Specified by:
      iterator in interface java.lang.Iterable<Literal>
    • getCandidateBeliefs

      public abstract java.util.Iterator<Literal> getCandidateBeliefs​(PredicateIndicator pi)
      Returns an iterator for all literals in the default namespace of the BB that match the functor/arity of the parameter.
    • getCandidateBeliefs

      public java.util.Iterator<Literal> getCandidateBeliefs​(Literal l, Unifier u)
      Returns an iterator for all literals relevant for l's predicate indicator, if l is a var, returns all beliefs.
      The unifier u may contain values for variables in l. Example, if BB={a(10),a(20),a(2,1),b(f)}, then getCandidateBeliefs(a(5), {}) = {{a(10),a(20)}.
      if BB={a(10),a(20)}, then getCandidateBeliefs(X) = {{a(10),a(20)}. The getCandidateBeliefs(a(X), {X -> 5}) should also return {{a(10),a(20)}.
    • contains

      public Literal contains​(Literal l)
      Returns the literal l as it is in BB, this method does not consider annotations in the search.
      Example, if BB={a(10)[a,b]}, contains(a(10)[d]) returns a(10)[a,b].
    • size

      public int size()
      Returns the number of beliefs in BB
    • getPercepts

      public java.util.Iterator<Literal> getPercepts()
      Returns all beliefs that have "percept" as source
    • remove

      public boolean remove​(Literal l)
      Removes a literal from BB, returns true if succeed
    • abolish

      public boolean abolish​(PredicateIndicator pi)
      Removes all believes with some functor/arity in the default namespace
    • abolish

      public boolean abolish​(Atom namespace, PredicateIndicator pi)
    • getAsDOM

      public org.w3c.dom.Element getAsDOM​(org.w3c.dom.Document document)
      Gets the BB as XML
      Specified by:
      getAsDOM in interface ToDOM
    • clone

      public abstract BeliefBase clone()
      Overrides:
      clone in class java.lang.Object
    • getLock

      public java.lang.Object getLock()
      Gets a lock for the BB
    • readObject

      private void readObject​(java.io.ObjectInputStream inputStream) throws java.io.IOException, java.lang.ClassNotFoundException
      Throws:
      java.io.IOException
      java.lang.ClassNotFoundException