Professional Documents
Culture Documents
4 Informed Search and Exploration
4 Informed Search and Exploration
1 TABLE OF CONTENTS
2 Informed (Heuristic) Search Strategies ................................................................................................................ 1
3 Greedy best-first search ....................................................................................................................................... 1
4 A* Search, Heuristic Functions ............................................................................................................................. 3
5 Heuristic Functions ............................................................................................................................................... 4
5.1 Example: 8-Puzzle......................................................................................................................................... 4
6 Local Search Algorithms and Optimization Problems .......................................................................................... 4
6.1 Hill-climbing search ...................................................................................................................................... 5
6.1.1 8-queens problem ................................................................................................................................ 6
6.1.2 Problems .............................................................................................................................................. 6
The general approach we will consider is called best-first search. Best-first search is an instance of the general
TREE-SEARCH or GRAPH-SEARCH algorithm in which a node is selected for expansion based on an evaluation
function, f (n).
Traditionally, the node with the lowest evaluation is selected for expansion.
Best-first search can be implemented within our general search framework via a priority queue.
The name "best-first search' is a venerable but inaccurate one. After all, if we could really expand the
best node first, it would not be a search at all; it would be a straight march to the goal.
All we can do is choose the node that appears to be best according to the evaluation function.
h() = estimated cost of the cheapest path from node to a goal node.
Greedy Best-First search tries to expand the node that is closest to the goal assuming it will lead to a
solution quickly
o f(n) = h(n)
o aka “Greedy Search”
Implementation
o expand the “most desirable” node into the fringe queue
o sort the queue in decreasing order of desirability
g(n) = cost from the initial state to the current state n
h(n) = estimated cost of the cheapest path from node n to a goal node
f(n) = evaluation function to select a node for expansion (usually the lowest cost node)
The progress of a greedy best-first search using to find a path from Arad to Bucharest. The first node to be
expanded from Arad will be Sibiu, because it is closer to Bucharest than either Zerind or Timisoara. The next node
to be expanded will be because it is closest. in turn generates Bucharest, which is the goal. For this particular
problem, greedy best-first search using finds a solution without ever expanding a node that is not on the solution
path; hence, its search cost is minimal. It is not optimal, however: the path via Sibiu and to Bucharest is 32
kilometers longer than the path through Rimnicu Vilcea and Pitesti. This shows why the algorithm is called
"greedy2'-at each step it tries to get as close to the goal as it can.
Complete - No, GBFS can get stuck in loops (e.g. bouncing back and forth between cities)
Time - O(bm) but a good heuristic can have dramatic improvement
Space - O(bm) – keeps all the nodes in memory
Optimal - No!
4 A* SEARCH, HEURISTIC FUNCTIONS
In computer science, A* is a computer algorithm that is widely used in pathfinding and graph traversal, which is
the process of finding a path between multiple points, called "nodes". It enjoys widespread use due to its
performance and accuracy.
Complete
o Yes, unless there are infinitely many nodes with f <= f(G)
Time
o Exponential in [relative error of h x length of soln]
o The better the heuristic, the better the time
o Best case h is perfect, O(d)
o Worst case h = 0, O(bd) same as BFS
Space
o Keeps all nodes in memory and save in case of repetition
o This is O(bd) or worse
o A* usually runs out of space before it runs out of time
Optimal
o Yes, cannot expand fi+1 unless fi is finished
5 HEURISTIC FUNCTIONS
The heuristic function is a way to inform the search about the direction to a goal. It provides an informed way to
guess which neighbor of a node will lead to a goal. There is nothing magical about a heuristic function.
To use A* a heuristic function must be used that never overestimates the number of steps to the goal
h2=the sum of the Manhattan distances of the tiles from their goal positions
h1 = 7
h2 = 4+0+3+3+1+0+2+1 = 14
If h2(n) > h1(n) for all n (both admissible) then h2(n) dominates h1(n) and is better for the search
When a goal is found, the path to that goal also constitutes a solution to the problem.
If the path to the goal does not matter, we might consider a different class of algorithms, ones that do
not worry about paths at all. Local search algorithms operate using a single current state (rather than
multiple paths) and generally move only to neighbors of that state.
In addition to finding goals, local search algorithms are useful for solving pure problems, in which the aim
is to find the best state according to an objective function.
Hill climbing is sometimes called greedy local because it grabs a good neighbor state without
thinking ahead about where to go next.
Local Maximum: Local maximum is a state which is better than its neighbor states, but there is
also another state which is higher than it.
Global Maximum: Global maximum is the best possible state of state space landscape. It has the
highest value of objective function.
Current state: It is a state in a landscape diagram where an agent is currently present.
Flat local maximum: It is a flat space in the landscape where all the neighbor states of current
states have the same value.
Shoulder: It is a plateau region which has an uphill edge.
6.1.1 8-queens problem
The eight queens puzzle is the problem of
placing eight chess queens on an 8×8 chessboard
so that no two queens threaten each other; thus,
a solution requires that no two queens share the
same row, column, or diagonal.
6.1.2 Problems
Local maxima
Ridges and alleys
Plateau
If the target function creates a narrow ridge then the hill climber can only ascend the
ridge.
Thus, it may take an unreasonable length of time for it to ascend the ridge (or descend
the alley).
6.1.2.3 Plateau
Another problem that sometimes occurs with hill climbing is that of a plateau. A plateau
is encountered when the search space is flat