Graph and Search Tree.pps

EA C461 – Artificial Intelligence
EA C461 – Artificial Intelligence
To Discuss
• Uninformed Search Strategies
( Breadth First Search, Uniform Cost Search, Depth
First Search, Depth Limited Search, Iterative
Deepening Search, Bidirectional Search )
• Handling Partial Information
• Informed Search Strategies
(Best First Search, Greedy Best First Search, A* Search,
Memory Bounded Heuristic Search )
EA C461 – Artificial Intelligence
Iterative deepening search
EA C461 – Artificial Intelligence
Iterative deepening search l =0
EA C461 – Artificial Intelligence
Iterative deepening search l =1
EA C461 – Artificial Intelligence
Iterative deepening search l =2
EA C461 – Artificial Intelligence
Iterative deepening search l =3
EA C461 – Artificial Intelligence
Iterative deepening search
N(IDS) = (d) (b) + (d-1) (b2) + (d-2) (b3) + (d-3) (b4) + (d-4) (b5) + …+(bd)
N(BFS) = b + b2 + b3 + b4 + …+ bd + (bd+1 b)
For b=10, d=5
N(IDS) = 50 + 400 + 3000 + 20,000 + 100,00 = 123,450
N(BFS) = 10 + 100 + 1000 + 10,000 + 100,000 + 999,990 = 1,111,100
IDS is the preferred uninformed search method when there is a
large search space, and the depth is unknown
EA C461 – Artificial Intelligence
Iterative deepening search
• For b = 10, d = 5,
– NDLS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111
– NIDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 = 123,456
• Overhead = (123,456 - 111,111)/111,111 = 11%
EA C461 – Artificial Intelligence
Properties of iterative deepening search
•
•
•
•
Complete? Yes
Time? (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd)
Space? O(bd)
Optimal? Yes, if step cost = 1
EA C461 – Artificial Intelligence
Summary of algorithms
EA C461 – Artificial Intelligence
bidirectional search
d
d/2
d/2
Time ~ bd/2 + bd/2 < bd
EA C461 – Artificial Intelligence
Repeated states
• Failure to detect repeated states can turn a linear
problem into an exponential one!
EA C461 – Artificial Intelligence
Graph search
EA C461 – Artificial Intelligence
Searching with Partial Information
• Sensorless Problems (Conformant problems)
• Contingency Problems
• Exploration Problems
EA C461 – Artificial Intelligence
Summary
• Problem formulation usually requires abstracting away
real-world details to define a state space that can feasibly
be explored
• Variety of uninformed search strategies
• Iterative deepening search uses only linear space and not
much more time than other uninformed algorithms
EA C461 – Artificial Intelligence
Informed Search Techniques
• Search
– Heuristic / Informed
• Uses additional information about nodes (heuristics) that
have not yet been explored to decide which nodes to
examine next
– Blind / Uninformed
• Assumes no additional information about the problem
• Heuristic function h (n) used in search provides
an estimate of the distance from any given node
to a goal node
EA C461 – Artificial Intelligence
Best First Search
• A node is selected for expansion based on an evaluation
function f(n)
– Choose the node which appears to be best while expanding
• Best First Search algorithms differs in the evaluation
function
– Evaluation function incorporate the problem specific knowledge
in the form of h(n)
– h(n)  heuristic function , a component of f(n)
 Estimated cost of cheapest path to the goal node
