0% found this document useful (0 votes)
18 views37 pages

Part3.3 Informed Search

Uploaded by

clintsimiyu004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views37 pages

Part3.3 Informed Search

Uploaded by

clintsimiyu004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 37

Part 3.

3: Informed (Heuristic)
Search
Concept
Informed search methods
Search with Domain Knowledge added


Uninformed (blind) searches are normally very
inefficient

Adding domain knowledge can improve the search
process.

Kaburu.M.M 2
cisy422_bbit333
Concept of informed (heuristic) search


Heuristic (informed) search -> explore the node that
is most “likely” to be the nearest to a goal state.

There is no guarantee that the heuristic provided
most “likely” node will get you closer to a goal state
than any other.

Kaburu.M.M 3
cisy422_bbit333
Knowledge/info


Example:
 City streets

You are at GPO and would like to go the Old Nation
Roundabout to get a matatu - What path will you take?
Is it the shortest?
 Parallel streets on all sides

Kaburu.M.M 4
cisy422_bbit333
Knowledge/info


Example:
 An office in a city building

Find me in Office door number N311 e.g. KICC, NSSF,
KEMU Main Campus, Student’s Center?
 Wing, floor, left/right

 Some streets in Nairobi are named in alphabetical


order

Kaburu.M.M 5
cisy422_bbit333
Knowledge/info


Example:
 Visit the doctor

Symptoms: fever, nausea, headache, …
 Leading questions: how long?, traveled?, … (Malaria,
typhoid, meningitis, flu,..)
 x Blood test, y test,...

Kaburu.M.M 6
cisy422_bbit333
Knowledge/info


Example:
 Climbing a hill in thick Fog

Heuristic function: check the change in altitude in 4
directions; the strongest increase is the direction in
which to move next.

Kaburu.M.M 7
cisy422_bbit333
Heuristic Searches - Characteristics


Has some domain knowledge

Usually more efficient than blind searches

Also called informed search

Heuristic searches work by deciding which is the
next best node to expand (there is no guarantee that
it is the best node)

Kaburu.M.M 8
cisy422_bbit333
Heuristic Searches - Why Use?

It may be too resource intensive (both time and
space) to use a blind search

Even if a blind search will work we may want a more
efficient search method

Kaburu.M.M 9
cisy422_bbit333
Part 3.3: Informed (Heuristic)
Search
Concept
Informed search methods

Kaburu.M.M 10
Heuristic Search Methods


Methods that use a heuristic function to provide
specific knowledge about the problem:

Heuristic Functions

Hill climbing

Greedy search

A* search algorithm

Kaburu.M.M 11
cisy422_bbit333
Heuristic Functions

To further improve the quality of the previous
methods, we need to include problem-specific
knowledge on the problem.
 How can this be done in such a way that the
algorithms remain generally applicable ???

 HEURISTIC FUNCTIONS:
 f: States --> Numbers
 f(T) : expresses the quality of the state T
 allow to express problem-specific knowledge in
the search method algorithm
Kaburu.M.M 12
cisy422_bbit333
Example 1: road map

Imagine the problem of finding a route on a road
map and that the NET below is the road map:
4 4
3 A B C
S 5 5 G
4 D E F 3
2 4
 Define f(T) = the straight-line distance from T to G
A 10.4 B 6.7 C 4
11 The estimate
S
G can be wrong!
8.9
D E 6.9 F 3
Kaburu.M.M 13
cisy422_bbit333
Example 2: 8-puzzle

f1(T) = the number correctly placed tiles on the
board: 1 3 2
f1 8 4 =4
5 6 7

 f2(T) = number or incorrectly placed tiles on board:


 gives (rough!) estimate of how far we are from goal

1 3 2
f2 8 4 =4
5 6 7
Most often, ‘distance to goal’ heuristics are more useful !
Kaburu.M.M 14
cisy422_bbit333
Example 2: 8-puzzle Manhattan distance


f3(T) = the sum of ( the horizontal + vertical distance
that each tile is away from its final destination):
 gives a better estimate of distance from the goal
node

1 3 2
f2 8 4 =1+1+2+2=6
5 6 7

Kaburu.M.M 15
cisy422_bbit333
Hill climbing


