ai.planning.propositional
Class Domain

java.lang.Object
  extended by ai.planning.propositional.Domain
All Implemented Interfaces:
Domain<ai.krr.propositions.Atom>, inf.compilers.SyntaxAdaptable

public class Domain
extends java.lang.Object
implements Domain<ai.krr.propositions.Atom>, inf.compilers.SyntaxAdaptable

A propositional planning domain corresponds to a state-transition system in which the state space is implicitly defined by the propositional Atoms used to define the Domain and the planning problems for this Domain. The state-transition function is also defined implicitly by the actions defined in the Domain. Thus, the most important explicit component defining Domain here is the set of ActionTypes the provide the possible actions. The only additional element defined here is the name of the Domain.

Author:
Gerhard Wickler

Field Summary
protected static java.util.Map<ai.krr.NamedSymbol,Domain> allDomains
          all known Domains indexed by their name
protected static inf.compilers.SyntaxAdaptor<Domain> ioAdaptor
          the SyntaxAdaptor used for input/output operations
protected  ai.krr.NamedSymbol name
          the name given to this Domain
protected  java.util.List<ActionType> operators
          the ActionTypes that define this Domain
 
Constructor Summary
Domain(ai.krr.NamedSymbol name, ActionType... ops)
           This constructor creates a new Domain that has the given name and is defined by the given ActionTypes.
Domain(ai.krr.NamedSymbol name, java.util.Collection<ActionType> ops)
           This constructor creates a new Domain that has the given name and is defined by the given ActionTypes.
 
Method Summary
protected  Domain clone()
           This class does not support cloning and an Exception will be thrown if this method is called.
 ai.krr.NamedSymbol getName()
           This function returns the name of this Domain.
 ActionType getOperator(ai.krr.NamedSymbol name)
           This function returns the ActionType with the given name that may be defined in this Domain.
 java.util.List<ActionType> getOperators()
           This function returns the List of ActionTypes that define this Domain.
 java.util.Set<Goal> getSubGoals(Goal goal)
           This function computes the regression set of the given Goal.
 java.util.Set<Goal> getSubGoals(java.util.Set<Goal> goals)
           This function computes the possible sub-goals of the given Set of Goals.
 java.util.Set<WorldState> getSuccessors(java.util.Set<WorldState> states)
           This function computes all the successor states of the given Set of WorldStates.
 java.util.Set<WorldState> getSuccessors(WorldState state)
           This function computes all the successor states of the given WorldState.
 int hashCode()
           This function returns a hash value for this domain.
 void prettyPrint(int indent, java.io.Writer w, inf.compilers.SyntaxAdaptor sa)
           This function can be used write this SyntaxAdaptable object to the given Writer.
static Domain read(java.io.Reader r, inf.compilers.SyntaxAdaptor<Domain> sa)
           This function can be used to parse a Domain from the given Reader.
static Domain readFromFile(java.io.File file)
           This convenience function can be used to read a Domain from the given File.
static void setSyntax(inf.compilers.SyntaxAdaptor<Domain> sa)
           This function can be used to define the syntax with which instances of this class are written or read.
 java.lang.String toString()
           This function returns a String representation of this Domain.
 void write(java.io.Writer w, inf.compilers.SyntaxAdaptor sa)
           This function can be used write this propositional Domain to the given Writer.
 void writeToFile(java.io.File file)
           This convenience function can be used to write this Domain to the given File.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

allDomains

protected static java.util.Map<ai.krr.NamedSymbol,Domain> allDomains
all known Domains indexed by their name


ioAdaptor

protected static inf.compilers.SyntaxAdaptor<Domain> ioAdaptor
the SyntaxAdaptor used for input/output operations


name

protected final ai.krr.NamedSymbol name
the name given to this Domain


operators

protected java.util.List<ActionType> operators
the ActionTypes that define this Domain

Constructor Detail

Domain

public Domain(ai.krr.NamedSymbol name,
              java.util.Collection<ActionType> ops)

This constructor creates a new Domain that has the given name and is defined by the given ActionTypes. Note that ActionTypes should have unique names, which is verified if assertions are on.

Parameters:
name - the Symbol representing the name of this Domain
ops - the ActionTypes in this Domain

Domain

public Domain(ai.krr.NamedSymbol name,
              ActionType... ops)

This constructor creates a new Domain that has the given name and is defined by the given ActionTypes. This constructor simply uses the one taking a Collection of ActionTypes

Parameters:
name - the Symbol representing the name of this Domain
ops - the ActionTypes in this Domain
Method Detail

clone

protected Domain clone()
                throws java.lang.CloneNotSupportedException

This class does not support cloning and an Exception will be thrown if this method is called.

Overrides:
clone in class java.lang.Object
Returns:
nothing
Throws:
java.lang.CloneNotSupportedException - will be thrown

getName

public final ai.krr.NamedSymbol getName()

This function returns the name of this Domain.

Specified by:
getName in interface Domain<ai.krr.propositions.Atom>
Returns:
the symbolic name of this Domain

getOperators

public java.util.List<ActionType> getOperators()

This function returns the List of ActionTypes that define this Domain.

Specified by:
getOperators in interface Domain<ai.krr.propositions.Atom>
Returns:
the ActionTypes in this Domain

getOperator

public ActionType getOperator(ai.krr.NamedSymbol name)

This function returns the ActionType with the given name that may be defined in this Domain. It returns null if there is no ActionType with the given name.

Specified by:
getOperator in interface Domain<ai.krr.propositions.Atom>
Parameters:
name - the name identifying the ActionType
Returns:
the ActionType with the given (unique) name

