ai.planning.strips
Class SequentialPlan

java.lang.Object
  extended by ai.planning.strips.SequentialPlan
All Implemented Interfaces:
Plan<ai.krr.fol.Atom>, SequentialPlan<ai.krr.fol.Atom>, inf.compilers.SyntaxAdaptable

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


Field Summary
protected  java.util.List<Action> actions
          the sequence of Actions contained in this Plan
protected  Domain domain
          the Domain in which this plan is defined
protected  ai.krr.NamedSymbol name
          the reference String that can be used to refer to this problem
 
Constructor Summary
SequentialPlan(Domain domain)
           This constructor creates a new, empty plan.
SequentialPlan(Domain domain, java.util.List<Action> acts)
           This constructor creates a new plan consisting of the given actions in the given order.
 
Method Summary
 void append(Action act)
           This function adds the given Action to the end of this plan.
 WorldState<ai.krr.fol.Atom> applyIn(WorldState<ai.krr.fol.Atom> istate)
           This function computes a new WorldState that is the result of applying this Plan in the given state.
 SequentialPlan<ai.krr.fol.Atom> asSequentialPlan()
           This function returns a linearised, total-order version of this Plan.
 SequentialPlan clone()
           This function returns a semi-shallow copy of this plan.
 void concatenate(SequentialPlan<ai.krr.fol.Atom> plan)
           This function can be used to concatenate two plans.
 boolean equals(java.lang.Object obj)
           This function compares this plan to the given Object.
 boolean equals(SequentialPlan other)
           
 java.util.List<Action<ai.krr.fol.Atom>> getActionSequence()
           This function returns the List of Actions that constitute this SequentialPlan.
 Domain<ai.krr.fol.Atom> getDomain()
           This function retrieves the Domain which contains the definitions of the ActionTypes of which the Actions in this Plan are instances.
 int hashCode()
           This function computes a hash code for this Plan.
 int length()
           This function returns the current length of this SequentialPlan.
protected  java.lang.String objectString()
           This function returns a String that is the String returned by this Object's toString function.
 void prepend(Action act)
           This function adds the given Action to the beginning of this plan.
 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 SequentialPlan read(java.io.Reader r, inf.compilers.SyntaxAdaptor<SequentialPlan> sa)
           
 boolean solves(Problem<ai.krr.fol.Atom> p)
           This function tests whether this Plan constitutes a solution to the given Problem.
 java.lang.String toString()
           This function returns a String representation of this plan.
 void write(java.io.Writer w, inf.compilers.SyntaxAdaptor sa)
          This function can be used write this logical Sentence to the given Writer.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

domain

protected Domain domain
the Domain in which this plan is defined


actions

protected java.util.List<Action> actions
the sequence of Actions contained in this Plan


name

protected ai.krr.NamedSymbol name
the reference String that can be used to refer to this problem

Constructor Detail

SequentialPlan

public SequentialPlan(Domain domain)

This constructor creates a new, empty plan.

Parameters:
domain - the Domain that defines the context for this plan

SequentialPlan

public SequentialPlan(Domain domain,
                      java.util.List<Action> acts)

This constructor creates a new plan consisting of the given actions in the given order.

Parameters:
domain - the Domain that defines the context for this plan
acts - the sequence of actions in this plan
Method Detail

clone

public SequentialPlan clone()

This function returns a semi-shallow copy of this plan. The actions in the plan will be the same as the originals, but the List that encapsulates them is new.

Overrides:
clone in class java.lang.Object
Returns:
a copy of this plan

asSequentialPlan

public SequentialPlan<ai.krr.fol.Atom> asSequentialPlan()

This function returns a linearised, total-order version of this Plan.

Specified by:
asSequentialPlan in interface Plan<ai.krr.fol.Atom>
Returns:
a SequentialPlan that corresponds to this Plan

getDomain

public Domain<ai.krr.fol.Atom> getDomain()

This function retrieves the Domain which contains the definitions of the ActionTypes of which the Actions in this Plan are instances.

Specified by:
getDomain in interface Plan<ai.krr.fol.Atom>
Returns:
the Domain for which this Plan was created

applyIn

public WorldState<ai.krr.fol.Atom> applyIn(WorldState<ai.krr.fol.Atom> istate)

This function computes a new WorldState that is the result of applying this Plan in the given state. If this Plan is not applicable in an intermediate state, the result will be null.

Specified by:
applyIn in interface Plan<ai.krr.fol.Atom>
Parameters:
istate - the WorldState in which the SequentialPlan is to be applied
Returns:
a new WorldState that is the result of the state transition function applied to this WorldState

solves

public boolean solves(Problem<ai.krr.fol.Atom> p)

This function tests whether this Plan constitutes a solution to the given Problem. This is true iff this Plan applied to the initial state results in a state that satisfies the goal of the Problem.

Specified by:
solves in interface Plan<ai.krr.fol.Atom>
Parameters:
p - the Problem to which this Plan be a solution
Returns:
true iff this Plan is a solution plan for the given problem

getActionSequence

public java.util.List<Action<ai.krr.fol.Atom>> getActionSequence()

This function returns the List of Actions that constitute this SequentialPlan.

Specified by:
getActionSequence in interface SequentialPlan<ai.krr.fol.Atom>
Returns:
the Action sequence that defines this SequentialPlan

concatenate

public void concatenate(SequentialPlan<ai.krr.fol.Atom> plan)

This function can be used to concatenate two plans. The result is a SequentialPlan that contains first this plan as its prefix and the given plan as its suffix. The length of the resulting plan will be the sum of the lengths of the two input plans.

Specified by:
concatenate in interface SequentialPlan<ai.krr.fol.Atom>
Parameters:
plan - the plan that will be appended to this SequentialPlan

length

public int length()

This function returns the current length of this SequentialPlan.

Specified by:
length in interface SequentialPlan<ai.krr.fol.Atom>
Returns:
the number of Actions in this SequentialPlan

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 logical Sentence 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 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

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

append

public void append(Action act)

This function adds the given Action to the end of this plan.

Parameters:
act - the new Action to be appended to this plan

prepend

public void prepend(Action act)

This function adds the given Action to the beginning of this plan.

Parameters:
act - the new Action to be prepended to this plan

objectString

protected java.lang.String objectString()

This function returns a String that is the String returned by this Object's toString function. Note that this makes it unique to this plan.

String a unique String for this SequentialPlan


equals

public boolean equals(java.lang.Object obj)

This function compares this plan to the given Object. Two SequentialPlans are equal if they contain equal Actions in an equal order.

Overrides:
equals in class java.lang.Object
Returns:
whether the given Object is equal to this plan

equals

public boolean equals(SequentialPlan other)

hashCode

public int hashCode()

This function computes a hash code for this Plan. The current implementation is not very efficient.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash value for this plan

toString

public java.lang.String toString()

This function returns a String representation of this plan.

Overrides:
toString in class java.lang.Object
Returns:
the contained List of Actions as a String

read

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