Algorithm
Development Kit 1.0

algs.model.searchtree
Class Solution

java.lang.Object
  extended by algs.model.searchtree.Solution

public class Solution
extends java.lang.Object

Records the solution for a search from an initial state to a solved goal state. In some search algorithms, the goal state is known in advance; in others, it is discovered as the search progresses. Upon a completed search, the set of moves can be recovered.

Since:
1.0
Version:
1.0, 6/15/08
Author:
George Heineman

Field Summary
 INode goal
          Goal node.
 INode initial
          Initial node.
 
Constructor Summary
Solution(INode initial, INode goal)
          Build the solution and work backwards without a debugger.
Solution(INode initial, INode goal, boolean success)
          Build the solution and work backwards without a debugger.
Solution(INode initial, INode goal, IDebugSearch debug)
          Build the solution and work backwards with a debugger.
Solution(INode initial, INode goal, IDebugSearch debug, boolean success)
          Build solution with success or not.
 
Method Summary
 DoubleLinkedList<IMove> moves()
          Sequence of moves that achieve the goalState.
 int numMoves()
          Number of moves in the solution.
 boolean succeeded()
          Was this a successful solution?
 java.lang.String toString()
          Return solution as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

initial

public final INode initial
Initial node.


goal

public final INode goal
Goal node.

Constructor Detail

Solution

public Solution(INode initial,
                INode goal,
                IDebugSearch debug)
Build the solution and work backwards with a debugger.

Parameters:
initial - initial state
goal - final state
debug - entity to help generate debug output

Solution

public Solution(INode initial,
                INode goal)
Build the solution and work backwards without a debugger.

Parameters:
initial - initial state
goal - final state

Solution

public Solution(INode initial,
                INode goal,
                boolean success)
Build the solution and work backwards without a debugger.

Parameters:
initial - initial state
goal - final state
success - was this a successful search?

Solution

public Solution(INode initial,
                INode goal,
                IDebugSearch debug,
                boolean success)
Build solution with success or not.

Parameters:
initial - initial state
goal - final state
debug - entity to help generate debug output
success - was this a successful search?
Method Detail

moves

public DoubleLinkedList<IMove> moves()
Sequence of moves that achieve the goalState.


succeeded

public boolean succeeded()
Was this a successful solution?


numMoves

public int numMoves()
Number of moves in the solution.


toString

public java.lang.String toString()
Return solution as a string.

Overrides:
toString in class java.lang.Object

Algorithm Development Kit 1.0

This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.