JSHOP2
Class InternalDomain

java.lang.Object
  extended by JSHOP2.InternalDomain

public class InternalDomain
extends java.lang.Object

Each domain at compile time is represented as an instance of this class.

Version:
1.0.3
Author:
Okhtay Ilghami, http://www.cs.umd.edu/~okhtay

Field Summary
private  java.util.Vector<InternalAxiom> axioms
          A Vector of axioms seen so far in the domain description.
private  java.util.Vector<java.lang.String> calcs
          A Vector of String names of user-defined external code calls that must be imported before being used in the domain description.
private  java.util.Vector<java.lang.String> compoundTasks
          A Vector of String names of compound tasks seen so far in the domain.
private  java.util.Vector<java.lang.String> constants
          A Vector of String names of constant symbols seen so far in the domain.
private  int constantsSize
          The number of constant symbols already seen in the planning domain.
(package private) static java.lang.String endl
          The new line character in the platform JSHOP2 is running on.
private  java.util.Vector<InternalMethod> methods
          A Vector of methods seen so far in the domain description.
private  java.lang.String name
          The String name of the domain.
private  java.util.Vector<InternalOperator> operators
          A Vector of operators seen so far in the domain description.
private  JSHOP2Parser parser
          The parser object that will parse this domain.
private  int planNo
          The number of solution plans per planning problem that the user has requested from this object.
private  java.util.Vector<java.lang.String> primitiveTasks
          A Vector of String names of primitive tasks seen so far in the domain.
private  java.lang.String probName
          The String name of the planning problem.
 
Constructor Summary
InternalDomain(java.io.File fin, int planNoIn)
          To initialize this domain.
 
Method Summary
 void addAxiom(InternalAxiom axiom)
          To add an axiom to the list of axioms read from the file.
 void addCalc(java.lang.String what)
          To add the String name of an external code call to the list of such code calls.
 int addCompoundTask(java.lang.String s)
          To add a String used as a name of a compound task in the domain description to the list of compound task names, in case it has not been added before.
 int addConstant(java.lang.String s)
          To add a String used as a constant symbol in the domain description to the list of constant symbols, in case it has not been added before.
 void addMethod(InternalMethod method)
          To add a method to the list of methods read from the file.
 void addOperator(InternalOperator op)
          To add an operator to the list of operators read from the file.
 int addPrimitiveTask(java.lang.String s)
          To add a String used as a name of a primitive task in the domain description to the list of primitive task names, in case it has not been added before.
 void close(int varsMaxSize)
          This function writes the Java code necessary to produce this domain at run time in the appropriate file.
 void commandInitialize()
          This function performs some necessary initialization when a problem file is being compiled, mainly reading and parsing the text file associated with the domain the planning problem is defined in.
 void commandToCode(java.util.LinkedList<java.util.Vector<Predicate>> states, java.util.LinkedList<TaskList> taskLists)
          This function writes the Java code necessary to produce these planning problems at run time in the appropriate file.
 void dumpStringArray(java.io.BufferedWriter dest, java.util.Vector<?> list)
          This function saves a given Vector of Strings in a given file.
 int getAxiomNo()
          This function returns the number of axioms in this domain.
 java.util.Vector<java.lang.String> getCompoundTasks()
          This function returns the Vector where the String names of the compound tasks in this domain are stored.
 java.util.Vector<java.lang.String> getConstants()
          This function returns the Vector where the String names of the constant symbols in this domain are stored.
 int getMethodNo()
          This function returns the number of methods in this domain.
 java.lang.String getName()
          This function returns the String name of this domain.
 java.util.Vector<java.lang.String> getPrimitiveTasks()
          This function returns the Vector where the String names of the primitive tasks in this domain are stored.
static void main(java.lang.String[] args)
          The main function that is called to do the compilation.
 int readStringArray(java.io.BufferedReader src, java.util.Vector<java.lang.String> list)
          This function reads a Vector of Strings from a given file.
 void setName(java.lang.String nameIn)
          To set the name of this planning domain.
 void setProbName(java.lang.String probNameIn)
          To set the name of this planning problem.
 java.lang.String vectorToCode(java.util.Vector<java.lang.String> list, java.lang.String name)
          This function produces the Java code needed to allocate and initialize an array the elements of which are drawn from a given Vector of Strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

planNo

private int planNo
The number of solution plans per planning problem that the user has requested from this object.


axioms

private java.util.Vector<InternalAxiom> axioms
A Vector of axioms seen so far in the domain description. Each member is of type InternalAxiom.


calcs

private java.util.Vector<java.lang.String> calcs
A Vector of String names of user-defined external code calls that must be imported before being used in the domain description.


compoundTasks

private java.util.Vector<java.lang.String> compoundTasks
A Vector of String names of compound tasks seen so far in the domain.


constants

private java.util.Vector<java.lang.String> constants
A Vector of String names of constant symbols seen so far in the domain.


constantsSize

private int constantsSize
The number of constant symbols already seen in the planning domain. Any number of constant symbols in the planning problem more than this indicates presence of constant symbols that appear exclusively in the problem description.


endl

static final java.lang.String endl
The new line character in the platform JSHOP2 is running on.


methods

private java.util.Vector<InternalMethod> methods
A Vector of methods seen so far in the domain description. Each member is of type InternalMethod.


name

private java.lang.String name
The String name of the domain.


operators

