Title: Search: Heuristic
1Search Heuristic Optimal
- Artificial Intelligence
- CMSC 25000
- January 16, 2003
2Agenda
- Heuristic Search
- Local Hill-climbing, Beam Search
- Limitations of local heuristics
- Global Best first
- Optimal Search
- A search
- Admissible, consistent heuristics
- Dynamic programming
- Problem representation
- Configuration space
3Searches
- Blind search Find ANY path to goal
- Know something about search space
- Most paths reach goal or terminate quickly DFS
- Low branching factor, possible long paths BFS
- Always ready to act ID-DFS
4Heuristic Search
- A little knowledge is a powerful thing
- Order choices to explore better options first
- More knowledge gt less search
- Better search alg?? Better search space
- Measure of remaining cost to goal-heuristic
- E.g. actual distance gt straight-line distance
10.4
6.7
4.0
11.0
3.0
8.9
6.9
5Hill-climbing Search
- Select child to expand that is closest to goal
8.9
10.4
6.9
10.4
3.0
6.7
6Hill-climbing Search Algorithm
- Form a 1-element queue of 0 costroot node
- Until first path in queue ends at goal or no
paths - Remove 1st path from queue extend path one step
- Reject all paths with loops
- Sort new paths by estimated distance to goal
- Add new paths to FRONT of queue
- If goal foundgtsuccess else, failure
7Beam Search
- Breadth-first search of fixed width - top w
- Guarantees limited branching factor, E.g. w2
8Beam Search Algorithm
- Form a 1-element queue of 0 costroot node
- Until first path in queue ends at goal or no
paths - Extend all paths one step
- Reject all paths with loops
- Sort all paths in queue by estimated distance to
goal - Put top w in queue
- If goal foundgtsuccess else, failure
9Best-first Search
- Expand best open node ANYWHERE in tree
- Form a 1-element queue of 0 costroot node
- Until first path in queue ends at goal or no
paths - Remove 1st path from queue extend path one step
- Reject all paths with loops
- Put in queue
- Sort all paths by estimated distance to goal
- If goal foundgtsuccess else, failure
10Heuristic Search Issues
- Parameter-oriented hill climbing
- Make one step adjustments to all parameters
- E.g. tuning brightness, contrast, r, g, b on TV
- Test effect on performance measure
- Problems
- Foothill problem aka local maximum
- All one-step changes - worse!, but not global max
- Plateau problem one-step changes, no FOM
- Ridge problem all one-steps down, but not even
local max - Solution (local max) Randomize!!
11Search Costs
12Searches
- Heuristic search Any path, but find faster
- Estimate remaining distance to goal
- Best from current node Hill-climbing
- Best from any node Best first
- Best w at this depth Beam search
13Optimal Search
- Find BEST path to goal
- Find best path EFFICIENTLY
- Exhaustive search
- Try all paths return best
- Optimal paths with less work
- Expand shortest paths
- Expanded shortest expected paths
- Eliminate repeated work - dynamic programming
14Efficient Optimal Search
- Find best path without exploring all paths
- Use knowledge about path lengths
- Maintain path path length
- Expand shortest paths first
- Halt if partial path length gt complete path
length
15 Underestimates
- Improve estimate of complete path length
- Add (under)estimate of remaining distance
- u(total path dist) d(partial path)u(remaining)
- Underestimates must ultimately yield shortest
- Stop if all u(total path dist) gt d(complete path)
- Straight-line distance gt underestimate
- Better estimate gt Better search
- No missteps
16Search with Dynamic Programming
- Avoid duplicating work
- Dynamic Programming principle
- Shortest path from S to G through I is shortest
path from S to I plus shortest path from I to G - No need to consider other routes to or from I
17A Search Algorithm
- Combines good optimal search ideas
- Dynamic programming and underestimates
- Form a 1-element queue of 0 costroot node
- Until first path in queue ends at goal or no
paths - Remove 1st path from queue extend path one step
- Reject all paths with loops
- For all paths with same terminal node, keep only
shortest - Add new paths to queue
- Sort all paths by total length underestimate,
shortest first (d(partial path) u(remaining)) - If goal foundgtsuccess else, failure
18A Search Example
13.4
12.9
19Heuristics
- A search only as good as the heuristic
- Heuristic requirements
- Admissible
- UNDERESTIMATE true remaining cost to goal
- Consistent
- h(n) lt c(n,a,n') h(n')
- Some heuristics better than others
- 0?
20Constructing Heuristics
- Relaxation
- State problem
- Remove one or more constraints
- What is the cost then?
- Example
- 8-square Move A to B if
- 1) A B horizontally or vertically adjacent, and
- 2) B is empty
- Ignore 1) -gt Manhattan distance
- Ignore 1) 2) of misplaced squares
21Navigation
22Application Configuration Space
- Problem Robot navigation
- Move robot between two objects without changing
orientation - Possible?
- Complex search space boundary tests, etc
- First step Problem transformation
- Model robot as point
- Model obstacles by combining their perimeter
path of robot around it - Configuration Space simpler search
23Navigation
24Navigation
25Navigation as Simple Search
- Replace funny robot shape in field of funny
shaped obstacles with - Point robot in field of configuration shapes
- All movement is
- Start to vertex, vertex to vertex, or vertex to
goal - Search Start, vertices, goal, connections
- A search yields efficient least cost path
26Online Search
- Offline search
- Think a lot, then act once
- Online search
- Think a little, act, look, think,..
- Necessary for exploration, (semi)dynamic env
- Components Actions, step-cost, goal test
- Compare cost to optimal if env known
- Competitive ratio (possibly infinite)
27Online Search Agents
- Exploration
- Perform action in state -gt record result
- Search locally
- Why? DFS? BFS?
- Backtracking requires reversibility
- Strategy Hill-climb
- Use memory if stuck, try apparent best neighbor
- Unexplored state assume closest
- Encourages exploration
28BB DynProg Analysis
- Algorithm
- Select best partial path from Q
- Test for completion
- Add path extensions to Q
- Assume that we are using an Expanded list to
implement Dynamic Prog. (implemented as a hash
table constant access time).
Assume we have a graph with N nodes and L links.
We call a graph where nodes have O(N) links are
dense. Graphs where the nodes have a nearly
constant number of links are sparse. For dense
graphs L is O(N2).
O(N)
Paths taken from Q ?
O(N)
Cost of picking path from Q ( cleanup), using
linear scan?
O(L)
Attempts to add path to Q (many are rejected)?
O(1)
Cost of adding path extension to front of Q ?
O(N2 L)
Total cost ?
Lozano-perez, 2000
29Cost and Performance
Searching a tree with N nodes and L links
Searching a tree with branching factor b and
depth d L N b d1
Worst case time is proportional to number of
nodes visited Worst case space is proportional to
maximal length of Q (and Expanded)
lozano-perez, 2000