net.sourceforge.jsl
Class AbstractOpenClosedListSearch

java.lang.Object
  |
  +--net.sourceforge.jsl.AbstractOpenClosedListSearch
All Implemented Interfaces:
Search
Direct Known Subclasses:
AbstractScoringSearch, BreadthFirstSearch, DepthFirstSearch

public abstract class AbstractOpenClosedListSearch
extends Object
implements Search

Abstract base class for a search that works using open and closed list for nodes already searched and nodes still to be processed.


Field Summary
protected  Collection closedList
           
protected  boolean closeGoal
           
protected  int expandCnt
           
protected  boolean expandGoal
           
protected  int maxClosed
           
protected  int maxDepth
           
protected  int maxExpands
           
protected  int maxOpen
           
protected  List openList
           
protected  SearchNode seed
           
protected  boolean useHashSet
           
 
Constructor Summary
AbstractOpenClosedListSearch()
           
 
Method Summary
protected  void checkForEmergencyStop()
           
protected  boolean cutOff(SearchNode searchNode)
           
protected  void expand(SearchNode searchNode)
           
 Collection getClosedList()
          Returns the unordered list of nodes already searched.
 boolean getCloseGoal()
           
 boolean getExpandGoal()
          Returns whether nodes that have been identified as goals shall be expanded and its successor be added to the open list.
 int getMaxClosed()
           
 int getMaxDepth()
           
 int getMaxExpands()
           
 int getMaxOpen()
           
 List getOpenList()
          Returns the list of open nodes yet to be searched in order in which they are scheduled for processing.
 SearchNode search()
          Searches for the search node that is marked as a goal and returns it.
 Collection search(int maxGoals)
          Searches for search nodes marked as a goal and returns them.
 void setCloseGoal(boolean closeGoal)
           
 void setExpandGoal(boolean expandGoal)
          Sets whether nodes that have been identified as goals shall be expanded and its successor be added to the open list.
 void setMaxClosed(int maxClosed)
           
 void setMaxDepth(int maxDepth)
           
 void setMaxExpands(int maxExpands)
           
 void setMaxOpen(int maxOpen)
           
 void setSeed(SearchNode seed)
          Sets the seed of the search, i.e. the root node of the search.
 void setUseHashSet(boolean useHashSet)
          Determines whether nodes in the closed list shall be stored using a HashSet.
protected abstract  void writeState(SearchNode state)
           
protected abstract  void writeStates(Collection states)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

seed

protected SearchNode seed

maxDepth

protected int maxDepth

maxExpands

protected int maxExpands

maxClosed

protected int maxClosed

maxOpen

protected int maxOpen

expandCnt

protected int expandCnt

openList

protected List openList

closedList

protected Collection closedList

expandGoal

protected boolean expandGoal

closeGoal

protected boolean closeGoal

useHashSet

protected boolean useHashSet
Constructor Detail

AbstractOpenClosedListSearch

public AbstractOpenClosedListSearch()
Method Detail

setSeed

public void setSeed(SearchNode seed)
Description copied from interface: Search
Sets the seed of the search, i.e. the root node of the search.

Specified by:
setSeed in interface Search
Parameters:
seed - the root node of the search

search

public Collection search(int maxGoals)
                  throws SearchException
Description copied from interface: Search
Searches for search nodes marked as a goal and returns them. The search stops either when there are no nodes left to process or the maximum number of goals are reached.

Specified by:
search in interface Search
Parameters:
maxGoals - the maximum number of goals to search for.
Returns:
a collection of all goal nodes found; if no goals have been found an empty collection is returned
Throws:
SearchException - signals an abnormal termination of the search

search

public SearchNode search()
                  throws SearchException
Description copied from interface: Search
Searches for the search node that is marked as a goal and returns it.

Specified by:
search in interface Search
Returns:
the first goal search node found or null if none was found
Throws:
SearchException - signals an abnormal termination of the search

getClosedList

public Collection getClosedList()
Returns the unordered list of nodes already searched.

Returns:
the list of closed nodes

getOpenList

public List getOpenList()
Returns the list of open nodes yet to be searched in order in which they are scheduled for processing.

Returns:
the list of open nodes

setUseHashSet

public void setUseHashSet(boolean useHashSet)
Determines whether nodes in the closed list shall be stored using a HashSet. If this feature is turned on (default) Object.hashCode() must be implemented properly in the custom SearchNode implementation.

Parameters:
useHashSet - true if a HashSet shall be used to store the closed list, false to use an ArrayList

getExpandGoal

public boolean getExpandGoal()
Returns whether nodes that have been identified as goals shall be expanded and its successor be added to the open list.

Returns:
true if goals will be expanded, false otherwise

setExpandGoal

public void setExpandGoal(boolean expandGoal)
Sets whether nodes that have been identified as goals shall be expanded and its successor be added to the open list.

Parameters:
expandGoal - true if goals will be expanded, false otherwise

getMaxDepth

public int getMaxDepth()

setMaxDepth

public void setMaxDepth(int maxDepth)

getMaxClosed

public int getMaxClosed()

getMaxExpands

public int getMaxExpands()

getMaxOpen

public int getMaxOpen()

setMaxClosed

public void setMaxClosed(int maxClosed)

setMaxExpands

public void setMaxExpands(int maxExpands)

setMaxOpen

public void setMaxOpen(int maxOpen)

getCloseGoal

public boolean getCloseGoal()

setCloseGoal

public void setCloseGoal(boolean closeGoal)

expand

protected void expand(SearchNode searchNode)
               throws SearchException
SearchException

writeState

protected abstract void writeState(SearchNode state)

writeStates

protected abstract void writeStates(Collection states)

checkForEmergencyStop

protected void checkForEmergencyStop()
                              throws SearchException
SearchException

cutOff

protected boolean cutOff(SearchNode searchNode)


Copyright © 2003-2004 Henrik Heine, Oliver Zeigermann. All Rights Reserved.