com.neatech.climbplan.activityplanner
Class SearchAlgorithm

java.lang.Object
  extended by com.neatech.climbplan.activityplanner.SearchAlgorithm
Direct Known Subclasses:
AStarSearchAlgorithm

public abstract class SearchAlgorithm
extends Object


Field Summary
private  List<ChangeListener> changeListeners
           
protected  Hashtable<Integer,Node> closedList
           
protected  Node startNode
           
 
Constructor Summary
SearchAlgorithm()
           
 
Method Summary
 void addChangeListener(ChangeListener changeListener)
           
private  void constructPath(List<Node> path, Node node)
           
protected abstract  boolean empty()
           
protected abstract  void insert(Node node)
          Inserts a node into the fringe
protected abstract  void insertAll(List<Node> nodes)
          Inserts a set of nodes into the fringe
protected abstract  boolean isClosed(Node node)
           
protected  void notifyChangeListeners()
           
abstract  double progress()
          Returns the progress of the algorithm.
 void removeChangeListener(ChangeListener changeListener)
           
protected abstract  Node removeFirst()
           
protected abstract  void reset()
          Resets the algorithm by clearing the state
 List<Node> search(Node startNode)
          Implements the generic tree search algorithm.
protected  List<Node> solution(Node node)
          Called when the search is complete.
protected abstract  void visit(Node node)
          Called when the node is visited by the algorithm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

changeListeners

private List<ChangeListener> changeListeners

closedList

protected Hashtable<Integer,Node> closedList

startNode

protected Node startNode
Constructor Detail

SearchAlgorithm

public SearchAlgorithm()
Method Detail

reset

protected abstract void reset()
Resets the algorithm by clearing the state


empty

protected abstract boolean empty()
Returns:
true if there are no more elements in the fringe

removeFirst

protected abstract Node removeFirst()
Returns:
the first element of the fringe

insert

protected abstract void insert(Node node)
Inserts a node into the fringe

Parameters:
node - to be inserted

insertAll

protected abstract void insertAll(List<Node> nodes)
Inserts a set of nodes into the fringe

Parameters:
nodes - to be inserted

visit

protected abstract void visit(Node node)
Called when the node is visited by the algorithm

Parameters:
node - to be visited

isClosed

protected abstract boolean isClosed(Node node)
Parameters:
node - is checked whether it is closed or not
Returns:
true if the node is closed

solution

protected List<Node> solution(Node node)
Called when the search is complete.

Parameters:
node - is the target if there is a solution otherwise null

constructPath

private void constructPath(List<Node> path,
                           Node node)

progress

public abstract double progress()
Returns the progress of the algorithm.

Returns:
a value in the range [0.0,1.0] indicating the current progress of the algorithm

search

public List<Node> search(Node startNode)
Implements the generic tree search algorithm. Subclasses modify the behavior by overriding abstract methods.

Parameters:
startNode - is the initial node

notifyChangeListeners

protected void notifyChangeListeners()

addChangeListener

public void addChangeListener(ChangeListener changeListener)

removeChangeListener

public void removeChangeListener(ChangeListener changeListener)