|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectJSHOP2.State
public class State
This class is used to represent the current state of the world.
Field Summary | |
---|---|
private java.util.Vector<Term>[] |
atoms
The atoms in the current state of the world as an array of Vector s. |
private Axiom[][] |
axioms
The axioms in the domain description as a two-dimensional array. |
private java.util.Vector<NumberedPredicate>[] |
protections
The protections in the current state of the world as an array of Vector s. |
Constructor Summary | |
---|---|
State(int size,
Axiom[][] axiomsIn)
To initialize the state of the world. |
Method Summary | |
---|---|
boolean |
add(Predicate p)
To add a predicate to the current state of the world. |
boolean |
addProtection(Predicate p)
To protect a given predicate in the current state of the world. |
void |
clear()
To empty the world state. |
int |
del(Predicate p)
To delete a predicate from the current state of the world. |
boolean |
delProtection(Predicate p)
To unprotect a given predicate. |
java.util.ArrayList<java.lang.String> |
getState()
Returns an ArrayList of strings that represents the state. |
boolean |
isProtected(Predicate p)
To check if a predicate is protected. |
MyIterator |
iterator(int head)
To initialize and return the appropriate iterator when looking for ways to satisfy a given predicate. |
Term[] |
nextBinding(Predicate p,
MyIterator me)
This function returns the bindings that can satisfy a given precondition one-by-one. |
void |
print()
This function is used to print the current state of the world. |
void |
undo(java.util.Vector[] delAdd)
This function is used, in case of a backtrack, to undo the changes that were made to the current state of the world because of the backtracked decision. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.Vector<Term>[] atoms
Vector
s. The array is indexed by the possible heads (i.e.,
the constant symbol that comes first) of the possible predicates.
private Axiom[][] axioms
private java.util.Vector<NumberedPredicate>[] protections
Vector
s. The array is indexed by the heads of protected
predicates.
Constructor Detail |
---|
public State(int size, Axiom[][] axiomsIn)
size
- the number of possible heads of predicates (i.e., the number of
constant symbols that can come first in a predicate).axiomsIn
- the axioms in the domain description as a two-dimensional array.
The array is indexed first by the head of the predicates each
axiom can prove and second by the axioms themselves.Method Detail |
---|
public boolean add(Predicate p)
p
- the predicate to be added.
true
if the predicate was added (i.e., it was not
already in the current state of the world), false
otherwise.public boolean addProtection(Predicate p)
p
- the predicate to be protected.
true
.public void clear()
public int del(Predicate p)
p
- the predicate to be deleted.
Vector
if the predicate was deleted (i.e., it
existed in the current state of the world), -1 otherwise. This
index is used in case of a backtrack to undo this deletion by
inserting the deleted predicate right back where it used to be.public boolean delProtection(Predicate p)
p
- the predicate to be unprotected.
true
if the protected is unprotected successfully,
false
otherwise (i.e., when the predicate was not
protected before).public boolean isProtected(Predicate p)
p
- the predicate to be checked.
true
if the predicate is protected,
false
otherwise.public MyIterator iterator(int head)
head
- the index of the constant symbol that is the head of the
predicate (i.e., that comes first in the predicate).
public Term[] nextBinding(Predicate p, MyIterator me)
p
- the predicate to be satisfied.me
- the iterator that keeps track of where we are with the satisfiers
so that the next time this function is called, we can take off
where we stopped last time.
public void print()
public java.util.ArrayList<java.lang.String> getState()
public void undo(java.util.Vector[] delAdd)
delAdd
- a 4-member array of type Vector
. These four
members are the deleted atoms, the added atoms, the deleted
protections and the added protections respectively.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |