We have seen how breadth-first
state space search
can take the place of breadth-first
graph search when generating optimal, that is, shortest-length,
solutions to problems like the 8-puzzle (see results in menu).
However, breadth-first state space search has limitations when applied
to more complex problems like the 15-puzzle, whose search results (see
menu) show the algorithm running out of memory on just the 3rd
benchmark.
This is because breadth-first state space search, like breadth-first
graph search, requires a queue whose size is
exponential
in the depth of the search.
To address this, we describe a search method that
exploits
knowledge of the problem domain.
A* search is implemented by an
AStarSolver class that makes a
simple change to the
Comparator object used by the priority
queue in the
BestFirstSolver constructor.
This simple change is left to the student.
A UML diagram can be seen from the menu, along with
a template listing of
AStarSolver.java
Also shown are performance results for A* search. Note that
the solutions found are optimal, but the fourth 15-Puzzle benchmark
runs out of memory, as the priority queue grows too large.