• No results found

Informed Search Uninformed Versus Informed Search Best First Search Greedy Search A* Search

N/A
N/A
Protected

Academic year: 2020

Share "Informed Search Uninformed Versus Informed Search Best First Search Greedy Search A* Search"

Copied!
71
0
0

Loading.... (view fulltext now)

Full text

(1)

Lecture 04

Informed (Heuristic) Search

Tooba Mehtab

(2)

Outline

Informed Search

Uninformed Versus Informed Search

(3)

Informed Search

Informed searches use domain knowledge

to guide selection of the best path to

continue searching

Heuristics

are used, which are informed

guesses

Heuristic means "serving to aid discovery“

A heuristic is a function that

estimates

the

(4)

Informed Search

Define a

heuristic

function,

h(n)

uses domain-specific information in some way

is computable from the current state description

it estimates

• the "goodness" of node n

• how close node n is to a goal

the cost of minimal cost path from node n to a goal

(5)

Informed Search

h

(

n

)

0

for all nodes

n

h(n)

close to 0 means we think n is close to a goal state

h(n)

very big means we think n is far from a goal state

All domain knowledge used in the search is encoded in

the heuristic function,

h

An example of a “

weak

method

” for AI because of the

(6)

Uninformed search Informed search

• does not have any additional information on the quality of states.

• So, it is impossible to

determine which state is the better than others. As a result, search efficiency depends only on the structure of a state

space

• look for solutions by

systematically generating new states and checking each of them against the goal.

• heuristically informed search uses a certain kind of

information about states in order to guide search along promising branches within a state space.

• Using problem specific

knowledge as hints to guide the search.

(7)

Uninformed search Informed search 1. It is very inefficient in most

cases.

2. Most successor states are “obviously” a bad choice.

3. Such strategies do not use problem-specific knowledge

1. They are almost always more efficient than uninformed

strategies.

2. May reduce time and space complexities.

3. Evaluation function f(n)

measures distance to the goal. 4. Order nodes in Frontier

(8)

An informed search strategy uses problem-specific knowledge beyond the definition of the problem itself, so it can find

solutions more efficiently than an uninformed strategy.

Best-first search is an instance of the general TREE-SEARCH or

GRAPH-SEARCH algorithm in which a node is selected for expansion based on an evaluation function, f (n) .

• A key component of these algorithms is a heuristic function

denoted h(n) :

h(n) = estimated cost of the cheapest path from node n to a

goal node, if n is a goal node, then h(n) = 0.

(9)

Best-First Search

Special cases:

Greedy Best first search

• “Always chooses the successor node with the best f

value” where f(n) = h(n)

• We choose the one that is nearest to the final state among all possible choices

A* search

• Best first search using an “admissible” heuristic function f

that takes into account the current cost g

(10)

Greedy Best First Search

(11)

Greedy best-first search tries to expand the node

that is closest to the goal, on the grounds that it is

likely to lead to a solution quickly.

Thus, it evaluates nodes by using just the

heuristic

function

; that is, f(n)=h(n).

Evaluation function

f(n) = h(n) (heuristic) = estimate of cost from n to goal

Assume

h

SLD

(n)

=

straight line distance

from

n

to

Bucharest

, so Greedy best-first search expands the

node that appears to be closest to goal

(12)
(13)
(14)
(15)
(16)

State Heuristic: h(n) A 366 B 374 C 329 D 244 E 253 F 178 G 193 H 98 I 0 A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111

f(n) = h (n) = straight-line distance heuristic

140

(17)

State Heuristic: h(n) A 366 B 374 C 329 D 244 E 253 F 178 G 193 H 98 I 0 A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111

f(n) = h (n) = straight-line distance heuristic

140

(18)

State Heuristic: h(n) A 366 B 374 C 329 D 244 E 253 F 178 G 193 H 98 I 0 A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111

f(n) = h (n) = straight-line distance heuristic

140

(19)

State Heuristic: h(n) A 366 B 374 C 329 D 244 E 253 F 178 G 193 H 98 I 0 A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111

