Heuristic in AI (Rule of thumb) [what, why, how] What: Mental shortcuts that ease the cognitive load of making a decision. Why: Solve problems and speed up our decision-making process How: Eucledian Distance, Manhattan Distance, etc
abihanaqvi8
6 views
55 slides
Sep 01, 2025
Slide 1 of 55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
About This Presentation
Estimated cost (or distance) of minimal cost path from start to a goal state.
h(n) → a heuristic function
Purpose of heuristic function is to guide the search process in the most profitable path among all that are available
Introduction Search with domain knowledge. Uninformed (blind) searches are normally very inefficient. Why?????? Adding domain knowledge can improve the search process. Heuristic Search Greedy Best-First Search A* Search
Informed methods add domain-specific information Estimated cost (or distance) of minimal cost path from start to a goal state. h(n) → a heuristic function Purpose of heuristic function is to guide the search process in the most profitable path among all that are available
Heuristic Solution Heuristic in AI (Rule of thumb) [what, why, how] What : Mental shortcuts that ease the cognitive load of making a decision. Why : Solve problems and speed up our decision-making process How: Eucledian Distance, Manhattan Distance, etc It is a provide the Good Solution. But not provides the guarantee of the optimal solution .
Eucledian Distance Calculate Distance using Pythagoras theorem. X-Axis Y-Axis (x 1 ,y 1 ) (x 2 ,y 2 ) A B C AC 2 = AB 2 + BC 2 AC = AB 2 + BC 2 AC = (x 2 -x 1 ) 2 + (y 2 -y 1 ) 2 x 1 x 2 y 1 y 2
8-Puzzle Problem with Heuristic 1 2 3 4 6 7 5 8 1 2 3 7 4 6 5 8 1 2 3 4 6 7 5 8 1 2 3 4 6 7 5 8 2 3 1 4 6 7 5 8 1 2 3 4 6 7 5 8 1 2 3 4 5 6 7 8 Start State Goal Move UP h=4 Move Down h=4 Move Right h =2 Move Left (NA) h =Nil Initial h=3
8-Puzzle Problem with Heuristic 1 2 3 4 6 7 5 8 1 2 3 4 5 6 7 8 1 2 3 4 6 7 5 8 1 2 3 4 6 7 5 8 1 3 4 2 6 7 5 8 1 2 3 4 6 7 5 8 1 2 3 4 5 6 7 8 Start State Goal Move UP h=3 Move Down h=1 Move Right h =3 Move Left h =3 Previous h=2
8-Puzzle Problem with Heuristic 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 6 7 5 8 1 2 3 4 6 7 5 8 1 2 3 4 5 6 7 8 Start State Goal Move UP h=2 Move Down (NA) h=Nil Move Right h =0 Move Left h =1 Previous h=1 1 2 3 4 5 6 7 8
Heuristic Search - Characteristics Has some domain knowledge Usually more efficient than blind searches Also called informed search Heuristic searches work by deciding which is the next best node to expand (there is no guarantee that it is the best node)
Greedy Best-First Search Greedy best-first search algorithm always selects the path which appears best at that moment. It is the combination of depth-first search and breadth-first search algorithms. It uses the heuristic function and search. Best-first search allows us to take the advantages of both algorithms .
Greedy Best-First Search Expand the node with the lowest expected cost. Not always guaranteed to find an optimal solution . Behaves like DFS: follows to depth paths that look promising. Advantage : moves quickly towards the goal. Disadvantage : can get stuck in deep paths.
GBS – Exampl e 1 Path H(n) Cost S->A 7 1 S->B 7 1 A->B 9 9 B->C 8 6 B->G 8 12 C->G 5 5 S/7 B/8 A/9 C/5 G/0 1 1 9 12 6 5 Nodes Node S H(n) 7 Closed List Open List Distance:
GBS – Exampl e 1 Path H(n) Cost S->A 7 1 S->B 7 1 A->B 9 9 B->C 8 6 B->G 8 12 C->G 5 5 S/7 B/8 A/9 C/5 G/0 1 1 9 12 6 5 Nodes S/7 Node A B H(n) 9 8 Closed List Open List Distance:
GBS – Exampl e 1 Path H(n) Cost S->A 7 1 S->B 7 1 A->B 9 9 B->C 8 6 B->G 8 12 C->G 5 5 S/7 B/8 A/9 C/5 G/0 1 1 9 12 6 5 Nodes S/7 Node A B H(n) 9 8 Closed List Open List Distance:
GBS – Exampl e 1 Path H(n) Cost S->A 7 1 S->B 7 1 A->B 9 9 B->C 8 6 B->G 8 12 C->G 5 5 S/7 B/8 A/9 C/5 G/0 1 1 9 12 6 5 Nodes S/7 B/8 Node A C G H(n) 9 5 Closed List Open List Distance: 1 +
GBS – Exampl e 1 Path H(n) Cost S->A 7 1 S->B 7 1 A->B 9 9 B->C 8 6 B->G 8 12 C->G 5 5 S/7 B/8 A/9 C/5 G/0 1 1 9 12 6 5 Nodes S/7 B/8 Node A C G H(n) 9 5 Closed List Open List Distance: 1 +
GBS – Exampl e 1 Path H(n) Cost S->A 7 1 S->B 7 1 A->B 9 9 B->C 8 6 B->G 8 12 C->G 5 5 S/7 B/8 A/9 C/5 G/0 1 1 9 12 6 5 Nodes S/7 B/8 G/0 Node A C H(n) 9 5 Closed List Open List Distance: 1 + 12 = 13
GBS – Exampl e 2
A* Search A * algorithm is a searching algorithm that searches for the shortest path between the initial and the final state. f(n) =g(n) + h(n) g(n) = Actual cost from Start node to n node h(n) = Estimation Cost from n to Goal node. Time complexity = O(Node + Edges) = O(b d ) Space complexity = O(b d )
Summary Greedy search: Estimated cost of reaching goal from current state – Heuristic evaluation functions, h(n). A* search: f(n) = g(n) + h(n). A* uses both backward costs and (estimates of) forward costs. Admissibility: h(n)never overestimates the actual cost of getting to the goal state.