public class DefaultBeliefBase extends BeliefBase
Modifier and Type | Class and Description |
---|---|
(package private) class |
DefaultBeliefBase.BelEntry
each predicate indicator has one BelEntry assigned to it
|
Modifier and Type | Field and Description |
---|---|
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.
|
private static java.util.logging.Logger |
logger |
private java.util.Map<Atom,java.util.Map<PredicateIndicator,DefaultBeliefBase.BelEntry>> |
nameSpaces |
protected java.util.Set<Literal> |
percepts
set of beliefs with percept annot, used to improve performance of buf
|
private int |
size |
Constructor and Description |
---|
DefaultBeliefBase() |
Modifier and Type | Method and Description |
---|---|
boolean |
abolish(Atom namespace,
PredicateIndicator pi) |
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.
|
protected boolean |
add(Literal l,
boolean addInEnd) |
void |
clear()
removes all beliefs from BB
|
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. |
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.util.Set<Atom> |
getNameSpaces() |
java.util.Iterator<Literal> |
getPercepts()
Returns all beliefs that have "percept" as source
|
(package private) java.util.Set<Literal> |
getPerceptsSet() |
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"]. |
java.util.Iterator<Literal> |
iterator()
Returns an iterator for all beliefs.
|
private DefaultBeliefBase.BelEntry |
provideBelEntry(Literal l) |
boolean |
remove(Literal l)
Removes a literal from BB, returns true if succeed
|
private boolean |
removeFromEntry(Literal l) |
int |
size()
Returns the number of beliefs in BB
|
java.lang.String |
toString() |
abolish, getLock, stop
private static java.util.logging.Logger logger
private java.util.Map<PredicateIndicator,DefaultBeliefBase.BelEntry> belsMapDefaultNS
private java.util.Map<Atom,java.util.Map<PredicateIndicator,DefaultBeliefBase.BelEntry>> nameSpaces
private int size
protected java.util.Set<Literal> percepts
public void init(Agent ag, java.lang.String[] args)
BeliefBase
agent BeliefBaseClass(1,bla);
init
in class BeliefBase
public java.util.Set<Atom> getNameSpaces()
getNameSpaces
in class BeliefBase
public int size()
BeliefBase
size
in class BeliefBase
public void clear()
BeliefBase
clear
in class BeliefBase
public java.util.Iterator<Literal> getPercepts()
BeliefBase
getPercepts
in class BeliefBase
java.util.Set<Literal> getPerceptsSet()
public boolean add(Literal l)
BeliefBase
add
in class BeliefBase
public boolean add(int index, Literal l)
BeliefBase
add
in class BeliefBase
protected boolean add(Literal l, boolean addInEnd)
private DefaultBeliefBase.BelEntry provideBelEntry(Literal l)
public boolean remove(Literal l)
BeliefBase
remove
in class BeliefBase
private boolean removeFromEntry(Literal l)
public java.util.Iterator<Literal> iterator()
BeliefBase
iterator
in interface java.lang.Iterable<Literal>
iterator
in class BeliefBase
public boolean abolish(Atom namespace, PredicateIndicator pi)
abolish
in class BeliefBase
public Literal contains(Literal l)
BeliefBase
contains(a(10)[d])
returns
a(10)[a,b].contains
in class BeliefBase
public java.util.Iterator<Literal> getCandidateBeliefs(PredicateIndicator pi)
BeliefBase
getCandidateBeliefs
in class BeliefBase
public java.util.Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u)
BeliefBase
getCandidateBeliefs(a(5), {})
= {{a(10),a(20)}.getCandidateBeliefs(X)
=
{{a(10),a(20)}. The getCandidateBeliefs(a(X), {X -> 5})
should also return {{a(10),a(20)}.getCandidateBeliefs
in class BeliefBase
public java.lang.String toString()
toString
in class java.lang.Object
public BeliefBase clone()
clone
in class BeliefBase
public org.w3c.dom.Element getAsDOM(org.w3c.dom.Document document)
BeliefBase
getAsDOM
in class BeliefBase