internship ppt on smartinternz platform as salesforce developer
Informed Search.pptx
1. SRI KRISHNA COLLEGE OF ENGINEERING AND TECHNOLOGY
Kuniamuthur, Coimbatore, Tamilnadu, India
An Autonomous Institution, Affiliated to Anna University,
Accredited by NAAC with “A” Grade & Accredited by NBA (CSE, ECE, IT, MECH ,EEE, CIVIL& MCT)
SKCET- LECTURE
Course: Artificial Intelligence
Module: Agents & Its Techniques - Informed Search
Strategies
Faculty : Dr. P. Mohan Kumar,CSE
www.skcet.ac.in
SKCET- EEE MEASUREMENTS
AND INSTRUMENTATION
2. Completion of this lecture students will be able to :
◦ Understand Search Strategies of AI
◦ Students will be able to solve the
problems using Strategic approach
SKCET- CSE AI
SRI KRISHNA COLLEGE OF ENGINEERING AND TECHNOLOGY
Kuniamuthur, Coimbatore, Tamilnadu, India
An Autonomous Institution, Affiliated to Anna University,
Accredited by NAAC with “A” Grade & Accredited by NBA (CSE, ECE, IT, MECH ,EEE, CIVIL& MCT)
7. An informed search strategy uses knowledge
beyond the definition of the problem
The word "heuristic" means trial-and-error,
exploratory, unguaranteed, rule of thumb.
The knowledge is embodied in an evaluation
function f(n)
◦ Estimates the distance of node n from the goal
7
8. A combination of DFS and BFS
The idea of Best First Search is to use an
evaluation function to decide which adjacent is
most promising and then explore.
At each step, using an appropriate heuristic
function, the most promising node is selected
If the node is selected, quit
Otherwise, add it to the set of nodes generated so
far, and carry on with generating & selecting the
next node
8
9. An instance of tree or graph search
Fringe is ordered by f(n)
Several best-first algorithms
◦ Greedy, A*, …
Key is the heuristic function h(n)
◦ Heuristic measures distance from n to goal based
solely on the state at n
◦ Problem specific
◦ Constraint: h(n) = 0 if n is a goal node
9
10. function BEST-FIRST SEARCH (problem, Eval fn) returns a solution
sequence
inputs: problem, a problem
Eval fn, an evaluation function
Queueing-Fn a function that orders nodes by Eval fn
return GENERAL-SEARCH(problem,Queueing-Fn)
10
12. Insert best nodes at beginning of nodes according to h,
that is, f(n)=h(n)
function Greedy-Search(problem) -> solution
input: a problem
best-first-search(problem,h) -> solution
Consider the route finding problem.
◦ Can we use additional information to avoid costly paths that
lead nowhere?
◦ Consider using the straight line distance (SLD)
12
15. 15
So is Arad->Sibiu->Fagaras->Bucharest optimal?
Possibilities from Arad: Go to Zerind, Timisoara, or Sibiu?
Take as heuristic the air distance:
Zerind (374), Timisoara (329), or Sibiu (253)
Closest air distance Sibiu, hence go to Sibiu.
Possibilities from Sibiu: Arad, Fagaras, Oradea, or Rimnicu Vilcea?
Take as heuristic the air distance:
Arad (366), Fagaras (176), Oradea (380), or Rimnicu Vilcea (193)
Closest air distance Fagaras, hence go to Fagaras.
Possibilities from Fagaras: Go to Sibiu or Bucharest?
Take as heuristic the air distance:
Sibiu (253) or Bucharest (0)?
Closest air distance Bucharest, hence go to Bucharest.
That is 140km +99km +211km = 450km .
16. Not optimal.
Not complete.
◦ Could go down a path and never return to try another.
Time Complexity
◦ O(bm)
Space Complexity
◦ O(bm)
16
17. The greedy best-first search does not consider how costly it was to
get to a node.
It insert best nodes at beginning of nodes according to,
f(n)=g(n)+h(n)
g(n) - actual cost to that node
h(n) - estimated cost to the goal.
In the A* algorithm the heuristic function h must be optimistic in order
to find the best solution.
function A-star(problem) -> solution
input: a problem
best-first-search(problem, g+h) -> solution
17
19. 19
Possibilities from Arad: Go to Zerind, Timisoara, or Sibiu?
Take as heuristic the air distance plus cost to town:
Zerind (374+75=449), Timisoara (329+118=447), or Sibiu
(253+140=393)
Most promising Sibiu, hence explore going to Sibiu.
Possibilities from Sibiu: Arad, Fagaras, Oradea, or Rimnicu Vilcea?
Take as heuristic the air distance plus cost to town:
Arad (140+140+366=646), Fagaras (140+99+176=415), Oradea
(140+151+380=671), or Rimnicu Vilcea (140+80+193=413)
Overall most promising not expanded Rimnicu Vilcea, hence explore going to
Rimnicu Vilcea
20. 20
Possibilities from Rimnicu Vilcea: Sibiu, Pitesti, or Craiova?
Take as heuristic the air distance plus cost to town:
Sibiu (140+80+80+253=553), Pitesti (140+80+97+100=417), or Craiova
(140+80+146+160=526)
Overall most promising not expanded Fagaras, hence explore going to
Fagaras (from Sibiu)
Possibilities from Fagaras: Sibiu, or Bucharest?
Take as heuristic the air distance plus cost to town:
Sibiu (140+99+99+253=591), or Bucharest (140+99+211+0=450)
Overall most promising not expanded Pitesti, hence explore going to Pitesti
(from Rimnicu Vilcea)
21. 21
Possibilities from Pitesti: Rimnicu Vilcea, Craiova, or Bucharest?
Take as heuristic the air distance plus cost to town:
Rimnicu Vilcea (140+80+97+97+193=607), Craiova
(140+80+97+138+160=615) or Bucharest (140+80+97+101+0=418)
Overall most promising go to Bucharest from Pitesti.
Since there is no way to get on a shorter route to Bucharest the last one is
taken.
22. A heuristic function h(n) is admissible if the estimated cost is
never more than the actual cost from the current node to the
goal node.
To understand this, we can imagine a diagram as depicted below.
The direct path (heuristic) from A to C will never be more than the
actual cost (distance taking the path A -> B -> C).
Theorem:
If h(n) is consistent, A* using GRAPH-SEARCH is optimal
22
23. A heuristic is consistent if the cost from the current node to a
successor node, plus the estimated cost from the successor node to
the goal is less than or equal to the estimated cost from the
current node to the goal
In an equation, it would look like this: C(n, n’) + h(n’) ≤ h(n)
Theorem:
If h(n) is consistent, A* using GRAPH-SEARCH is optimal
23
24. Consider the heuristic such that h(n) = the minimum cost
from a successor of n to one of its own successors,
unless the successor is a goal node, in which case it is 0.
(i,e)h(n) = the minimum cost of it’s successor’s
successor.
So if we were to traverse A -> B -> C, h(A) would be
calculated from B -> C and NOT from A -> B
24
25. In this case h(1) =15 , but h(2) = 0 ,
so, 13, c(1,3) + h(3) > h(1) 20 >15
23 , c (2, 3) + h(3) > h(2) 15 > 0,
which violates consistency.
Note that the heuristic is still admissible because
h(1) =15 ≤ 20 = g (1),
h(2) = 0 ≤15 = g(2)
h(1) = 15 because by definition, h(1) is from 2 -> 3. C(1,
2) + h(2) = 5 because C(1, 2) = 5 and h(2) = 0 because
as stated above, since 3 is the goal node, as well as
2’s successor node, h(2) = 0.
25
26. Complete
◦ Yes! Same as above.
Time and Space Complexity
◦ Depends on h(n)
◦ Sub-exponential if where h*(n) is true cost of getting from n to
goal
◦ Optimally efficient
26
))
(
(log
)
(
)
( *
*
n
h
O
n
h
n
h
30. h1 = number of misplaced tiles
h2 = sum of distances of tiles to goal position.
30
31. Is h1
◦ admissible?
◦ consistent?
Is h2
◦ admissible?
◦ consistent?
31
32. Heuristics are often obtained from relaxed
problem
◦ Simplify the original problem by removing constraints
◦ The cost of an optimal solution to a relaxed problem is an
admissible heuristic.
32
33. Original
◦ A tile can move from A to B if A is horizontally or
vertically adjacent to B and B is blank.
Relaxations
◦ Move from A to B if A is adjacent to B
h2 by moving each tile in turn to destination
◦ Move from A to B if B is blank
◦ Move from A to B
h1 by simply moving each tile directly to destination.
33
34. What heuristic is obtained from
Move from A to B if B is blank?
Gaschnig’s heuristic (1979)
34
35. Suppose now that the bananas are hung from
the ceiling and the monkey needs to climb on a
box to get the bananas. In addition, walls exist in
the environment.
Box, monkey, and bananas placed randomly
Monkey can see the entire world.
Actions: N,S,E,W,Grab,Drop,Climb,Eat
35
36. Describe the problem as a search problem.
◦ Initial state, successor function, goal, path cost
In what way(s) can we relax the problem to obtain
a heuristic?
36
37. If h2(n) h1(n) for all n, then h2 dominates h1
◦ h2 is better for use with searching
For the 8-puzzle, h2 does dominate h1
◦ If a tile is out of place, it is at least a distance of 1 away
from its correct position. Since h1 counts the number of
out of place tiles, and h2 totals all of the distances,
h2(n) h1(n) for all n.
37