04 Informed Search
04 Informed Search
Informed Search If you are not enrolled in the class, and still
would like to be, come see me later
– There’s space for up to 35 students in the class
– That means 6 more seats, from the waiting list
Burr H. Settles
CS-540, UW-Madison
www.cs.wisc.edu/~cs540-1
Don’t be scared by Homework #1
Summer 2003
1 2
Several of you were confused about why we only find 12 Someone asked about why we might want to choose the
of the 20 possible states in yesterday’s water jug problem: BFS strategy over IDS
– They are both complete, optimal, and complexities of O(bd) for
00
fill(B)
04
pour(B,A)
31 00
fill(B)
04
pour(B,A)
31 time, but IDS has O(bd) for space
fill(A) dump(A) fill(A) fill(A) dump(A)
– It turns out, IDS has O(2×bd) time complexity
fill(B) – Recall that in “big-O” notation, we ignore linear factors, so in the
30 34 01 30 34 01 limit IDS is O(2×bd) → O(bd)
pour(A,B) pour(B,A) pour(B,A)
Yet someone else asked what search algorithms have to do We talked about building goal-based agents and
with AI… my answer: AI is all search!!
utility-based agents using search strategies
Even someone else pointed out that UCS appears to be
Dijkstra’s Algorithm, a famous example of dynamic But the strategies we discussed were uninformed
programming (DP)… and it is!!
– DP is a family of algorithms that are guaranteed to find optimal
because the agent is given nothing more than the
solutions for problems problem definition
– They work by breaking the problem up into sub-problems and
solving the simplest sub-problems first
– Other examples of DP are the Viterbi Algorithm, which is used in Today we’ll present informed search strategies
speech recognition software, and the CYK Algorithm, for finding
the most probable “parse tree” for natural language sentences
5 6
1
Searching in Large Problems Searching in Large Problems
The search space of a problem is generally Some problems’ search spaces are too large to
described in terms of the number of possible search efficiently using uninformed methods
states in the search:
Sometimes we have additional domain knowledge
Water Jug 12 states about the problem that we can use to inform the
Tic-Tac-Toe 39 states agent that’s searching
Rubik’s Cube 1019 states
100-variable SAT 1030 states
Chess 10120 states To do this, we use heuristics (informed guesses)
– Heuristic means “serving to aid discovery”
7 8
Best-first search is a generic informed Greedy search is the best-first search strategy,
search strategy that uses an evaluation with a simple evaluation function of f(n) = h(n)
function f(n), incorporating some kind of
domain knowledge It relies only on the heuristic to select what is
currently believed to be closest to the goal state
11 12
2
Greedy Search Example Greedy Search Issues
A Search is an informed strategy that incorporates Heuristic functions are good for helping us find
both the real costs and the heuristic functions to good solutions quickly
find better solutions
But it’s hard to design accurate heuristics!
– They can be expensive to compute
However, if our heuristic makes certain errors
– They can make errors estimating the costs
(e.g. estimating along the path to a goal):
– Still not complete
These problems keep informed searches like the
– Still not optimal
A search from being complete and optimal
17 18
3
Admissible Heuristics A* Search
There is hope! We can add a constraint on our When we conduct an A search using an
heuristic function that, for all nodes n in the search admissible heuristic, it is called A* search
space, h(n) h*(n)
– Where h*(n) is the true minimal cost from n to a goal
A* search is complete if
When h(n) h*(n), we say that h(n) is admissible – The branching factor is finite
– Every action has a fixed cost
Admissible heuristics are inherently optimistic,
(i.e. they never overestimate the cost to a goal) A* search is optimal
19 20
4
Devising Heuristics Devising Heuristics
25 26
27 28
Optimality isn’t always required (i.e. you So far we’ve discussed algorithms that try to find
want some solution, not the best solution) a path from the initial state to a goal state
– h(n) need not be admissible (necessarily)
– Greedy search will often suffice These are called partial search strategies because
– This is all problem-dependent, of course they build up partial solutions, which could
enumerate the entire search space to find solutions
Can result in fewer nodes being expanded, – This is OK for small “toy world” problems
and a solution can be found faster – This is not OK for NP-Complete problems or those
with exponential search spaces
29 30
5
Next Time
31