Package jason.bb

Class DefaultBeliefBase

java.lang.Object
jason.bb.BeliefBase
jason.bb.DefaultBeliefBase
All Implemented Interfaces:
ToDOM, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Literal>

public class DefaultBeliefBase
extends BeliefBase
implements java.io.Serializable
Default implementation of Jason BB.
See Also:
Serialized Form
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
      Constant Field Values
    • logger

      private static java.util.logging.Logger logger
    • belsMapDefaultNS

      private java.util.Map<PredicateIndicator,​DefaultBeliefBase.BelEntry> belsMapDefaultNS
      belsMap is a table where the key is the bel.getFunctorArity and the value is a list of literals with the same functorArity.
    • nameSpaces

      private java.util.Map<Atom,​java.util.Map<PredicateIndicator,​DefaultBeliefBase.BelEntry>> nameSpaces
    • size

      private int size
    • percepts

      protected java.util.Set<Literal> percepts
      set of beliefs with percept annot, used to improve performance of buf
  • Constructor Details

    • DefaultBeliefBase

      public DefaultBeliefBase()
  • Method Details

    • init

      public void init​(Agent ag, java.lang.String[] args)
      Description copied from class: BeliefBase
      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"].
      Overrides:
      init in class BeliefBase
    • getNameSpaces

      public java.util.Set<Atom> getNameSpaces()
      Overrides:
      getNameSpaces in class BeliefBase
    • size

      public int size()
      Description copied from class: BeliefBase
      Returns the number of beliefs in BB
      Overrides:
      size in class BeliefBase
    • clear

      public void clear()
      Description copied from class: BeliefBase
      removes all beliefs from BB
      Overrides:
      clear in class BeliefBase
    • getPercepts

      public java.util.Iterator<Literal> getPercepts()
      Description copied from class: BeliefBase
      Returns all beliefs that have "percept" as source
      Overrides:
      getPercepts in class BeliefBase
    • getPerceptsSet

      java.util.Set<Literal> getPerceptsSet()
    • add

      public boolean add​(Literal l)
      Description copied from class: BeliefBase
      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.
      Overrides:
      add in class BeliefBase
    • add

      public boolean add​(int index, Literal l)
      Description copied from class: BeliefBase
      Adds a belief in the BB at index position, returns true if succeed
      Overrides:
      add in class BeliefBase
    • add

      protected boolean add​(Literal l, boolean addInEnd)
    • provideBelEntry

      private DefaultBeliefBase.BelEntry provideBelEntry​(Literal l)
    • remove

      public boolean remove​(Literal l)
      Description copied from class: BeliefBase
      Removes a literal from BB, returns true if succeed
      Overrides:
      remove in class BeliefBase
    • removeFromEntry

      private boolean removeFromEntry​(Literal l)
    • iterator

      public java.util.Iterator<Literal> iterator()
      Description copied from class: BeliefBase
      Returns an iterator for all beliefs.
      Specified by:
      iterator in interface java.lang.Iterable<Literal>
      Specified by:
      iterator in class BeliefBase
    • abolish

      public boolean abolish​(Atom namespace, PredicateIndicator pi)
      Overrides:
      abolish in class BeliefBase
    • contains

      public Literal contains​(Literal l)
      Description copied from class: BeliefBase
      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].
      Overrides:
      contains in class BeliefBase
    • getCandidateBeliefs

      public java.util.Iterator<Literal> getCandidateBeliefs​(PredicateIndicator pi)
      Description copied from class: BeliefBase
      Returns an iterator for all literals in the default namespace of the BB that match the functor/arity of the parameter.
      Specified by:
      getCandidateBeliefs in class BeliefBase
    • getCandidateBeliefs

      public java.util.Iterator<Literal> getCandidateBeliefs​(Literal l, Unifier u)
      Description copied from class: BeliefBase
      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)}.
      Overrides:
      getCandidateBeliefs in class BeliefBase
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • clone

      public BeliefBase clone()
      Specified by:
      clone in class BeliefBase
    • getAsDOM

      public org.w3c.dom.Element getAsDOM​(org.w3c.dom.Document document)
      Description copied from class: BeliefBase
      Gets the BB as XML
      Specified by:
      getAsDOM in interface ToDOM
      Overrides:
      getAsDOM in class BeliefBase