ai.planning.propositional
Class Problem

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

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

A planning problem over a planning Domain is defined by an initial WorldState and a Goal.

Author:
Gerhard Wickler

Field Summary
protected  Domain domain
          the Domain over which this problem is defined
protected  Goal goal
          the goal condition to be achieved
protected  WorldState initialState
          the initial state of the world
protected static inf.compilers.SyntaxAdaptor<Problem> ioAdaptor
          the SyntaxAdaptor used for input/output operations
 
Constructor Summary
Problem(Domain d, WorldState s0, Goal g)
           This constructor creates a new planning problem over the given domain.
 
Method Summary
protected  Problem clone()
           This class does not support cloning and an Exception will be thrown if this method is called.
 Domain getDomain()
           This function returns the domain over which this Problem is defined.
 Goal getGoal()
           This function returns the goal conditions that define this Problem.
 WorldState getInitialState()
           This function returns the initial state of the world that defines this Problem.
 int hashCode()
           This function returns a hash value for this problem.
 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 Problem read(java.io.Reader r, inf.compilers.SyntaxAdaptor<Problem> sa)
           This function can be used to parse a Problem from the given Reader.
static Problem readFromFile(java.io.File file)
           This convenience function can be used to read a Problem from the given File.
static void setSyntax(inf.compilers.SyntaxAdaptor<Problem> 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 Problem.
 void write(java.io.Writer w, inf.compilers.SyntaxAdaptor sa)
           This function can be used write this propositional planning problem to the given Writer.
 void writeToFile(java.io.File file)
           This convenience function can be used to write this Problem to the given File.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ioAdaptor

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


domain

protected final Domain domain
the Domain over which this problem is defined


initialState

protected final WorldState initialState
the initial state of the world


goal

protected final Goal goal
the goal condition to be achieved

Constructor Detail

Problem

public Problem(Domain d,
               WorldState s0,
               Goal g)

This constructor creates a new planning problem over the given domain.

Parameters:
d - the domain over which the problem is defined
s0 - the initial state of the world
g - the goal to be achieved
Method Detail

clone

protected Problem 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

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 planning problem 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 Problem 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

getDomain

public final Domain getDomain()

This function returns the domain over which this Problem is defined.

Specified by:
getDomain in interface Problem<ai.krr.propositions.Atom>
Returns:
the Domain underlying this Problem

getInitialState

public final WorldState getInitialState()

This function returns the initial state of the world that defines this Problem.

Specified by:
getInitialState in interface Problem<ai.krr.propositions.Atom>
Returns:
the WorldState assumed to hold initially

getGoal

public final Goal getGoal()

This function returns the goal conditions that define this Problem.

Specified by:
getGoal in interface Problem<ai.krr.propositions.Atom>
Returns:
the Goal that is to be achieved in this Problem

writeToFile

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

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

Parameters:
file - the File to which this Problem 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 Problem. 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 Problem 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 Problem

hashCode

public int hashCode()

This function returns a hash value for this problem.

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

setSyntax

public static void setSyntax(inf.compilers.SyntaxAdaptor<Problem> 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 PplProblemAdaptor.

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

read

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

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

Parameters:
r - the Reader from which character input is parsed
sa - the SyntaxAdaptor that creates the Problem
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 Problem readFromFile(java.io.File file)
                            throws inf.compilers.ExpressivenessException,
                                   java.text.ParseException,
                                   java.io.IOException

This convenience function can be used to read a Problem 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 Problem is to be read
Returns:
the Problem 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