Heuristic
Heuristic
Heuristic
Informed Search
24 January 2024 5
24 January 2024 6
Greedy best-first search
• Greedy best-first search tries to expand the node that is
closest to the goal, on the grounds that this is likely to lead to a
solution quickly.
• It evaluates nodes by using just the heuristic function; that is,
f(n) = h(n).
• For route-finding problems in Romania; we use the straight
line distance as heuristic, which is hSLD.
• If the goal is Bucharest, we need to know the straight-line
distances to Bucharest from any node say, n.
• For example, hSLD(Arad) = 366.
Greedy best-first search
Hence f(G2) > f(n), and A* will never select G2 for expansion
Each equation has to satisfy its condition to have an admissible heuristic.
If one of them is not admissible, then we say that it is not an admissible
heuristic.
Maintain a closed-list containing those nodes that have already been
expanded. Then, if a node is encountered that is already in closed-list, it is
simply ignored
This guarantees that no loops are generated, and essentially converts the
graph
24 January 2024into a tree 20
• Its very well to prune the search space by ignoring
repeated states
• But the problem is that Graph-search can end up
discovering sub-optimal solutions
– Basically, a loop means that there might be more then
one path to a node
– Once we discover a path to a node, then any other
paths to the same node are ignored by graph-search
– However, it is not necessary that the first path is the
optimal one
– Hence, sub-optimal solutions can be returned.
24 January 2024 21
• Solution?
– We can adopt a uniform-cost approach, in which
we keep track of all the paths that have been
currently generated
– Then, we select only that path which has the
least-cost.
24 January 2024 22
• A heuristic is consistent if for every node n, every successor n' of n
generated by any action a,
h(n) ≤ c(n,a,n') + h(n')
• If h is consistent,
f(n') = g(n') + h(n')
= g(n) + c(n,a,n') + h(n')
≥ g(n) + h(n)
≥ f(n)
• Inside the contour labeled 400, all nodes have f(n) less than or equal
to 400,
• With uniform-cost search (A* search using h(n) = 0), the bands will
be “circular” around the start state.
• With more accurate heuristics, the bands will stretch toward the
goal state and become more narrowly focused around the optimal
path.
Any consistent heuristic is also admissible. But when is a
heuristic admissible but not consistent (monotone)?
Since this graph is undirected, this heuristic is also inconsistent at c2, because
going from c2 to p has the same problem.
The classic heuristic for this problem (Manhattan distance of each tile to
the location where it is supposed to be) is admissible and consistent.
Checking Monotonicity
If one of the equations is not satisfied, then the heuristic is not monotonic.
• If C* is the cost of the optimal solution path, then we can say
the following:
• A* expands all nodes with f(n) < C*.
• The simplest model studied is a state space that has a single goal
and is essentially a tree with reversible actions.
• At each iteration, the cutoff value is the smallest f-cost of any node
that exceeded the cutoff on the previous iteration.
• IDA* is practical for many problems with unit step costs and avoids
the substantial overhead associated with keeping a sorted queue of
nodes.
Recursive best-first search (RBFS)
• RBFS structure is similar to that of a recursive depth-first search,
but rather than continuing indefinitely down the current path, it uses
the f limit variable to keep track of the f-value of the best alternative
path available from any ancestor of the current node.
• If the current node exceeds this limit, the recursion unwinds back to
the alternative path.
• As the recursion unwinds, RBFS replaces the f-value of each node
along the path with a backed-up value—the best f-value of its
children.
• In this way, RBFS remembers the f-value of the best leaf in the
forgotten subtree and can therefore decide whether it’s worth
reexpanding the subtree at some later time.
Heuristic search Problems
The average solution cost for a randomly generated 8-puzzle instance is about 22 steps with
branching factor is about 3.
This means that an exhaustive tree search to depth 22 would look at about 322 ≈ 3.1×1010
states.
A graph search would cut this down to 181, 440 distinct states, which is manageable
• h1 = the number of misplaced tiles
• All of the eight tiles are out of position, so the start state would
have h1= 8.
• h1 is an admissible heuristic because it is clear that any tile
that is out of place must be moved at least once.