• h(n) = 0, if n is the goal node
• Greedy Best First Search, A* Search
EA C461 – Artificial Intelligence
Greedy best-first search
• Expands the node that is closest to the goal
• Consider route finding problem in Romania
– Use of hSLD, Straight Line Distance Heuristic
– Evaluation function f(n) = h(n) (heuristic), estimate of
cost from n to goal
• For the problem of finding route from Arad to
Burcharest…
EA C461 – Artificial Intelligence
Optimal Distance 140+80+97+101 = 418
EA C461 – Artificial Intelligence
Greedy best-first search
EA C461 – Artificial Intelligence
Greedy best-first search
EA C461 – Artificial Intelligence
Greedy best-first search
EA C461 – Artificial Intelligence
Greedy best-first search
EA C461 – Artificial Intelligence
Optimal Distance 140+80+97+101 = 418
EA C461 – Artificial Intelligence
Critics
• Minimizing f(n) is susceptible to false start
• Same issues with DFS
• Not optimal, Incomplete (may search an infinite
path)
• Performance depends problem and heuristic
• O(bm)  Worst case space needed
EA C461 – Artificial Intelligence
A* Search
• A better form of best-first search
• f(n)=g(n) + h(n)
– g(n) the cost to reach the node
– h(n) the estimated cost of the cheapest path from n
to the goal
– f(n)  the estimated cost of the cheapest solution
through the node n
• h(n)  Admissible Heuristic / Consistent (in
case of graph search)
EA C461 – Artificial Intelligence
A* search
EA C461 – Artificial Intelligence
A* search
EA C461 – Artificial Intelligence
A* search
EA C461 – Artificial Intelligence
A* search
EA C461 – Artificial Intelligence
A* search
EA C461 – Artificial Intelligence
A* search
EA C461 – Artificial Intelligence
A* Search : Admissible heuristics
• A heuristic h(n) is admissible if for every node n,
h(n) ≤ h*(n), where h*(n) is the true cost to reach
the goal state from n
• An admissible heuristic never overestimates the
cost to reach the goal, i.e., it is optimistic
• Example: hSLD(n) (never overestimates the actual
road distance)
• Theorem: If h(n) is admissible, A* using TREESEARCH is optimal
EA C461 – Artificial Intelligence
A* Search : Optimality of A* (proof)
• Suppose some suboptimal goal G2 has been generated
and is in the fringe. Let n be an unexpanded node in the
fringe such that n is on a shortest path to an optimal goal
G.
f(G2) = g(G2),
g(G2) > g(G),
f(G) = g(G),
f(G2) > f(G),
since h(G2) = 0
since G2 is suboptimal
since h(G) = 0
Hence f(G2) > f(n), and A* will never
from above
select G2 for expansion
EA C461 – Artificial Intelligence
A* Search: Repeated states
• Sub optimal solutions can be returned, if we
discard the optimal path to a repeated node
– Can be handled by keeping all nodes expanded in
memory, and when repeated make a decision based
on their costs
– Make Sure, repeated nodes are costlier
• Requires the heuristic to be consistent
EA C461 – Artificial Intelligence
A* Search : Consistent heuristics
• 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, we have
f(n') = g(n') + h(n')
= g(n) + c(n,a,n') + h(n')
≥ g(n) + h(n)
= f(n)
i.e., f(n) is non-decreasing along any path.
• Theorem: If h(n) is consistent, A* using GRAPH-SEARCH
is optimal
EA C461 – Artificial Intelligence
A* Characteristics
• A* expands no nodes with f(n)>C*
– These nodes are said to be pruned
– This pruning still guarantees optimality
• Expands nodes in the increasing order of costs
• A* is optimally efficient
– For a given heuristic, A* finds optimal solution with the fewest
number of nodes expansion
– Any algorithm that doesn’t expand nodes with f(n)<C* has the
risk of missing an optimal solution
• For most problems the number of nodes with costs lesser than
C* is exponential
EA C461 – Artificial Intelligence
Memory Bounded Heuristic Search
• Iterative-deepening A* (IDA*)
– uses f-value (g + h) as the cutoff
– Keep increase the cutoff for each iteration by the smallest
amount, in excess of the current cutoff
EA C461 – Artificial Intelligence
Recursive best-first search
• Keeps track of the f-value of the best-alternative path
available.
– If current f-values exceeds this alternative f-value than backtrack
to alternative path.
– Upon backtracking change f-value to best f-value of its children.
– Re-expansion of this result is thus still possible.
EA C461 – Artificial Intelligence
Recursive best-first search, ex.
EA C461 – Artificial Intelligence
Recursive best-first search, ex.
EA C461 – Artificial Intelligence
Recursive best-first search, ex.
EA C461 – Artificial Intelligence
RBFS evaluation
• RBFS is a bit more efficient than IDA*
– Still excessive node generation (mind changes)
• Like A*, optimal if h(n) is admissible
• Space complexity is O(bd).
– IDA* retains only one single number (the current f-cost
limit)
• Time complexity difficult to characterize
– Depends on accuracy if h(n) and how often best path
changes.
• IDA* en RBFS suffer from too little memory.
EA C461 – Artificial Intelligence
Consider a state space in which start state is
numbered 1 and the successor function for state n
returns two states, numbered 2n and 2n+1.
1. Draw the portion of the state space for states 1 to 15.
2. Suppose the goal state is 11. List the order in which
nodes will be visited for BFS, DFS, IDS.
3. Explain how do you apply Bidirectional search to
this problem
1. In that case, what is the branching factor in each direction
EA C461 – Artificial Intelligence