

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object ai.planning.strips.Grounding ai.planning.strips.ActionType.ArrayGrounding
public static class ActionType.ArrayGrounding
A Substitution maps a set of Variables to a set of Terms. In the case of a Grounding the Terms must be Constants and no Variables can be unified with other Variables.
This implementation maintains two arrays where a variable at one index in the
first array is mapped to a value at the same index in the second array. The
biggest disadvantage of this implementation is that access takes linear time
for most operations, which is why this class should only be used if the
number of variables to be grounded is small. This number is limited at
construction time. The advantage of this implementation is that it provides a
function revertTo(int)
which can be used to backtrack to a previous
version of this Grounding. This is very useful when searching for a
Grounding.
Field Summary  

protected int 
nextIdx
the index of the next free position in the arrays 
protected ai.krr.fol.Constant[] 
terms
the Constants to which the Variables are mapped 
protected ai.krr.fol.Variable[] 
vars
the Variables that are grounded by this Grounding 
Constructor Summary  

ActionType.ArrayGrounding(int maxVars)
This constructor creates a new Grounding with no associations. 
Method Summary  

ActionType.ArrayGrounding 
clone()
This function creates a shallow copy of this Grounding which consists of a shallow copy of the contained map. 
boolean 
contains(ai.krr.fol.Variable var)
This function tests whether this Substitution maps the given Variable to a new Term. 
boolean 
equals(Grounding s)
This function compares this and the given Grounding. 
ai.krr.fol.Constant 
getValue(ai.krr.fol.Variable var)
This function returns the Term the given Variable is mapped to. 
java.util.Set<ai.krr.fol.Variable> 
getVars()
This function returns a Set of all the Variables that are unified in this Substitution. 
int 
hashCode()

void 
revertTo(int nrVars)
This function reverts this Grounding to an earlier version in which only the given number of Variables are unified. 
int 
size()
This function returns the number of variables bound by this Grounding. 
java.lang.String 
toString()

boolean 
unify(ai.krr.fol.Variable var,
ai.krr.fol.Term term)
This function attempts to extend this Substitution such that the given Variable (from the "left" expression) and the given Term (from the "right") are unified and returns whether this succeeded. 
Methods inherited from class ai.planning.strips.Grounding 

unify, unify 
Methods inherited from class java.lang.Object 

equals, finalize, getClass, notify, notifyAll, wait, wait, wait 
Field Detail 

protected ai.krr.fol.Variable[] vars
protected ai.krr.fol.Constant[] terms
protected int nextIdx
Constructor Detail 

public ActionType.ArrayGrounding(int maxVars)
This constructor creates a new Grounding with no associations. The given integer specifies the maximal number of Variables that can be grounded here. An attempt to add more Variables will result in an Exception.
size
 the maximal number of Variables to be groundedMethod Detail 

public ActionType.ArrayGrounding clone()
This function creates a shallow copy of this Grounding which consists of a shallow copy of the contained map. Thus, modifications to the map of the copy will not modify the original, modifications to the key or value objects will.
clone
in class java.lang.Object
public int size()
This function returns the number of variables bound by this Grounding.
size
in class Grounding
public boolean unify(ai.krr.fol.Variable var, ai.krr.fol.Term term)
This function attempts to extend this Substitution such that the given Variable (from the "left" expression) and the given Term (from the "right") are unified and returns whether this succeeded.
aVar
 the Variable the given Term is to be unified withaTerm
 the Term the given Variable will be mapped to
public boolean contains(ai.krr.fol.Variable var)
This function tests whether this Substitution maps the given Variable to a new Term.
var
 the Variable the Term is being sought for
public ai.krr.fol.Constant getValue(ai.krr.fol.Variable var)
This function returns the Term the given Variable is mapped to. More specifically, it returns:
getValue
in interface ai.krr.fol.Substitution
getValue
in class Grounding
aVar
 the Variable the Term is being sought for
public java.util.Set<ai.krr.fol.Variable> getVars()
This function returns a Set of all the Variables that are unified in this
Substitution. To find out whether a specific Variable is instantiated by
this ArrayGrounding, it is more efficient to use
#getTerm(Variable)
which should return null iff the Variable is
not instantiated.
getVars
in class Grounding
public void revertTo(int nrVars)
This function reverts this Grounding to an earlier version in which only the given number of Variables are unified.
nrVars
 the number of Variables in the earlier versionpublic boolean equals(Grounding s)
Grounding
This function compares this and the given Grounding. Two Groundings are equal if they map the same Variables to the same Constants.
equals
in class Grounding
s
 the Grounding this one is to be compared to
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 