0% found this document useful (0 votes)
4 views

Module3 InformedSearch

Uploaded by

satya prakash
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Module3 InformedSearch

Uploaded by

satya prakash
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

MODULE 3:

INFORMED
SEARCH
Informed search strategies

■ Informed search strategy--one that uses problem-specific knowledge beyond


the definition of the problem itself-can find solutions more efficiently than an
uninformed strategy.
■ BEST-FIRST SEARCH: 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,
because the evaluation measures distance to the goal.
■ There is a whole family of BEST-FIRST-SEARCH algorithms with different
evaluation functions.' A key component of these algorithms is a heuristic function
denoted h(n):
■ h(n) = estimated cost of the cheapest path from node n to a goal node.
Greedy best-first search
Greedy best-first search3 tries to expand the node that is
closest to the goal, on the: grounds that this is likely to lead
to a solution quickly.
Evaluation function f(n) = h(n) (heuristic)= estimate of cost from n to goal

• e.g., hSLD(n) = straight-line distance from n to Bucharest

• Greedy best-first search expands the node that appears to be closest


to goal
Romania with step costs in km
Greedy best-first search- Route
finding problems in Romania
Straight line distance heuristic, Hsld
• If the goal is Bucharest, we need to know the straight-line distances to Bucharest

• Hsld is correlated with actual road distances and is, therefore, a useful heuristic
For example,
Hsld(In(Arad)=) 366. Notice that the values of Hsld cannot be computed from the
problem description itself. Moreover, it takes a certain amount of experience to know that
Hsld is correlated with actual road distances and is, therefore, a useful heuristic.
Greedy best-first search- Route
finding problem in Romania
Greedy best-first search- Route
finding problem in Romania
Properties of greedy best-first search
• Complete?
• No – can get stuck in loops, e.g., Iasi  Neamt  Iasi 
Neamt 
• Time?
• O(bm), but a good heuristic can give
dramatic improvement
• Space?
• O(bm) -- keeps all nodes in memory
• Optimal?
• No
A* search

■ The most widely-known form of best-first search is called A* search It evaluates


nodes by combining g(n),t he cost to reach the node, and h(n.),the cost to get
from the node to the goal:

Evaluation function: f(n) = g(n) + h(n)


g(n) = gives the path cost from the start node to node n,
h(n) = is the estimated cost of the cheapest path from n to the goal
f(n) = estimated cost of the cheapest solution through n
10
Problem 1

■ Where h(x) = heuristic value


■ g(x) = path cost
12
13
14
Iterative Deepening A* (IDA*)
■ IDA* combines the concepts of Iterative Deepening Search (IDS) and A*.
■ The simplest way to reduce memory requirements for A" is to adapt the idea
of iterative deepening to the heuristic search context, resulting in the
iterative-deepening A" (IDA*) algorithm.
■ Instead of using depth as the cutoff (as in regular iterative deepening),
– IDA* uses the f-cost 𝑓(𝑛)=𝑔(𝑛)+ℎ(𝑛).
– g(n): Cost from the start to node 𝑛. ℎ(𝑛): Estimated cost from 𝑛n to the
goal.
■ Initially, a cutoff value is set to the 𝑓-cost of the root node.
■ During each iteration: Nodes with 𝑓(𝑛)> current cutoff are skipped.
■ A new cutoff is set to the smallest 𝑓-cost of nodes that exceeded the
previous cutoff. The search continues until a solution is found.
Recursive Best-First Search
■(RBFS)
memory limit. It maintains the 𝑓-cost of the best alternative path available
RBFS uses recursion to mimic best-first search but operates within a fixed

(backup values) to decide whether to continue down a path or back track.


■ Keeps track of the best alternative path to explore if the current path becomes
too costly.

current 𝑓-cost limit, it backtracks and replaces the cost with the next best
■ The algorithm recursively explores the best child node. If a node exceeds the

alternative.
■ Advantages: Requires minimal memory (linear in the depth of the search
tree). Adapts well to problems with high branching factors.
■ Limitations:
– Can re-expand nodes multiple times (not as efficient as A* in terms of
time).
– Performance depends on the accuracy of the heuristic.
Stages in an RBFS

Stages in an RBFS search for the shortest route to Bucharest.


The f-limit value for each recursive call is shown on top of each current node.
(a) The path via Rimnicu Vilcea is followed until the current best leaf (Pitesti) has a
value that is worse than the best alternative path (Fagaras).
(b) The recursion unwinds and the best leaf value of the forgotten subtree (417) is
backed up to Rimnicu Vilcea; then Fagaras is expanded, revealing a best leaf value of
450.
(c) The recursion unwinds and the best leaf value of the forgotten subtree (450) is
backed up to Fagaras; then Rirnnicu Vilcea is expanded. This time, because the best
alternative path (through Timisoara) costs at least 447, the expansion continues to
Bucharest.
Memory-Bounded A* (MA*)
■ MA* is a memory-bounded variation of A*. When memory is exhausted, it
selectively removes nodes from memory while retaining enough
information to reconstruct paths later if needed..
■ Keeps a priority queue of nodes, like A*, but removes least-promising
nodes when memory is full.
■ Stores backup values of removed nodes to revisit them if necessary.
■ When memory is exhausted, MA* prunes nodes with the highest 𝑓-cost.
If the pruned node becomes relevant later, it can be recomputed using
the stored backup value.
■ Advantages: Efficient for large problems where full storage of the
search tree is impractical. Balances memory usage and search
completeness.
■ Limitations: May require additional computation to re compute pruned
nodes.
Heuristics Functions

