0% found this document useful (0 votes)
58 views

AI - Informed Search - Lecture 7, 8

(1) Informed search methods use heuristics to guide the search for solutions in a more efficient manner than uninformed blind search. (2) Heuristics are rules or methods that provide an estimation of how close a state is to the goal state, guiding the search towards the most promising paths. (3) Hill climbing is a simple heuristic search method where the search expands the current state and selects the best child state to move to, based on the heuristic evaluation, without retaining search history.

Uploaded by

samar
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

AI - Informed Search - Lecture 7, 8

(1) Informed search methods use heuristics to guide the search for solutions in a more efficient manner than uninformed blind search. (2) Heuristics are rules or methods that provide an estimation of how close a state is to the goal state, guiding the search towards the most promising paths. (3) Hill climbing is a simple heuristic search method where the search expands the current state and selects the best child state to move to, based on the heuristic evaluation, without retaining search history.

Uploaded by

samar
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 42

ARTIFICIAL

INTELLIGENC
E
Review of Last Lecture
5

Informed Search Methods


Heuristic = “to find”, “to discover”

• Blind search:
• Search the solution space in an uninformed manner
•They simply march through the search space until a solution is found.
• Costly with respect time, space or both
• Informed search.
• Search the solution space in informed manner -> HEURISTIC
SEARCH
• Don’t try to explore all possible search path, rather focus on
the path which get you closer to the goal state using some
kind of a
“ GUIDE”.
• A heuristic search makes use of available information in making the
search more efficient.
6

HEURISTIC SEARCH

•Heuristics:
• Rules for choosing the branches in a state space that are
•most likely to lead to an acceptable problem solution.
•Used when:
• Computational costs are high E.g. Chess
•But, Heuristics are fallible. They can lead a search algorithm to a suboptimal
solution or fail to find a solution at all.
7

Informed Search Methods


Heuristic = “to find”, “to discover”

• A heuristic is a rule or method that almost always improves the


decision process.
• Generally can’t be sure that you are near the goal, but
heuristic is a good guess for the purpose.
• E.g. mouse searching for cheese having fresh smell.
• Mouse use “fresh smell” as a guide to reach the goal state.
7

Informed Search Methods


Heuristic = “to find”, “to discover”

For example, if in a shop with several checkouts, it is usually best to go to the


one with the shortest queue. This holds true in most cases but further information
could influence this –

(1) if you saw that there was a checkout with only one person in that queue but that

the person currently at the checkout had three trolleys full of shopping

(2) that at the fast- checkout all the people had only one item, you may choose to go

to the fast- checkout instead.

(3) you don't go to a checkout that doesn't have a cashier - it may have the shortest

queue but you'll never get anywhere


Heuristic

• Euclidian/Straight line Distance= Sqrt (X2-X1)^2+(Y2-Y1) ^2


• Manhattan distance = all possible moves ()
• No of Misplaced tiles
1 3 2 1 2 3
6 5 4 4 5 6
8 7 7 8
Heuristic search
• Straight line distance of each city form goal city..

A 5 B 3 C 2

S 6
G
3 3
D 4 E F
Heuristic search: road
map
The number show 3
the distance b/w two
3
cities
2
A B C

S 4 4
G
3
2
D 1 E 3 F
Best First Search

• A combination of depth first (DFS) and breadth first


search (BFS).

• DFS is good because a solution can be found


without computing all nodes and BFS is good
because it does not get trapped in dead ends.

• The Best First Search (BestFS) allows us to switch


between paths thus gaining the benefits of both
approaches.
BestFS1: Greedy Search
• This is one of the simplest BestFS strategy.

• Heuristic function: h(n) - prediction of path cost left to the goal.

• Greedy Search: “To minimize the estimated cost to reach


the
goal”.

• The node whose state is judged to be closest to the goal state


is always expanded first.

• Two route-finding methods (1) Straight line distance; (2) minimum


Manhattan Distance - movements constrained to horizontal and
vertical directions.
BestFS1: Greedy Search
A Route Plan – Arad to Bucharest
BestFS1: Greedy Search (cont)
BestFS1: Greedy Search (cont)
BestFS1: Greedy Search (cont)
• Noticed that the solution for A  S  F  B is not optimum. It is 32
miles longer than the optimal path A  S  R  P  B.
• The strategy prefers to take the biggest bite possible out of the
remaining cost to reach the goal, without worrying whether this is
the best in the long run - hence the name ‘greedy search’.
• Greed is one of the 7 deadly sins, but it turns out that GS perform
quite well though not always optimal.
BestFS1: Greedy Search (cont)
BestFS1: Greedy Search (cont)

• GS resembles DFS in the way it prefers to follow a single path all


• the way to the goal, but will back up when it hits a dead end.

• Thus suffering the same defects as DFS - not optimal


and is incomplete.

• The worst-case time complexity for GS is O(bm), where m is the


• max depth of the search space.

• With good heuristic function, the space and time complexity


can be reduced substantially.
22

Best First Search Algorithm


•Algorithm: At any time, expand the most promising node
according to the heuristic
If the heuristic is always 0, best-first search is the same as
breadth-first search

