ai.planning.propositional.ssp
Class ForwardSearchPlanner

java.lang.Object
  extended by ai.planning.propositional.ssp.ForwardSearchPlanner
All Implemented Interfaces:
Planner<ai.krr.propositions.Atom>

public class ForwardSearchPlanner
extends java.lang.Object
implements Planner<ai.krr.propositions.Atom>

This class represents a planner that can solve (simple) propositional planning problems. The algorithm used is forward state-space search, i.e. each search state corresponds to a WorldState. Successors are generated by applying applicable actions from the Domain specified in the Problem given to the planner at construction time. The SearchEngine used to perform the search is an AStarSearcherForIntCostFn. It explores the search space from the initial state defined in the planning problem and stops when a state that satisfies the goal has been found. The search is performed as a graph search, i.e. a test for repeated states is performed to avoid multiple exploration of equal states reached via different paths. The heuristic used simply counts the number of unachieved goal conditions and this is obviously not an admissible heuristic. For a more detailed and theoretical description of the algorithm see Ghallab, Nau and Traverso. Automated Planning: Theory and Practice, section 4.2.

Author:
Gerhard Wickler

Field Summary
protected  Problem problem
          the planning problem to be solved by this planner
 
Constructor Summary
ForwardSearchPlanner(Problem problem)
           This constructor creates a new ForwardSearchPlanner for the given planning Problem.
 
Method Summary
protected  java.lang.Object clone()
           This class does not support cloning and an Exception will be thrown if this method is called.
 SequentialPlan doPlanSearch()
           This function will search for a solution to the given planning Problem.
 ai.search.informed.BestFirstSearcherForIntCostFn getSearchEngine()
           This function returns the SearchEngine (a BestFirstSearcherForIntCostFn) that is used by this planner to perform the search for the next plan.
 int hashCode()
           This function returns the hash code for the problem provided at construction time.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

problem

protected final Problem problem
the planning problem to be solved by this planner

Constructor Detail

ForwardSearchPlanner

public ForwardSearchPlanner(Problem problem)

This constructor creates a new ForwardSearchPlanner for the given planning Problem. A limited amount of configuration can be done by using the function getSearchEngine() and configuring the search engine. The search for a plan is then started with the function doPlanSearch().

The following code can be used to generate and print all the solutions for a given planning problem, which is passed to the constructor of the planner. Before planning begins, the underlying SearchEngine may be configured, as shown in the example. Here, tracing is switched on. The loop then searches for a plan until the returned value is null, indicating there are no more plans. Note that plans need to be assigned to a NameSpace (even null) before they can be printed.

 ForwardSearchPlanner planner = new ForwardSearchPlanner(problem);
 planner.getSearchEngine().setTraceStream(System.out);
 
 SequentialPlan plan;
 while ((plan = planner.doPlanSearch()) != null) {
         plan.assignTo(null);
         System.out.println("Solution plan: " + plan.toString());
 }
 System.out.println("no more plans!");
 

Parameters:
problem - the planning Problem to be solved by this planner
Method Detail

clone

protected java.lang.Object 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

doPlanSearch

public SequentialPlan doPlanSearch()

This function will search for a solution to the given planning Problem. If a solution is found, it will be returned as a SequentialPlan. Calling doPlanSearch again will continue the search to find another solution plan. When no more plans can be found the function will return null.

Specified by:
doPlanSearch in interface Planner<ai.krr.propositions.Atom>
Returns:
the next plan found (or null for no more plans)

getSearchEngine

public ai.search.informed.BestFirstSearcherForIntCostFn getSearchEngine()

This function returns the SearchEngine (a BestFirstSearcherForIntCostFn) that is used by this planner to perform the search for the next plan. Configuring this search engine directly effects the way this planner works.

Returns:
the BestFirstSearcherForIntCostFn used to search for plans

hashCode

public int hashCode()

This function returns the hash code for the problem provided at construction time.

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