f(n) = h (n) = straight-line distance heuristic

140

(20)

State Heuristic: h(n) A 366 B 374 C 329 D 244 E 253 F 178 G 193 H 98 I 0 A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111

f(n) = h (n) = straight-line distance heuristic

140

(21)

State Heuristic: h(n) A 366 B 374 C 329 D 244 E 253 F 178 G 193 H 98 I 0 A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111

f(n) = h (n) = straight-line distance heuristic

140

(22)

State Heuristic: h(n) A 366 B 374 C 329 D 244 E 253 F 178 G 193 H 98 I 0 A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111

f(n) = h (n) = straight-line distance heuristic

140

(23)

State Heuristic: h(n) A 366 B 374 C 329 D 244 E 253 F 178 G 193 H 98 I 0 A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111

f(n) = h (n) = straight-line distance heuristic

140

(24)

State Heuristic: h(n) A 366 B 374 C 329 D 244 E 253 F 178 G 193 H 98 I 0 A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111

f(n) = h (n) = straight-line distance heuristic

140

(25)

State Heuristic: h(n) A 366 B 374 C 329 D 244 E 253 F 178 G 193 H 98 I 0 A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111

f(n) = h (n) = straight-line distance heuristic

140

(26)

A Start

Greedy Search – Tree Search

State Heuristic : h(n)

A 366

B 374

C 329

D 244

E 253

F 178

G 193

H 98

(27)

A

B C

E

Start 75 118

140 [374]

[329]

[253]

Greedy Search – Tree Search

State Heuristic : h(n)

A 366

B 374

C 329

D 244

E 253

F 178

G 193

H 98

(28)

A B C E F 99 G A 80 Start 75 118 140 [374] [329] [253] [193] [366] [178]

Greedy Search – Tree Search

(29)

A B C E F I 99 211 G A 80 Start Goal 75 118 140 [374] [329] [253] [193] [366] [178] E [0] [253]

Greedy Search – Tree Search

(30)

A B C E F I 99 211 G A 80 Start Goal 75 118 140 [374] [329] [253] [193] [366] [178] E [0] [253]

Path cost(A-E-F-I) = 253 + 178 + 0 = 431

dist(A-E-F-I) = 140 + 99 + 211 = 450

Greedy Search – Tree Search

(31)

State Heuristic: h(n) A 366 B 374 C 329 D 244 E 253 F 178 G 193 H 98 I 0 A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111

f(n) = h (n) = straight-line distance heuristic

dist(A-E-G-H-I) = 140 + 80 + 97 + 101 = 418

140

(32)

A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111

f(n) = h (n) = straight-line distance heuristic

140

Greedy Search: Complete ?

State Heuristic: h(n)

A 366

B 374

** C 250

(33)

A Start

Greedy Search: Tree Search

State Heuristic: h(n)

A 366

B 374

** C 250

D 244

E 253

F 178

G 193

H 98

(34)

A

B C

E

Start 75 118

140 [374]

[250]

[253]

Greedy Search: Tree Search

State Heuristic: h(n)

A 366

B 374

** C 250

D 244

E 253

F 178

G 193

H 98

(35)

A

B C

E

D

111

Start 75 118

140 [374]

[250]

[253]

[244]

Greedy Search: Tree Search

State Heuristic: h(n)

A 366

B 374

** C 250

D 244

E 253

F 178

G 193

H 98

(36)

A

B C

E

D

111

Start 75 118

140 [374]

[250]

[253]

[244]

C [250]

Infinite Branch !

Greedy Search: Tree Search

State Heuristic: h(n)

A 366

B 374

** C 250

D 244

E 253

F 178

G 193

H 98

(37)

A B C E D 111 Start 75 118 140 [374] [250] [253] [244] C D [250] [244]

Infinite Branch !

Greedy Search: Tree Search

State Heuristic: h(n)

A 366

B 374

** C 250

(38)

A B C E D 111 Start 75 118 140 [374] [250] [253] [244] C D [250] [244]

Infinite Branch !

Greedy Search: Tree Search