8-puzzle search space


Typical solution length: 22 steps
Average branching factor: 3
Exhaustive tree search: 320 =~ 3.1 x 1010
states
Exhaustive Graph search: 9! = 3,62,880

How about for a 15 puzzle problem? Good


Admissible heuristics
■ Admissible heuristics are functions used in search algorithms,
especially in A*, that estimate the minimum cost to reach a goal
from a given state. For a heuristic h(n) to be admissible, it must
satisfy the following condition:
h(n) ≤ h∗(n)
where h∗(n) is the true minimum cost to reach the goal from node
n. This ensures that h(n)) never overestimates the actual cost,
which is why admissible heuristics are often called "optimistic."
Examples of Admissible
Heuristics
■ Straight-line Distance: In a route-planning problem, the straight-line
(Euclidean) distance between two points is admissible because the shortest
path cannot be longer than the straight-line distance.
■ Number of Tiles Misplaced: In the 8-puzzle or 15-puzzle, counting the
number of misplaced tiles compared to the goal state is admissible because
each misplaced tile represents at least one required move.
■ Manhattan Distance: For grid-based movement (e.g., in the 8-puzzle), the
Manhattan distance (sum of the horizontal and vertical moves required to
reach the goal) is admissible. It doesn’t overestimate because diagonal moves
aren’t allowed in this context.
■ Chebyshev Distance: In chess, for a king moving on a board, the Chebyshev
distance (maximum of horizontal and vertical distances) is admissible, as it
estimates the minimum moves needed without overestimating.
Admissible heuristics
E.g., for the 8-puzzle:

• h1(n) = number of misplaced tiles. In fig., all of the eight


tiles are out of position, so the start state would have h1
= 8.
• h2(n) = total Manhattan or City block distance
(i.e., no. of squares from desired location of each tile)

• h1(S) = ? 8
• h2(S) = ? 3+1+2+2+2+3+3+2 = 18
Performance of heuristics
• function
One way to characterize the quality of a heuristic is the
effective branching factor b∗

• If the total number of nodes generated by A∗ for a


particular problem is N and the solution depth is d,
then b∗ is the branching factor that a uniform tree of
depth d, given by
N = 1 + b* + (b*)2 + ...+ (b*)d

• To test the heuristic functions h1 and h2, 1200 random problems


were generated with solution lengths from 2 to 24 (100 for each
even number) and solved them with iterative deepening search
and with A∗ tree search using both h1 and h2.
Generating admissible heuristics
from Relaxed problems
• A problem with fewer restrictions on the actions is called a relaxed problem

• The cost of an optimal solution to a relaxed problem is an admissible


heuristic for the original problem

• If the rules of the 8-puzzle are relaxed so that a tile can move anywhere,
then h1(n) gives the shortest solution

• If the rules are relaxed so that a tile can move to any adjacent square,
then h2(n) gives the shortest solution

• The state-space graph of the relaxed problem is a supergraph of the


original state space because the removal of restrictions creates added
edges in the graph.
■ we can generate three relaxed problems by removing one or both
of the conditions:
(a) A tile can move from square A to square B if A is adjacent to B.
(b) A tile can move from square A to square B if B is blank.
(c) A tile can move from square A to square B.
■ From (a), we can derive (Manhattan distance). The reasoning is
that h2 would be the proper score if we moved each tile in turn to
its destination.
■ (b), we can derive hl (misplaced tiles), because it would be the
proper score if tiles could move to their intended destination in
one step.
Dominance
• If h2(n) ≥ h1(n) for all n (both admissible)
then h2 dominates h1
• h2 is better for search (in terms of
efficiency)
• Typical search costs (average number of node
expanded):
• d=12
A*(h1) = 227 nodes
A*(h2) = 73 nodes
• d=24
A*(h1) = 39,135 nodes
Generating admissible heuristics
from subproblems: Pattern
• Figure shows a subproblem of the 8-puzzle problem. The subproblem
involves getting tiles 1, databases
2, 3, 4 into their correct positions. Clearly, the
cost of the optimal solution of this subproblem is a lower bound on the
cost of the complete problem.

• The choice of 1-2-3-4 is fairly arbitrary; we could also construct


databases for 5-6-7-8, for 2-4-6-8, and so on. Each database yields an
admissible heuristic, and these heuristics can be combined

• The idea behind pattern databases is to store these exact solution


costs for every possible subproblem instance—in our example, every
possible configuration of the four tiles and the blank.
Learning heuristics from
• experience
"Experience" here means solving lots of 8-puzzles, for instance.
• Each example consists of a state from the solution path and the actual cost of the
solution from that point.
• For example, the feature "number of misplaced tiles" might be helpful in predicting
the actual distance of a state from the goal.
• Let's call this feature XI(n). We could take 100 randomly generated 8-puzzle
configurations and gather statistics on their actual solution costs. We might find
that when XI(n) is 5, the average solution cost is around 14, and so on.
• Given these data, the value of XI can be used to predict h(n).
• A second feature x2(n) might be "number of pairs of adjacent tiles that are also
adjacent in the goal state." How should XI (n) and X2(n) be combined to predict
h(n)?
• A common approach is to use a linear combination:

The constants cl and c2 are adjusted to give the best fit to the actual data on
solution costs.

You might also like