A basic heuristic search method:
 depth-first + heuristic

Kaburu.M.M 16
cisy422_bbit333
Hill climbing_1
 Example: using the straight-line distance:

S

Perform depth-first,
10.4 8.9 BUT:
A D 
instead of left-to-right
selection,
10.4 6.9
A E

FIRST select the child
with the best heuristic
value
6.7 B F
3.0

Kaburu.M.M 17
cisy422_bbit333
Hill climbing_2
 Inspiring Example: climbing a hill in the fog.
 Heuristic function: check the change in altitude

in 4 directions: the strongest increase is the


direction in which to move next.

 Is identical to Hill climbing_1, except for dropping


the backtracking.
 Produces a number of classical problems:

Kaburu.M.M 18
cisy422_bbit333
Problems with
Hill climbing_2:
Foothills: Plateaus

Local
maximum

Ridges

Kaburu.M.M 19
cisy422_bbit333
Comments:

Foothills are local minima: hill climbing_2 can’t
detect the difference.

Plateaus don’t allow you to progress in any
direction.

 Foothills and plateaus require random jumps to


be combined with the hill climbing algorithm.


Ridges neither: the directions you have fixed in
advance all move downwards for this surface.
 Ridges require new rules, more directly targeted
to the goal, to beKaburu.M.M
introduced (new directions to 20

move) . cisy422_bbit333
Local search
S

Hill climbing_2 is an example of local
search. A

In local search, we only keep track of 1 B
path and use it to compute a new path in
the next step. C
D
 QUEUE is always of the form:

( p)
 Another example:
 MINIMAL COST search: A
3 4
 If p is the current path:
B C
 the next path extends p by adding 2 3 5
the node with the smallest cost from D E F
the endpoint of p Kaburu.M.M 21
cisy422_bbit333
Heuristic Searches - Greedy search


So named as it takes the biggest “bite” it can out of
the problem.
That is, it seeks to minimise the estimated cost to the
goal by expanding the node estimated to be closest
to the goal state

in other words,

Always expand the heuristically best nodes first.

Kaburu.M.M 22
cisy422_bbit333
Greedy search, or
Heuristic best-first search:

S 30

10 40
1 20 
At each step,

3 select the node


with the best (in
35 15 this case:
lowest) heuristic
2 27 18 value.

25 45 The ‘open’
nodes
Kaburu.M.M 23
cisy422_bbit333
Greedy search algorithm:
1. QUEUE <-- path only containing the root;

2. WHILE QUEUE is not empty


AND goal is not reached

DO remove the first path from the QUEUE;


create new paths (to all children);
reject the new paths with loops;
add the new paths and sort the entire QUEUE;
(HEURISTIC)
3. IF goal reached
THEN success;
ELSE failure; Kaburu.M.M 24
cisy422_bbit333
Heuristic Searches - Greedy Search

It is only concerned with short term aims

It is possible to get stuck in an infinite loop, unless
you check for repeated states

It is not optimal

It is not complete

Time and space complexity is O(Bm); where m is the depth of the


search tree

Kaburu.M.M 25
cisy422_bbit333
Heuristic Searches - A* Algorithm

A combination of Greedy search and Uniform cost
search. - to compliment one another

This search method minimises the cost to the goal
using an heuristic function, h(n). Greedy search can
considerably cut the search time but it is neither
optimal nor complete. By comparison uniform cost
search minimises the cost of the path so far, g(n).
Uniform cost search is both optimal and complete
but can be very inefficient.

Kaburu.M.M 26
cisy422_bbit333
Road map example:
Re-introduce the costs of paths in the NET

A 4 B 4 C
3
S 5 5
G
4 D 2 E F 3
4
3 S 4
4 A D
5 5 2
B D A E
4 5 2 4 5 4
C E E B B F
2 4 5 4 4 5 4 4 3
D F B F C E A C G
3 4 3 4
G C G F
Kaburu.M.M 3 27
cisy422_bbit333 G
A look at Uniform cost search= uniformed best-first

S
3 4

A 3 5 D4 At each step,
4

5 2 select the
B 7 D 8 A 9 E 6 node with the
4 5 5 4 lowest
5 4
accumulated
C 11 E 12 E 13 B 13 B 11 F 10 cost.
3
D F B F C E A C G 13