Best-first search is a greedy method.


Greedy methods maximize short-term advantage without
worrying about long-term consequences.
23

Best First Search


Method
Function best_First_Search;
Begin
open := [Start];
closed:=[];
while open != []
do begin
remove the
leftmost
state from
open, call it
X;
If X = goal
then return
the path
from Start to
X
Else
begin
Generat
e
children
of X;
24

Best First Search Demonstration


A:10

B: C:
5 3

D:4 E: F:
2 6

G:0
Solution
25

Best First Search Demonstration


1. Open [A:10] : closed []
2. Evaluate A:10; open [C:3,B:5]; closed [A:10]
3. Evaluate C:3; open [B:5,F:6]; closed
4. [C:3,A:10]
5. Evaluate B:5; open [E:2,D:4,F:6]; closed
[C:3,B:5,A:10].
Evaluate E:2; open [G:0,D:4,F:6];
6.
closed [E:2,C:3,B:5,A:10]
Evaluate G:0; the solution / goal is reached
26

Best First Search Demonstration


27

Best First Search Demonstration


1. Open [A5] : closed []
2. Evaluate A5; open [B4,C4,D6]; closed [A5]
3. Evaluate B4; open [C4,E5,F5,D6]; closed
4. [B4,A5]
5. Evaluate C4; open [H3,G4,E5,F5,D6]; closed [C4,B4,A5].
6. Evaluate H3; open [O2,P3,G4,E5,F5,D6]; closed [H3,C4,B4,A5]
7. Evaluate O2; open [P3,G4,E5,F5,D6]; closed [O2,H3,C4,B4,A5]
Evaluate P3; THE SOLUTION IS FOUND!
Simple heuristic search procedure:
Hill Climbing
• Named so because it resembles an eager, but blind
mountain climber, you move in such direction in which
your height increased.
• Used a heuristic function which measure your height, or
measure remaining distance.

• As it keeps no history, the algorithm cannot recover


from failures of its strategy
Hill
Climbing
• Simplest way to implement heuristic search
• Expand current state in the search and evaluate its
children
• The best child is selected for further expansion; neither
its siblings nor parents are retained
12

Hill Climbing:
If the Node is better in terms of assigned heuristics, only then you proceed
to
that Node
Algorithm:
1. Start with current-state (cs) = initial state
2. Until cs = goal-state or there is no change in the cs
do:

(a) Get the successor of cs and use the EVALUATION


FUNCTION to assign a score to each successor
(b) If one of the successor has a better score than cs
then
set the new state to be the successor with the best
score.
Hill-climbing (cont)

•This simple policy has three


(a)
well- known drawbacks:
1. Local Maxima: a local
maximum
• as opposed to global (b)

maximum.
2. Plateaus: An area of the (c)
search
• space where evaluation
function
•is Figure 5.9 Local maxima, Plateaus and
ridge situation for Hill
• flat, thus requiring random Climbing

walk.
Optimal searches
• We have covered informed and uninformed
searches.
• Bothe have some advantages and
disadvantages.
• One common lacks in both:
• Immediately stop when find a solution
• Don’t look for an optimal solution
• Optimal search:
• Find all the possible solution using
either blind/heuristic
search.
• Choose the most optimal amongst
Branch and Bound (B& B)
• Some how related to heuristic search.
• Cut of the unnecessary search.

3 A 6 E 1

2 4
S D G
4 3
B
2

8 5
C
Branch and Bound

3 4 8
A B C
11
5 B 10 G
9
E D
7
6
8 D D
A

D D D E E G C 9
10 12 12 12 11 11
Branch and bound
• Some how related to heuristic search.
• Cut of the unnecessary search.

D
A
E
B 9
9 F G
30
. Branch and bound
The no show the distance b/w two cities
•.
3
2
A B
3
C
S 4 4
G
3
2
D 1 E 3 F
A
*•
A* (pronounced "A star") is a best-first, graph
search algorithm that finds the least-cost path
from a given initial node to one goal node (out
of one or more possible goals).
• Improve version of branch and bound.
• Uses a distance-plus-cost heuristic function
(usually denoted f(x)) to determine the order in
which the search visits nodes in the tree.
• Initially called algorithm A. Since using this
algorithm yields optimal behavior for a given
heuristic, it has been called A*.
Distance-Plus-Cost Heuristics function
• The distance-plus-cost heuristic is a sum of two functions:
• The path-cost function (usually denoted g(x)): cost from the starting
node to the current node.
• A heuristic estimate of the distance to the goal (usually denoted
h(x)).
• Total Cost: f(x) = g(x) + h(x)
A* Search
Algorithm
• At every step, take node n from the front of the queue
• Enqueue all its successors n" with priorities:
• f(n") = g(n") + h(n")
= cost of getting to n" + estimated cost from n" to goal
• Terminate when a goal state is popped from the queue.
A* Search
. The Algorithm
no show the distance b/w two cities
•. And the color no shows the under estimated
distance between that particular node and
the goal 2
node. 3
3 3
A B C 5
2
8
S 4 4
0 G
3 5 2
2
6 D E F
42

Examples of
Heuristics
43

Last Solution

You might also like