private java.util.Vector<InternalOperator> operators
A Vector of operators seen so far in the domain description. Each member is of type InternalOperator.


parser

private JSHOP2Parser parser
The parser object that will parse this domain.


primitiveTasks

private java.util.Vector<java.lang.String> primitiveTasks
A Vector of String names of primitive tasks seen so far in the domain.


probName

private java.lang.String probName
The String name of the planning problem.

Constructor Detail

InternalDomain

public InternalDomain(java.io.File fin,
                      int planNoIn)
               throws java.io.IOException
To initialize this domain.

Parameters:
fin - the file from which the domain description is to be read.
planNoIn - the number of solution plans per planning problem that the user has requested from this object.
Throws:
java.io.IOException
Method Detail

addAxiom

public void addAxiom(InternalAxiom axiom)
To add an axiom to the list of axioms read from the file.

Parameters:
axiom - the axiom to be added.

addCompoundTask

public int addCompoundTask(java.lang.String s)
To add a String used as a name of a compound task in the domain description to the list of compound task names, in case it has not been added before.

Parameters:
s - the String to be added.
Returns:
the index assigned to this name.

addConstant

public int addConstant(java.lang.String s)
To add a String used as a constant symbol in the domain description to the list of constant symbols, in case it has not been added before.

Parameters:
s - the String to be added.
Returns:
the index assigned to this name.

addCalc

public void addCalc(java.lang.String what)
To add the String name of an external code call to the list of such code calls.

Parameters:
what - the name of the code call being added.

addMethod

public void addMethod(InternalMethod method)
To add a method to the list of methods read from the file.

Parameters:
method - the method to be added.

addOperator

public void addOperator(InternalOperator op)
To add an operator to the list of operators read from the file.

Parameters:
op - the operator to be added.

addPrimitiveTask

public int addPrimitiveTask(java.lang.String s)
To add a String used as a name of a primitive task in the domain description to the list of primitive task names, in case it has not been added before.

Parameters:
s - the String to be added.
Returns:
the index assigned to this name.

close

public void close(int varsMaxSize)
           throws java.io.IOException
This function writes the Java code necessary to produce this domain at run time in the appropriate file.

Parameters:
varsMaxSize - the maximum number of variables seen in any variable scope in this domain.
Throws:
java.io.IOException

commandInitialize

public void commandInitialize()
                       throws java.io.IOException
This function performs some necessary initialization when a problem file is being compiled, mainly reading and parsing the text file associated with the domain the planning problem is defined in.

Throws:
java.io.IOException

commandToCode

public void commandToCode(java.util.LinkedList<java.util.Vector<Predicate>> states,
                          java.util.LinkedList<TaskList> taskLists)
                   throws java.io.IOException
This function writes the Java code necessary to produce these planning problems at run time in the appropriate file.

Parameters:
states - the list of initial state of the world, one per each planning problem.
taskLists - the list of the task lists to be achieved, one per each planning problem.
Throws:
java.io.IOException

dumpStringArray

public void dumpStringArray(java.io.BufferedWriter dest,
                            java.util.Vector<?> list)
                     throws java.io.IOException
This function saves a given Vector of Strings in a given file.

Parameters:
dest - the file where the Vector is to be saved.
list - the Vector to be saved.
Throws:
java.io.IOException

getAxiomNo

public int getAxiomNo()
This function returns the number of axioms in this domain.

Returns:
the number of axioms in this domain.

getCompoundTasks

public java.util.Vector<java.lang.String> getCompoundTasks()
This function returns the Vector where the String names of the compound tasks in this domain are stored.

Returns:
the Vector where the String names of the compound tasks in this domain are stored.

getConstants

public java.util.Vector<java.lang.String> getConstants()
This function returns the Vector where the String names of the constant symbols in this domain are stored.

Returns:
the Vector where the String names of the constant symbols in this domain are stored.

getMethodNo

public int getMethodNo()
This function returns the number of methods in this domain.

Returns:
the number of methods in this domain.

getName

public java.lang.String getName()
This function returns the String name of this domain.

Returns:
the String name of this domain.

getPrimitiveTasks

public java.util.Vector<java.lang.String> getPrimitiveTasks()
This function returns the Vector where the String names of the primitive tasks in this domain are stored.

Returns:
the Vector where the String names of the primitive tasks in this domain are stored.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
The main function that is called to do the compilation.

Parameters:
args - the command line arguments.
Throws:
java.lang.Exception

readStringArray

public int readStringArray(java.io.BufferedReader src,
                           java.util.Vector<java.lang.String> list)
                    throws java.io.IOException
This function reads a Vector of Strings from a given file.

Parameters:
src - the input file.
list - the Vector to be read.
Returns:
the number of the elements in the Vector.
Throws:
java.io.IOException

setName

public void setName(java.lang.String nameIn)
To set the name of this planning domain.

Parameters:
nameIn - the name of this planning domain.

setProbName

public void setProbName(java.lang.String probNameIn)
To set the name of this planning problem.

Parameters:
probNameIn - the name of this planning problem.

vectorToCode

public java.lang.String vectorToCode(java.util.Vector<java.lang.String> list,
                                     java.lang.String name)
This function produces the Java code needed to allocate and initialize an array the elements of which are drawn from a given Vector of Strings.

Parameters:
list - the Vector the elements of which are to be stored in the resulting array.
name - the name of the array where the elements of the Vector are to be stored.
Returns:
the produced Java code.