search: heuristic &optimal artificial intelligence cmsc 25000 january 16, 2003

29
Search: Heuristic &Optimal Artificial Intelligence CMSC 25000 January 16, 2003

Upload: julianna-jefferson

Post on 27-Dec-2015

220 views

Category:

Documents


3 download

TRANSCRIPT

Search: Heuristic &Optimal

Artificial Intelligence

CMSC 25000

January 16, 2003

Agenda

• 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

Searches

• 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

Heuristic Search● A little knowledge is a powerful thing

– Order choices to explore better options first– More knowledge => less search– Better search alg?? Better search space

● Measure of remaining cost to goal-heuristic– E.g. actual distance => straight-line distance

S

D

A

E

B C

F

G

4.06.710.4

11.0

8.96.9

3.0

Hill-climbing Search

● Select child to expand that is closest to goal

S

A10.4 D 8.9

A10.4 E 6.9

B6.7 F3.0

G

Hill-climbing Search Algorithm

● Form a 1-element queue of 0 cost=root 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 found=>success; else, failure

Beam Search● Breadth-first search of fixed width - top w

– Guarantees limited branching factor, E.g. w=2

S

A D

B D A E

10.4 8.9

6.7 8.9 10.4 6.9

C E B F4.0 6.9 6.7 3

A C G

Beam Search Algorithm

– Form a 1-element queue of 0 cost=root 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 found=>success; else, failure

Best-first Search● Expand best open node ANYWHERE in tree

– Form a 1-element queue of 0 cost=root 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 found=>success; else, failure

Heuristic 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!!

Search CostsType Worst / Worst

Time SpaceReachGoal?

Depth-first B^d+1/ Bd Yes

Breadth-first B^d+1/B^d Yes

Hill-Climbing(no backup)

D / B No

Hill-Climbing B^d+1 /Bd Yes

Beam Search Wd / WB No

Best-first B^d+1/B^d Yes

Searches

• 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

Optimal 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

Efficient 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 > complete path length

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) > d(complete path)

• Straight-line distance => underestimate

• Better estimate => Better search • No missteps

Search 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

A* Search Algorithm• Combines good optimal search ideas

– Dynamic programming and underestimates

• Form a 1-element queue of 0 cost=root 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 found=>success; else, failure

A* Search Example

S

A D13.4 12.9

A E19.4 12.9

B F17.7 13

G 13

Heuristics

• A* search: only as good as the heuristic

• Heuristic requirements:– Admissible:

• UNDERESTIMATE true remaining cost to goal

– Consistent:• h(n) <= c(n,a,n') + h(n')

• Some heuristics better than others– 0?

Constructing 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) -> Manhattan distance– Ignore 1) & 2): # of misplaced squares

Navigation

Application: 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

Navigation

Navigation

Navigation 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

Online 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)

Online Search Agents

• Exploration:– Perform action in state -> 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

Lozano-perez, 2000

B&B + 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).

Paths taken from Q ?

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)

Cost of adding path extension to front of Q ?

O(L)

Total cost ? O(N2 + L)

Cost of picking path from Q (& cleanup), using linear scan? O(N)

Attempts to add path to Q (many are rejected)?O(1)

lozano-perez, 2000

Cost and Performance

Searching a tree with branching factor b and depth dL = N= b d+1

Worst case time is proportional to number of nodes visitedWorst case space is proportional to maximal length of Q (and Expanded)

Searching a tree with N nodes and L links

Yes

Guaranteed to find shortest path

O(N)O(N log N)O(N2)Branch & BoundA*

Worst Space

Worst Time(Sparse)

Worst Time(Dense)

SearchMethod