You are on page 1of 22

Fundamentals of Ar tificial Intelligence

Introduction
• In this lecture we will introduce a new method
of search called informed search algorithms
which is based on heuristics

• A the top of that talk about general search


algorithm

1
Fundamentals of Ar tificial Intelligence

Why using Informed Search?


• Blind search algorithm don’t utilize
information that guides the search within the
tree in order to optimize the search process

• Search algorithms based on heuristics use


available information in order to achieve
efficient search

2
Fundamentals of Ar tificial Intelligence

Definitions of Heuristics
• “A rule of thumb, simplification, or
educated guess that reduces or limits the
search for solutions in domains that are
difficult and poorly understood. Unlike
algorithms, heuristics do not guarantee
optimal, or even feasible, solutions and are
often used with no theoretical guarantee”
Web Dictionary Definition

3
Fundamentals of Ar tificial Intelligence

Definitions of Heuristics
• “A rule of thumb or guideline (as opposed to
an invariant procedure). Heuristics may not
always achieve the desired outcome, but they
are extremely valuable to problem-solving
processes ”
Wilson
• “The art of good guessing”
A Dictionary Definition

4
Fundamentals of Ar tificial Intelligence

Notion of Heuristics
• In AI, a heuristic is a function, h(n), that
estimates the best of a node n to continue
search in order to reach a goal

• Specifically, h(n) is an estimation of the cost


from n to a goal

5
Fundamentals of Ar tificial Intelligence

Notion of Heuristics
• Heuristic h(n) has the following properties:
– h(n) = 0 implies that n is a goal node
– h(n) >= 0 for all nodes n
– h(n) = infinity implies that n is a dead end
from which a goal cannot be reached

h(n) is considered as a “guess” to how far n is


from the goal

6
Fundamentals of Ar tificial Intelligence

Notion of Heuristics
• Heuristic is a domain-specific information that
selects the best path to continue searching
along

• Heuristics do not guarantee feasible solutions


and are often without theoretical basis

• Some problems may have multiple heuristics

7
Fundamentals of Ar tificial Intelligence

Examples
• Heuristics used in some games:

– Missionaries and Cannibals: Number of


people on starting river bank

– 8-puzzle: Number of tiles out of place

8
Fundamentals of Ar tificial Intelligence

Examples
- Blue means the actual cost
- Red means the heuristic value
S
1 5 8

8 A 3 B 5 C

Depending on the heuristic, we can choose node B


to continue the search because it gives
the best estimation

9
Fundamentals of Ar tificial Intelligence

General Search Algorithm


function General-Search (problem, strategy)

initialize the search tree using the initial state of problem

loop do
if no candidates for expansion then return failure
choose node for expansion according to strategy
if node contains goal state then return solution
else expand node and add the resulting nodes search tree

end

10
Fundamentals of Ar tificial Intelligence

General Search Algorithm


• This is the same general search algorithm
used for uninformed search
• The main difference between this
algorithm and the uniformed is in the
expansion of the nodes
• In fact, the chosen node is the most
desirable one based on the heuristic

11
Fundamentals of Ar tificial Intelligence

Best-First Search
• It combines both breadth and depth search
techniques. Its advantages are:
• In breadth:
– Avoiding getting lost in depth within the tree search
• In depth:
– Solution can be found without visiting all the nodes
Best-first search explores nodes following their
heuristic values (increasing or decreasing order)

12
Fundamentals of Ar tificial Intelligence

Best-First Search
• Strategy
– Use an evaluation function for each node in order
to determine the nearest node to the goal
– Expand the most desirable unexpanded node
• Implementation
– Put successors in decreasing order of desirability

13
Fundamentals of Ar tificial Intelligence

Best-First Search
• Special cases: There are two cases for this
search algorithm
– Greedy search
– A* search
• In this lecture, we will talk about the greedy
search algorithm
• A* search algorithm will be discussed in the
next lecture

14
Fundamentals of Ar tificial Intelligence

Greedy Search
• It is the simplest best-first search strategy
• It heuristic function is as follows:
h(s) = cost estimation for s to the goal
• Greedy search try to minimize the estimated
cost to reach the goal
• The most desirable node will be expanded first

15
Fundamentals of Ar tificial Intelligence

Greedy Search

The word “greedy” comes from the


selection of a node to expand which
is believed to be closest to the goal
node

16
Fundamentals of Ar tificial Intelligence

Greedy Search: Example

Assuming all arc


s
costs are 1, then h=3 x p h=5
Greedy search will
find goal f, which h=2 y q h=3
has a solution cost
of 5, while the h=1 z g h=0

optimal solution is
h=1 w
the path to goal g
with cost 3 h=0 f

17
Fundamentals of Ar tificial Intelligence

Greedy Search: Example

Red means heuristic


values 8 S
Blue means actual 1 5 8
cost
9 A 4 B 3 C
3 9
7 4 5
11 D 10 E 0 G

18
Fundamentals of Ar tificial Intelligence

Greedy Search: Example

Stage 0: Starting from node S

8 S

19
Fundamentals of Ar tificial Intelligence

Greedy Search: Example

Stage 1: Selecting node C

8 S
1 5 8

9 A 4 B 3 C

20
Fundamentals of Ar tificial Intelligence

Greedy Search: Example


Stage 2: Selecting node G (the goal)

8 S
1 5 8

9 A 4 B 3 C
4 5
0 G

21
Fundamentals of Ar tificial Intelligence

Greedy Search: Properties


• Complete: Yes (if search tree is finite and
without cycles)

• Time: O(bm): exponential in m = maximum


depth of the tree search

• Space: O(bm): keeps all the nodes in


memory

• Optimal: No

22

You might also like