32
Informed search algorithms

Lecture4(Search) (1)

Embed Size (px)

DESCRIPTION

Artificial intellegence

Citation preview

Page 1: Lecture4(Search) (1)

Informed search algorithms

Page 2: Lecture4(Search) (1)

Uninformed and informed search

• Uninformed techniques (blind search) are not always possible (they require too much time or memory).

• Informed techniques can be effective if applied correctly on the right kinds of tasks.

– Typically require domain specific information.

Page 3: Lecture4(Search) (1)

3

Example: 8 Puzzle

1 2 37 46

85

1 2 38 47 6 5

Page 4: Lecture4(Search) (1)

4

1 2 3

6 5

7 8 4

leftup

Which move is best?

right

1 2 3

5

7 8 4

1 2 3

6 5

7 8 4

1 2 3

6 5

7

8

4

6

1 2 3

7 6 5

8 4

GOAL

Page 5: Lecture4(Search) (1)

5

8 Puzzle Heuristics

• Blind search techniques used an arbitrary ordering (priority) of operations.

• Heuristic search techniques make use of domain specific information - a heuristic.

• What heurisitic(s) can we use to decide which 8-puzzle move is “best” (worth considering first).

Page 6: Lecture4(Search) (1)

6

A Simple 8-puzzle heuristic

• Number of tiles in the correct position.– The higher the number the better.– Easy to compute (fast and takes little

memory).– Probably the simplest possible heuristic.

• Number of tiles in the incorrect position.– The “best” move is the one with the lowest

number returned by the heuristic.

Page 7: Lecture4(Search) (1)

7

1 2 3

6 5

7 8 4

leftup

right

1 2 3

5

7 8 4

1 2 3

6 5

7 8 4

1 2 3

6 5

7

8

4

6

1 2 3

7 6 5

8 4

GOAL

h=2 h=4 h=3

Page 8: Lecture4(Search) (1)

8

Another 8-puzzle heuristic

• Count how far away (how many tile movements) each tile is from it’s correct position.

• Sum up this count over all the tiles.• This is another estimate on the number of

moves away from a solution.

Page 9: Lecture4(Search) (1)

9

1 2 3

6 5

7 8 4

leftup

right

1 2 3

5

7 8 4

1 2 3

6 5

7 8 4

1 2 3

6 5

7

8

4

6

1 2 3

7 6 5

8 4

GOAL

h=2 h=4 h=4

Page 10: Lecture4(Search) (1)

Best-first search

• Idea: use an evaluation function f(n) for each node– estimate of "desirability“– Expand most desirable unexpanded node

• Special cases:– greedy best-first search– A* search

Page 11: Lecture4(Search) (1)

Romania with step costs in km

Page 12: Lecture4(Search) (1)

Greedy best-first search

• Evaluation function f(n) = h(n) (heuristic)

= estimate of cost from n to goal• e.g., hSLD(n) = straight-line distance from n

to Bucharest• Greedy best-first search expands the node

that appears to be closest to goal

Page 13: Lecture4(Search) (1)

Greedy best-first search example

Page 14: Lecture4(Search) (1)

Greedy best-first search example

Page 15: Lecture4(Search) (1)

Greedy best-first search example

Page 16: Lecture4(Search) (1)

Greedy best-first search example

Page 17: Lecture4(Search) (1)

A* search

• Idea: avoid expanding paths that are already expensive

• Evaluation function f(n) = g(n) + h(n)• g(n) = cost so far to reach n• h(n) = estimated cost from n to goal• f(n) = estimated total cost of path through

n to goal

Page 18: Lecture4(Search) (1)

A* search example

Page 19: Lecture4(Search) (1)

A* search example

Page 20: Lecture4(Search) (1)

A* search example

Page 21: Lecture4(Search) (1)

A* search example

Page 22: Lecture4(Search) (1)

A* search example

Page 23: Lecture4(Search) (1)

A* search example

Page 24: Lecture4(Search) (1)

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 TREE-SEARCH is optimal

Page 25: Lecture4(Search) (1)

Local search algorithms

• In many optimization problems, the path to the goal is irrelevant; the goal state itself is the solution

• State space = set of "complete" configurations• Find configuration satisfying constraints, e.g., n-

queens• In such cases, we can use local search

algorithms• keep a single "current" state, try to improve it

Page 26: Lecture4(Search) (1)

Example: n-queens

• Put n queens on an n × n board with no two queens on the same row, column, or diagonal

Page 27: Lecture4(Search) (1)

27

Simple Hill Climbing

• Use heuristic to move only to states that are better than the current state.

• Always move to better state when possible.

• The process ends when all operators have been applied and none of the resulting states are better than the current state.

Page 28: Lecture4(Search) (1)

Hill-climbing search

"Like climbing Everest in thick fog with amnesia"•

Page 29: Lecture4(Search) (1)

Hill-climbing search

• Problem: depending on initial state, can get stuck in local maxima

Page 30: Lecture4(Search) (1)

30

Example - Traveling Salesman Problem (TSP)

• Traveler needs to visit n cities.• Know the distance between each pair of

cities.• Want to know the shortest route that visits

all the cities once.• n=80 will take millions of years to solve

exhaustively!

Page 31: Lecture4(Search) (1)

31

TSP Example

A B

CD 4

6

35

1 2

Page 32: Lecture4(Search) (1)

32

TSP Hill Climb State Space

CABDCABD ABCDABCD ACDBACDB DCBADCBA

Initial State

Swap 1,2 Swap 2,3Swap 3,4 Swap 4,1

Swap 1,2

Swap 2,3

Swap 3,4

Swap 4,1

ABCDABCD

BACDBACD ACBDACBD ABDCABDC DBCADBCA