0% found this document useful (0 votes)
17 views34 pages

3.3informed Search

Uploaded by

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

3.3informed Search

Uploaded by

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

Vidya Vikas Education Trust’s

Universal College of Engineering, Vasai(E)

AI
CH:03
Solving Problems by Searching
Content
• Informed Search:
• Heuristic Function,
• Admissible Heuristic,
– Informed Search Technique:
• Greedy Best First Search,
• A* Search,
What is a Heuristic Search?

• Heuristics is an approach to problem-solving in which the objective


is to produce a working solution within a reasonable time frame.
• Instead of looking for a perfect solution, heuristic strategies look
for a quick solution that falls within an acceptable range of
accuracy.
• A Heuristic is a technique to solve a problem faster than classic
methods, or to find an approximate solution when classic methods
cannot.
• A Heuristic (or a heuristic function) takes a look at search
algorithms. At each branching step, it evaluates the available
information and makes a decision on which branch to follow.
Types of Heuristic
1.Admissible:
• In this heuristic function never over estimates
the cost of reaching the goal.
• H(n) is always less than or equal to actual cost
of lowest cost path from node ‘n’ to goal.
• H(n)<=H’(n)
– H(n) heuristic cost
– H’(n) actual cost
2.Non-Admissible-
In this heuristic function over estimates the cost
of reaching the goal.

H(n)>H’(n)
Example
Refer book
Informed Search Algorithms

• Algorithms have information on the goal state, which helps in more


efficient searching. This information is obtained by something
called a heuristic.
• Algorithms.
– Greedy best first Search,
– A* Search,
– Memory bounded heuristic Search.

• Search Heuristics: In an informed search, a heuristic is


a function that estimates how close a state is to the goal state. For
examples – Euclidean distance, etc. (Lesser the distance, closer the
goal.)
1. Greedy Best First Search

• It expands the node that is estimated to be


closest to goal.
• It expands nodes based on f(n) = h(n).
• It is implemented using priority queue.
• Greedy best-first search algorithm always selects the path which appears
best at that moment.
• It uses the heuristic function and search.
• Best-first search allows us to take the advantages of both algorithms.
• With the help of best-first search, at each step, we can choose the most
promising node.
• In the best first search algorithm, we expand the node which is closest to
the goal node and the closest cost is estimated by heuristic function,
• Heuristic value is a estimated value from node n to goal state.
Advantages:

● Best first search can switch between BFS and DFS by gaining the advantages of both the
algorithms.
● This algorithm is more efficient than BFS and DFS algorithms.

Disadvantages:

● It can get stuck in a loop as DFS.


● This algorithm is not optimal.
Refer note book for example
Expand the nodes of S and put in the CLOSED list

Initialization: Open [A, B], Closed [S]

Iteration 1: Open [A], Closed [S, B]

Iteration 2: Open [E, F, A], Closed [S, B]

: Open [E, A], Closed [S, B, F]

Iteration 3: Open [I, G, E, A], Closed [S, B, F]

: Open [I, E, A], Closed [S, B, F, G]

Hence the final solution path will be: S----> B----->F----> G


A* Algorithm
A* is formulated with weighted graphs, which means it
can find the best path involving the smallest cost in terms
of distance and time. This makes A* algorithm in artificial
intelligence an informed search algorithm for best-first
search.
A* algorithm works based on heuristic methods and this helps achieve
optimality. A* is a different form of the best-first algorithm.
When A* enters into a problem, firstly it calculates the cost to travel to the
neighbouring nodes and chooses the node with the lowest cost.
If The f(n) denotes the cost, A* chooses the node with the lowest f(n) value.
Here ‘n’ denotes the neighbouring nodes. The calculation of the value can
be done as shown below:
f(n)=g(n)+h(n)f(n)=g(n)+h(n)
g(n) = shows the shortest path’s value from the starting node to
node n
h(n) = The heuristic approximation of the value of the node
• The numbers written on edges represent the
distance between the nodes while the
numbers written on nodes represent the
heuristic values.

• Let us find the most cost-effective path to reach


from start state A to final state G using A*
Algorithm.
Let’s start with node A.Since A is a starting node, therefore, the value of

g(x) for A is zero and from the graph, we get the heuristic value of A is 11,

therefore

● g(x) + h(x) = f(x)


● 0+ 11 =11
● Thus for A, we can write
● A=11
Now from A, we can go to point B or point E, so we compute f(x) for each of them

● A→B=2+6=8
● A→E=3+6=9

Since the cost for A → B is less, we move forward with this path and compute the

f(x) for the children nodes of B

Since there is no path between C and G, the heuristic cost is set infinity or a very

high value
● A → B → C = (2 + 1) + 99= 102
● A → B → G = (2 + 9 ) + 0 = 11

Here the path A → B → G has the least cost but it is still more than the

cost of A → E, thus we explore this path further


A → E → D = (3 + 6) + 1 = 10
Comparing the cost of A → E → D with all the
paths we got so far and as this cost is least of all
we move forward with this path. And compute
the f(x) for the children of D
A → E → D → G = (3 + 6 + 1) +0 =10
Now comparing all the paths that lead us to the
goal, we conclude that A → E → D → G is the
most cost-effective path to get from A to G.
The numbers written on edges represent the distance between
the nodes.
The numbers written on nodes represent the heuristic value.
Find the most cost-effective path to reach from start state A to
final state J using A* Algorithm.
● We start with node A.
● Node B and Node F can be reached from node A.

A* Algorithm calculates f(B) and f(F).


● f(B) = 6 + 8 = 14
● f(F) = 3 + 6 = 9

Since f(F) < f(B), so it decides to go to node F.

Path- A → F
Node G and Node H can be reached from node F.

A* Algorithm calculates f(G) and f(H).


● f(G) = (3+1) + 5 = 9
● f(H) = (3+7) + 3 = 13

Since f(G) < f(H), so it decides to go to node G.

Path- A → F → G
Node I can be reached from node G.

A* Algorithm calculates f(I).


f(I) = (3+1+3) + 1 = 8
It decides to go to node I.

Path- A → F → G → I
Node E, Node H and Node J can be reached from node I.

A* Algorithm calculates f(E), f(H) and f(J).


● f(E) = (3+1+3+5) + 3 = 15
● f(H) = (3+1+3+2) + 3 = 12
● f(J) = (3+1+3+3) + 0 = 10

Since f(J) is least, so it decides to go to node J.

Path- A → F → G → I → J
Advantages:

● A* search algorithm is the best algorithm than other search algorithms.


● A* search algorithm is optimal and complete.
● This algorithm can solve very complex problems.
Disadvantages:

● It does not always produce the shortest path (longest)as it mostly based
on heuristics and approximation.
● A* search algorithm has some complexity issues.
● The main drawback of A* is memory requirement as it keeps all
generated nodes in the memory, so it is not practical for various large-
scale problems.
Thank you !

34

You might also like