write

public void write(java.io.Writer w,
                  inf.compilers.SyntaxAdaptor sa)
           throws inf.compilers.ExpressivenessException,
                  java.io.IOException

This function can be used write this propositional Domain to the given Writer. The syntax in which it is written is defined by the SyntaxAdaptor that is also given to this function.

Specified by:
write in interface inf.compilers.SyntaxAdaptable
Parameters:
w - the Writer to which this Domain is written
sa - the SyntaxAdaptor that determines the syntax
Throws:
inf.compilers.ExpressivenessException - if the syntax does not support every construct occurring in this Domain
java.io.IOException - if writing to the Writer fails

prettyPrint

public void prettyPrint(int indent,
                        java.io.Writer w,
                        inf.compilers.SyntaxAdaptor sa)
                 throws inf.compilers.ExpressivenessException,
                        java.io.IOException

This function can be used write this SyntaxAdaptable object to the given Writer. The syntax is the same as for normal writing. The only difference is the inclusion of extra space and newlines for better readability.

Specified by:
prettyPrint in interface inf.compilers.SyntaxAdaptable
Parameters:
indent - the amount of indentation for the first line
w - the Writer to which this Sentence is written
sa - the SyntaxAdaptor that determines the syntax
Throws:
inf.compilers.ExpressivenessException - if the syntax does not support every construct occurring in this Sentence
java.io.IOException - if writing to the Writer fails

getSuccessors

public java.util.Set<WorldState> getSuccessors(WorldState state)

This function computes all the successor states of the given WorldState. This domain defines the ActionTypes that may be used to generate the successors.

Parameters:
state - the WorldState from which the successors are generated
Returns:
the Set of all the states reachable from this one

getSuccessors

public java.util.Set<WorldState> getSuccessors(java.util.Set<WorldState> states)

This function computes all the successor states of the given Set of WorldStates. This domain defines the ActionTypes that may be used to generate the successors.

Parameters:
states - the WorldStates from which the successors are generated
Returns:
the Set of all the states reachable from the given states

getSubGoals

public java.util.Set<Goal> getSubGoals(Goal goal)

This function computes the regression set of the given Goal. If a WorldState satisfies any one of these sub-goals then a state in which this Goal is satisfied is reachable. This domain defines the ActionTypes that may be used to generate the sub-goals.

Parameters:
goal - the Goal of which the possible sub-goals are to be computed
Returns:
the Set of all the sub-goals that may lead to this Goal being achieved

getSubGoals

public java.util.Set<Goal> getSubGoals(java.util.Set<Goal> goals)

This function computes the possible sub-goals of the given Set of Goals. If a WorldState satisfies any one of these sub-goals then a state in which a Goal in the given Set is satisfied is reachable. This domain defines the ActionTypes that may be used to generate the sub-goals.

Parameters:
goals - the Goals of which the possible sub-goals are to be computed
Returns:
the Set of all the sub-goals that may lead to the given Goals being achieved

writeToFile

public void writeToFile(java.io.File file)
                 throws java.io.IOException,
                        inf.compilers.ExpressivenessException

This convenience function can be used to write this Domain to the given File. Note that it actually pretty-prints this domain. The SyntaxAdaptor used can specified using setSyntax(SyntaxAdaptor).

Parameters:
file - the File to which this Domain is to be written
Throws:
java.io.IOException - if writing to the File fails
inf.compilers.ExpressivenessException - if the SyntaxAdaptor used throws this Exception

toString

public java.lang.String toString()

This function returns a String representation of this Domain. The exact syntax is determined by the SyntaxAdaptor used, which can be set using setSyntax(SyntaxAdaptor). If the transformation causes an ExpressivenessException (if there are constructs in this Domain that cannot be expressed in the syntax) this function will return null.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this Domain

hashCode

public int hashCode()

This function returns a hash value for this domain.

Overrides:
hashCode in class java.lang.Object
Returns:
an integer that can be used for hashing

setSyntax

public static void setSyntax(inf.compilers.SyntaxAdaptor<Domain> sa)

This function can be used to define the syntax with which instances of this class are written or read. The default is the PPL syntax defined by a PplDomainAdaptor.

Parameters:
sa - the SyntaxAdaptor that defines the syntax for I/O operations

read

public static Domain read(java.io.Reader r,
                          inf.compilers.SyntaxAdaptor<Domain> sa)
                   throws inf.compilers.ExpressivenessException,
                          java.text.ParseException,
                          java.io.IOException

This function can be used to parse a Domain from the given Reader. The syntax that is expected from the input and how this is transformed into a propositional Domain is determined by the given SyntaxAdaptor.

Parameters:
r - the Reader from which character input is parsed
sa - the SyntaxAdaptor that creates the Domain
Returns:
a new Domain corresponding to the given input
Throws:
inf.compilers.ExpressivenessException - if the syntax does not support every construct occurring in the input
java.text.ParseException - if the input contains syntax errors
java.io.IOException - if reading from the Reader fails

readFromFile

public static Domain readFromFile(java.io.File file)
                           throws inf.compilers.ExpressivenessException,
                                  java.text.ParseException,
                                  java.io.IOException

This convenience function can be used to read a Domain from the given File. It uses the SyntaxAdaptor that can be set using setSyntax(SyntaxAdaptor) to perform this operation.

Parameters:
file - the File from which the Domain is to be read
Returns:
the Domain defined in the given file
Throws:
inf.compilers.ExpressivenessException - if the syntax does not support every construct occurring in the input
java.text.ParseException - if the input contains syntax errors
java.io.IOException - if reading from the File fails