SciLib.AI.Search
Class TreeSearch

java.lang.Object
  extended by SciLib.AI.Search.TreeSearch

public class TreeSearch
extends java.lang.Object

This class contains some methods to handle the searching problems


Field Summary
protected  SearchNode goal
           
protected  int round
           
protected  SearchNode start
           
protected  int step
           
 
Constructor Summary
TreeSearch(SearchNode start, SearchNode goal)
           
 
Method Summary
 SearchNode AStar(Application app, boolean detail)
          implements A* search algorithm
 java.util.LinkedList<SearchNode> BDS(Application app, boolean detail)
          implements Bidirectional search algorithm
 SearchNode BFS(Application app)
          implements breadth-first search algorithm
 SearchNode BFS(Application app, boolean detail)
          implements breadth-first search algorithm
 int[] commonElement(java.util.LinkedList<SearchNode> list1, java.util.LinkedList<SearchNode> list2, Application app)
          check if two lists are not disjoint
 SearchNode DFS(Application app, boolean detail)
          implements depth-first search algorithm
 SearchNode DLS(Application app, int limit, boolean detail)
          implements depth-limited search algorithm
 int getRounds()
          get rounds
 int getSteps()
          get steps
 SearchNode HillClimbing(Application app)
          implements Hill-Climbing algorithm
 SearchNode HillClimbing(Application app, int roundLimit)
          implements Hill-Climbing algorithm
 SearchNode IDAStar(Application app, boolean detail)
          implements IDA*-search algorithm
 SearchNode IDS(Application app, boolean detail)
          implements iterative-deepning search algorithm
 void initialState(SearchNode start)
          set start node
 boolean isElement(java.util.LinkedList<SearchNode> list, SearchNode n, Application app)
          check if a node belongs to a list of nodes
 Result RDFS(Application app)
          implements RDFS-search algorithm
 void setGoal(SearchNode goal)
          set goal node
 SearchNode SimulatedAnnealing(Application app, Scheduler scheduler)
          implements Simulated-Annealing algorithm
 SearchNode SimulatedAnnealing(Application app, Scheduler scheduler, int roundLimit)
          implements Simulated-Annealing algorithm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

step

protected int step

round

protected int round

start

protected SearchNode start

goal

protected SearchNode goal
Constructor Detail

TreeSearch

public TreeSearch(SearchNode start,
                  SearchNode goal)
Method Detail

getSteps

public int getSteps()
get steps

Returns:
the number of expanded nodes

getRounds

public int getRounds()
get rounds

Returns:
the number of rounds before the search is stopped

initialState

public void initialState(SearchNode start)
set start node

Parameters:
start - the initial state node

setGoal

public void setGoal(SearchNode goal)
set goal node

Parameters:
goal - the goal state node

BFS

public SearchNode BFS(Application app)
implements breadth-first search algorithm

Parameters:
app - Application interface
Returns:
the result search node

BFS

public SearchNode BFS(Application app,
                      boolean detail)
implements breadth-first search algorithm

Parameters:
app - Application interface
detail - the option to show each step when searching
Returns:
the result search node

isElement

public boolean isElement(java.util.LinkedList<SearchNode> list,
                         SearchNode n,
                         Application app)
check if a node belongs to a list of nodes

Parameters:
list - the list of nodes
n - a SearchNode for checking
app - Application interface
Returns:
a boolean

commonElement

public int[] commonElement(java.util.LinkedList<SearchNode> list1,
                           java.util.LinkedList<SearchNode> list2,
                           Application app)
check if two lists are not disjoint

Parameters:
list1 - the list1 of nodes
list2 - the list2 of nodes
app - Application interface
Returns:
a commonNode

DFS

public SearchNode DFS(Application app,
                      boolean detail)
implements depth-first search algorithm

Parameters:
app - Application interface
detail - the option to show each step when searching
Returns:
the result search node

DLS

public SearchNode DLS(Application app,
                      int limit,
                      boolean detail)
implements depth-limited search algorithm

Parameters:
app - Application interface
limit - the depth limit for searching
detail - the option to show each step when searching
Returns:
the result search node

IDS

public SearchNode IDS(Application app,
                      boolean detail)
implements iterative-deepning search algorithm

Parameters:
app - Application interface
detail - the option to show each step when searching
Returns:
the result search node

BDS

public java.util.LinkedList<SearchNode> BDS(Application app,
                                            boolean detail)
implements Bidirectional search algorithm

Parameters:
app - Application interface
detail - the option to show each step when searching
Returns:
the linked list of the search result

AStar

public SearchNode AStar(Application app,
                        boolean detail)
implements A* search algorithm

Parameters:
app - Application interface
Returns:
the result search node

IDAStar

public SearchNode IDAStar(Application app,
                          boolean detail)
implements IDA*-search algorithm

Parameters:
app - Application interface
Returns:
the result search node

RDFS

public Result RDFS(Application app)
implements RDFS-search algorithm

Parameters:
app - Application interface
Returns:
the result object, Result

HillClimbing

public SearchNode HillClimbing(Application app)
implements Hill-Climbing algorithm

Parameters:
app - Application interface
Returns:
the result search node

HillClimbing

public SearchNode HillClimbing(Application app,
                               int roundLimit)
implements Hill-Climbing algorithm

Parameters:
app - Application interface
roundLimit - The maximum number of rounds, an integer
Returns:
the result search node

SimulatedAnnealing

public SearchNode SimulatedAnnealing(Application app,
                                     Scheduler scheduler)
implements Simulated-Annealing algorithm

Parameters:
app - Application interface
scheduler - the scheduler for annealing process
Returns:
the result search node

SimulatedAnnealing

public SearchNode SimulatedAnnealing(Application app,
                                     Scheduler scheduler,
                                     int roundLimit)
implements Simulated-Annealing algorithm

Parameters:
app - Application interface
scheduler - the scheduler for annealing process
roundLimit - The maximum number of rounds, an integer
Returns:
the result search node