G C G F
G

Kaburu.M.M 28
cisy422_bbit333
Now incorporate heuristic estimates

Replace the ‘accumulated cost’ in the ‘Uniform
cost search’ by a function:
f(path) = cost(path) + h(endpoint_path)

fn g(n) h(n)
 where:
cost(path) = the accumulated cost of the partial path
h(T) = a heuristic estimate of the cost remaining
from T to a goal node

f(path) = an estimate of the cost of a path extending


the current path to reach a goal.
fn =Kaburu.M.M
g(n) + h(n) 29
cisy422_bbit333
Heuristic Searches - A* Algorithm

Combines the cost so far and the heuristic estimated
cost to the goal. That is fn = g(n) + h(n)
This gives us estimated cost of the cheapest solution
through path n

It can be proved to be optimal and complete
providing that the heuristic is admissible.
That is the heuristic must never over estimate the
cost to reach the goal.

But, the number of nodes that have to be searched
still grows exponentially

Kaburu.M.M 30
cisy422_bbit333
Example: road map

Imagine the problem of finding a route on a road
map. The paths distances between nodes define
g(n): 4 4
3 A B C
S 5 5 G
4 D E F 3
2 4
 Define h(n) = the straight-line distance from node to
G 10.4
A B 6.7 C 4
11
S
G
8.9
D E 6.9 F 3
Kaburu.M.M 31
cisy422_bbit333
S
3 + 10.4 = 13.4 A D 4 + 8.9 = 12.9

S
A 13.4 D
9 + 10.4 = 19.4 A E 6 + 6.9 = 12.9
X
S
A 13.4 D
A E
X B F 10 + 3.0 = 13.0
11 + 6.7 = 17.7
S
A 13.4 D
A
X
E STOP!
17.7 B F
Kaburu.M.M 32
cisy422_bbit333
G 13 + 0.0 = 13.0
Heuristic Searches - A* Algorithm for 8-Puzzle
Example
5 4 1 2 3
6 1 8 8 4
7 3 2 7 6 5

Initial State Goal State


 Typical solution is about twenty steps

 Branching factor is approximately three. Therefore a complete


search would need to search 320 states. But by keeping track of
repeated states we would only need to search 9! (362,880) states

 But even this is a lot (imagine having all these in memory)

 Our aim is to develop a heuristic that does not over estimate (it is
admissible) so that we can use A* to find the optimal solution
Kaburu.M.M 33
cisy422_bbit333
Heuristic Searches - Possible Heuristics

H1 = the number of tiles that are in the wrong


position (=7)

H2 = the sum of the distances of the tiles from their


goal positions using the Manhattan Distance (=18)

Both are admissible but which one is best?

Kaburu.M.M 34
cisy422_bbit333
Test from 100 runs with varying solution depths
Search
Cost
Depth IDS A*(h1) A*(h2)
2 10 6 6
4 112 13 12
6 680 20 18
8 6384 39 25
10 47127 93 39
12 364404 227 73
14 3473941 539 113
16 1301 211
18 3056 363
20 7276 676
22 18094 1219
24 39135 1641
H2 looks better as fewer nodes are expanded. But why?
Kaburu.M.M 35
cisy422_bbit333
Effective Branching Factor
Search EBF
Cost
Depth IDS A*(h1) A*(h2) IDS A*(h1) A*(h2)
2 10 6 6 2.45 1.79 1.79
4 112 13 12 2.87 1.48 1.45
6 680 20 18 2.73 1.34 1.30
8 6384 39 25 2.80 1.33 1.24
10 47127 93 39 2.79 1.38 1.22
12 364404 227 73 2.78 1.42 1.24
14 3473941 539 113 2.83 1.44 1.23

 H2 has a lower branching factor and so fewer nodes are expanded


 Therefore, one way to measure the quality of a heuristic is to find
its average branching factor
 H2 has a lower EBF and is therefore the better heuristic

Kaburu.M.M 36
cisy422_bbit333
Summary


Blind Search is very expensive

A Search with info (heuristics) is far better

Info can be difficult to incorporate

The more info, the better

Kaburu.M.M 37
cisy422_bbit333

You might also like