State Heuristic: h(n)

A 366

B 374

** C 250

(39)

A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111 140

• Greedy search is not optimal.

• Greedy search is incomplete

without systematic checking of

repeated states.

• In the worst case, the Time and

Space Complexity of Greedy

Search are both O(b

m

)

Where b is the branching factor and m the maximum path length

(40)

A* Search

(41)

o

Greedy Search minimizes a heuristic h(n) which is an

estimated cost from a node n to the goal state. Greedy

Search is efficient but it is not optimal nor complete.

o

Uniform Cost Search minimizes the cost g(n) from the

initial state to n. UCS is optimal and complete but not

efficient.

o

New Strategy

: Combine Greedy Search and UCS to

get an

efficient

algorithm which is

complete and

optimal

.

(42)

A* uses a heuristic function which combines

g(n) and h(n): f(n) = g(n) + h(n)

g(n)

is the exact cost to reach node

n

from

the initial state.

h(n)

is an estimation of the remaining cost

to reach the goal.

(43)

n

g(n)

h(n)

f(n) = g(n)+h(n)

(44)

State Heuristic: h(n) A 366 B 374 C 329 D 244 E 253 F 178 G 193 H 98 I 0

f(n) = g(n) + h (n)

g(n): is the exact cost to reach node n from the initial state.

(45)

A Start

A* Search: Tree Search

State Heuristic: h(n)

A 366

B 374

C 329

D 244

E 253

F 178

G 193

H 98

(46)

A

B

C E

Start

75 118

140

[393] [449]

[447]

A* Search: Tree Search

State Heuristic: h(n)

A 366

B 374

C 329

D 244

E 253

F 178

G 193

H 98

(47)

A

B

C E

F 99

G 80

Start

75 118

140

[393] [449]

[447]

[417] [413]

A* Search: Tree Search

State Heuristic: h(n)

A 366

B 374

C 329

D 244

E 253

F 178

G 193

H 98

(48)

A B C E F 99 G 80 Start 75 118 140 [393] [449] [447] [417] [413] H 97 [415]

A* Search: Tree Search

(49)

A B C E F I 99 G H 80 Start 97 101 75 118 140 [393] [449] [447] [417] [413] [415] Goal [418]

A* Search: Tree Search

(50)

A B C E F I 99 G H 80 Start 97 101 75 118 140 [393] [449] [447] [417] [413] [415] Goal [418] I [450]

A* Search: Tree Search

(51)

A B C E F I 99 G H 80 Start 97 101 75 118 140 [393] [449] [447] [417] [413] [415] Goal [418] I [450]

A* Search: Tree Search

(52)

A B C E F I 99 G H 80 Start 97 101 75 118 140 [393] [449] [447] [417] [413] [415] Goal [418] I [450]

A* Search: Tree Search

(53)

A* with f() not Admissible

(54)

State Heuristic: h(n) A 366 B 374 C 329 D 244 E 253 F 178 G 193 H 138 I 0 A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111

f(n) = g(n) + h (n) – (H-I) Overestimated

g(n): is the exact cost to reach node n from the initial state.

140

(55)

A Start

(56)

A

B

C E

Start

75 118

140

[393] [449]

[447]

(57)

A

B

C E

F 99

G 80

Start

75 118

140

[393] [449]

[447]

[417] [413]

(58)

A

B

C E

F 99

G 80

Start

75 118

140

[393] [449]

[447]

[417] [413]

H

97

[455]

(59)

A

B

C E

F 99

G

H

80

Start

97

75 118

140

[393] [449]

[447]

[417] [413]

[455] Goal I [450]

(60)

A

B

C E

F 99

G

H

80

Start

97

75 118

140

[393] [449]

[447]

[417] [413]

[455] Goal I [450]

D [473]

A* Search: Tree Search

(61)

A

B

C E

F 99

G

H

80

Start

97

75 118

140

[393] [449]

[447]

[417] [413]

[455] Goal I [450]

D [473]

A* Search: Tree Search

(62)

A

B

C E

F 99

G

H

