You are on page 1of 43

ARTIFICIAL INTELLIGENCE

CSE 3201

Informed Search (I)


Informed Search
■ A search strategy which searches the most promising branches of the state-space to-
– find a solution more quickly,
– find solutions even when there is limited time available,
– often find a better solution, since more profitable parts of the state-space can be
examined,
while ignoring the unprofitable parts.
■ Relies on additional knowledge about the problem or domain
– frequently expressed through heuristics.
■ Used to distinguish more promising paths towards a goal
– may be mislead, depending on the quality of the heuristic.
■ In general, performs much better than uninformed search.
2
Uninformed vs. Informed
■ Uninformed search technique have access only to the problem definition whereas
Informed search technique have access to heuristic function as well as problem definition.

■ Uninformed search known as blind search whereas Informed search is known as heuristic
search.

■ Uninformed search is less efficient whereas informed search is more efficient.

■ Many problems are not solved by uninformed search whereas Most of the problem are
solved by informed search.

3
Heuristics
■ All the previous searches have been blind searches
– They make no use of any knowledge of the problem
– If we know something about the problem, we can usually do much better.
■ A heuristic is a rule of thumb for deciding which choice might be best. It’s a technique that
improves the efficiency of a search process.
■ Heuristics are like tour guides
■ There are good general purpose heuristics that are useful in a wide variety of problem
domains.
■ There is no general theory for finding heuristics, because every problem is different.
■ Choice of heuristics depends on knowledge of the problem space.

4
Heuristic Example
■ Example: 8-puzzle
– For each piece, figure out how many moves away it is from its
goal position, if no other piece were in the way
– The total of these gives a measure of distance from goal
– This is a heuristic measure

5
Heuristic for the 8-puzzle
■ Number of tiles out of place (h1)
• Manhattan distance (h2)
- Sum of the distance of each
tile from its goal position.
- The distance we’ll count is the
sum of the horizontal distance
and vertical distance which is
also known as Manhattan or
City block distance.

6
Basic Search Algorithm
■ Initialize: put the start node into OPEN
while OPEN is not empty
take a node N from OPEN
if N is a goal node, report success
put the children of N onto OPEN
Report failure
■ If OPEN is a stack, this is a depth-first search
■ If OPEN is a queue, this is a breadth-first search
■ If OPEN is a priority queue, sorted according to most promising first, we have a best-
first search.

7
Best-First Search
■ Use the same basic search algorithm.
■ Relies on an evaluation function that gives an indication of how useful it would
be to expand a node
– family of search methods with various evaluation functions
– usually gives an estimate of the distance to the goal
■ The node with the lowest value is expanded first
– the name is a little misleading: the node with the lowest value for
the evaluation function is not necessarily one that is on an optimal path
to a goal.
– if we really know which one is the best, there’s no need to do a
search.
8
Greedy Search
• Evaluation function f(n) = h(n) (heuristic) = estimation of cost from n to goal.
• e.g., hSLD(n) = straight-line distance from n to Bucharest (Next example)
• Greedy best-first search expands the node that appears to be closest to goal.
• Also called Greedy Best-first Search.

9
Romania With Step Costs in km

10
Greedy Best-first Search Example

11
Greedy Best-first Search Example

12
Greedy Best-first Search Example

13
Greedy Best-first Search Example

14
Greedy Best-first Search
■ Expand the node with smallest h(n)
• Why is it called greedy?
– Expands node that appears closest to goal.
• It can be similar to depth-first search
– Follows single path all the way to goal, backs up when dead end.

15
Properties of Greedy best first search
■ Complete and/or optimal?
– No (same problems as depth first search)
– Can get lost down an incorrect path.
■ Time?
O (bd), but a good heuristic can give dramatic improvement
■ Space?
O (bd) -- Where, d is the maximum depth of the search space.

16
The A* algorithm

17
The A* algorithm

18
The A* algorithm

19
Romania With Step Costs in km

20
A* Search Example

21
A* Search Example

22
A* Search Example

23
A* Search Example

24
A* Search Example

25
A* Search Example

26
Another Example

27
A* Example

28
A* Example

29
A* Example

30
8-Puzzle without Heuristic

31
8-Puzzle by A*

32
8-Puzzle by A*

33
Exercise for A*

34
Conditions for Optimality of A*
■ Two conditions need to be fulfilled for A* to be Optimal:
- Admissibility
- Consistency

35
A*-Admissibility/Admissible Heuristic
■ A search algorithm is said to be admissible if it is guaranteed to return an optimal
solution.
■ An admissible heuristic never overestimates the cost to reach the goal, i.e., it is
optimistic
■ So, a given heuristic function h(n) is admissible if it never overestimates the real distance
between n and the goal node.
■ If the heuristic function used by A* is admissible, then A* is admissible.

36
A*-Admissibility/Admissible Heuristic
■ Admissibility of A* search is measured by the condition:
h(n) <= h*(n)
where h*(n) is the real distance between n and the goal node.
■ Given a h function that satisfies these constraints, we must prove that Algorithm A* will
find a cheapest path to a goal node(or optimal solution).

h(n) must be less or equal to the actual cost for A* to be admissible.

37
A*-Admissibility

38
A*-Admissibility

39
A* - Consistency
■ A heuristic h(n) is consistent if, for every node n and every successor n’ of n, the
estimated cost of reaching the goal from n is less than or equal to the actual step
cost of getting to n’ plus the estimated cost of reaching the goal from n’. In an
equation, it would look like this:
h(n) <= C(n, n’) + h(n’)

OR,
A consistent heuristic must satisfy h(N) − h(L) ≤ path(N → L) for all paths and nodes N and L.

40
Optimality of A*

41
Optimality of A*

42
Properties of A*

43

You might also like