22
Search in Artificial Intelligence Find the next move in chess, checkers. Scheduling: finding a good class schedule. Theorem proving: given a set of axioms and inference rules, find a proof of a theorem. Planning: find a sequence of actions to achieve a goal for a robot. Natural language understanding: find the best parse of a sentence.

Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

Search in Artificial Intelligence

Find the next move in chess, checkers.Scheduling: finding a good class schedule.Theorem proving: given a set of axioms and

inference rules, find a proof of a theorem.Planning: find a sequence of actions to

achieve a goal for a robot.Natural language understanding: find the

best parse of a sentence.

Page 2: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

Dimensions of Search Problems

In its general form: find a desired object among a set of objects.

Sometimes, you don’t even know if the object exists or not.

In other cases, the goal is to find the best object.

Blind vs. informed search.

Page 3: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

3

Specifying a search problem?

What are states (nodes in graph)?What are the operators (arcs between

nodes)?Initial state?Goal testMetric (e.g., distance to goal)

E.g., Eight Puzzle

1 2 3

7 8

4 5 67 2 3

8 5

4 1 6

Page 4: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

SearchTypes of Search

Blind Heuristic & optimization Adversary Search

Analysis Completeness Time complexity Space Complexity Guaranteed to find best solution? Guaranteed to find the closest solution?

Page 5: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

5

Search Strategies

Blind Search Generate & test Depth first search Breadth first search Iterative deepening search Iterative broadening search

Heuristic searchOptimizing search

Page 6: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

O(b^d)

O(d)

Not for infinite spaces

Depth First Search

a

b

c d

e

f g h

Maintain stack of nodes to visitEvaluation

Complete?

Time Complexity?

Space Complexity?

Page 7: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

Yes

O(b^d)

O(b^d)

Breadth First Search

a

b c

d e f g h

Maintain queue of nodes to visitEvaluation

Complete?

Time Complexity?

Space Complexity?

Page 8: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

Yes

O(b^d)

O(d)

Iterative Deepening Search

a b

c d

e

f

g h

DFS with limit; incrementally grow limitEvaluation

Complete?

Time Complexity?

Space Complexity?

j

i

k L

Page 9: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

9

Search Strategies

Blind Search Heuristic Search

Best-first Beam Hill climbing Simulated annealing

Optimizing Search

Page 10: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

Heuristic Search

A heuristic (metric) is: Function from a state to a real number

Low number means state is close to goalHigh number means state is far from the goal

Designing a good heuristic is very important!

(And hard)

More on this in a bit...

Page 11: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

No

O(b^d)

O(b^d)

Idea Breadth first but use priority queue instead of a

queueEvaluation

Complete?

Time Complexity?

Space Complexity?

Best First Search

a b

c d

e

f

g h j

i

k L

Page 12: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

No

O(b^d)

O(b + N)

Beam Search

Idea Best first but only keep N best items on priority

queueEvaluation

Complete?

Time Complexity?

Space Complexity?

a b

c d

e

f

g h j

i

k L

Page 13: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

No - suffers from plateau, local maxima, ridges

O(b^d) but only in pathological cases

O(b)

Hill Climbing

Idea Always choose best child; no backtracking

Evaluation Complete?

Time Complexity?

Space Complexity?

a b

c d

e

f

g h j

i

k L

Page 14: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

Simulated Annealing

Objective: avoid local minimaTechnique:

For the most part use hill climbing Occasionally take non-optimal step Reduce probability(non-optimal) over time

Comparison to Hill Climbing Completeness? Speed? Space Complexity?

temp

Page 15: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

15

Search Strategies

Blind SearchHeuristic SearchOptimizing Search

A* IDA* SMA*

Objective is to find the very best solution.

Page 16: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

A* Search

Idea Best first search with admissible heuristic Plus keep checking until all possibilities look worse

Evaluation Finds optimal solution?

Time Complexity?

Space Complexity?

Yes

O(b^d)

O(b^d)

Underestimates cost ofany solution which can reached from node

{

Page 17: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

Admissible Heuristics

f(x) = g(x) + h(x)g: cost so farh: underestimate of remaining costs

a

b

c

d

e

f12

8

15

10

8

14 20

7 2 3

8 5

4 1 6

For eight puzzle?

Page 18: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

Importance of Heuristics

D IDS A*(h1) A*(h2) 2 10 6 6 4 112 13 12 6 680 20 18 8 6384 39 2510 47127 93 3912 364404 227 7314 3473941 539 11318 3056 36324 39135 1641

h1 = number of tiles in wrong placeh2 = sum of distances of tiles from

correct loc

7 2 3

8 5

4 1 6

Page 19: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

Iterative Deepening A*

Like iterative deepening depth first, but...Depth bound modified to be an f-cost

limitContour lines bounding search

a

b

c

d

e

fF=15

F=21

Page 20: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

SMA*

Problem is f-cost bound increases slowlyMust do iterative search again and againStoring little state between each iteration

Just one number: next highest contour levelSMA*

Uses all available memory to store state Duplicates minimal work Optimal in a number of nice ways

Page 21: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

Adversary Search

Game playing: want to make the move for which the opponent cannot respond well. a b

c d

e

f

g h j

i

k L

c f

g h

c f

h

c f

g

c f

g h

max

max

max

min

min

1 -1

1-1 1 1

-1 -1

-1

Page 22: Search in Artificial Intelligence zFind the next move in chess, checkers. zScheduling: finding a good class schedule. zTheorem proving: given a set of

Alpha-beta Pruning

a b

c d

e

f

g h j

i

k L

c f c f c f c f

max

max

min

min

max