80

Start

97

75 118

140

[393] [449]

[447]

[417] [413]

[455] Goal I [450]

D [473]

A* Search: Tree Search

(63)

A

B

C E

F 99

G

H

80

Start

97

75 118

140

[393] [449]

[447]

[417] [413]

[455] Goal I [450]

D [473]

A* not optimal !!!

A* Search: Tree Search

(64)

A* with systematic checking for

repeated states …

(65)

1. Search queue Q is empty.

2. Place the start state s in Q with f value h(s). 3. If Q is empty, return failure.

4. Take node n from Q with lowest f value.

(Keep Q sorted by f values and pick the first element). 5. If n is a goal node, stop and return solution.

6. Generate successors of node n. 7. For each successor n’ of n do:

a) Compute f(n’) = g(n) + cost(n,n’) + h(n’).

b) If n’ is new (never generated before), add n’ to Q.

c) If node n’ is already in Q with a higher f value, replace it with current f(n’) and place it in sorted order in Q.

End for

8. Go back to step 3.

(66)

A B D C E F I 99 211 G H 80 Start Goal 97 101 75 118 111 140

•A* is complete except if there is an infinity of nodes with f < f(G).

•A* is optimal if heuristic h is admissible.

•Time complexity depends on the quality of heuristic but is still

exponential.

(67)

Frustration with uninformed search led to the

idea of using domain specific knowledge in a

search so that one can intelligently explore

only the relevant part of the search space that

has a good chance of containing the goal state.

These new techniques are called informed

(heuristic) search strategies.

Even

though

heuristics

improve

the

performance of informed search algorithms,

they are still time consuming especially for

large size instances.

(68)

1. Define informed/heuristic search strategy.

2. What is the difference between

a) Informed and Uninformed Search

b) Greedy best first and A* algorithms

3. Prove that Uniform-cost search is a special case of A∗ search..

4. Prove that if a heuristic is consistent, it must be admissible.

Construct an admissible heuristic that is not consistent.

5. Are Greedy best first and A* algorithms optimal and complete?

6. What is the time and space complexity of Greedy best first and A*

algorithms?

(69)

A 240

B 186

C 182

D 163

E 170

F 150

G 165

H 139

I 120

J 130

K 122

L 104

M 100

N 77

O 72

P 65

Q 65

R 0

Tutorial 04

Goal

(70)

TUTORIAL 04

8. Consider the following map (not drawn to scale).

Use the A* algorithm to work out a route from town A to town M. Use the following cost functions. •G(n) = The cost of each move as the distance between each town (shown on map).

[image:70.720.5.709.41.371.2]

•H(n) = The Straight Line Distance between any town and town M. These distances are given in the table to right of map.

•Provide the search tree for your solution, showing the order in which the nodes were expanded and the cost at each node. You should not re-visit a town that you have just come from.

•State the route you would take and the cost of that route.

A 56

B 22

C 30

D 29

E 29

F 30

G 14

H 10

I 8

J 5

K 30

L 15

(71)

Figure

table to right of map.

References

Related documents

AI attacks, strong/narrow AI, KWARC topics PROLOG Complexity, Agents, Environments Agent Types, Rationality Problem solving, Tree Search Uninformed search Informed Heuristic

• Time may be better spent, if we use a faster, simpler heuristic function and expand more nodes... Put the start node S on the priority queue, called

b: branching factor (assume finite) d: goal depth m: graph depth.. C* is the best goal

Might pass global optima after reaching it adverse effect (easy to avoid by keeping track of 7 g best-ever state) CS 470/670 Artificial Intelligence B lt hi Boltzmann machines B

b: branching factor (assume finite) d: goal depth m: graph depth.. And

Move any square 1 space (overlapping ok) Optimal path cost is Manhattan distance for. each square to goal

Optimization may target different types of search like image search, local search, video search, academic search, new search, industry specific vertical search .It can also be

• Uninformed search has uses but also severe limitations • Heuristics are a structured way to make search smarter. • Informed (or heuristic) search uses problem-specific heuristics to