You are on page 1of 24

Artificial & Computational Intelligence

AMLCCZG557
M2 : Problem Solving Agent using Search
Indumathi V
BITS Pilani Guest Faculty
Pilani Campus
BITS -WILP
A*Search

Optimal on condition
h(n) must satisfies two conditions:
- Admissible Heuristic – one that never overestimates the cost to reach the goal
- Consistency – A heuristic is consistent if for every node n and every successor node
n` of n generated by action a, h(n) <= c(n, a, n`) + h(n`)

Complete
- If the number of nodes with cost <=C* is finite
- If the branching factor is finite
- A* expands no nodes with f(n) > C*, known as pruning

Time Complexity - 𝐺 𝑏∆ where the absolute error ∆ = ℎ∗ − ℎ

BITS Pilani, Pilani Campus


A*Search
Istheheuristicdesignedleadstooptimalsolution?

1
-A--ssuming node 3 as goal, taking only sample edges
75
70 per node below is checked for consistency
125
100 5
125
2
125
75
50 50

3 4 n h(n) Is Admissible? Is Consistent?


100
h(n) <= h*(n) For every arc (i,j):
h(i) <= g(i,j) + h(j)
1 80 Y N (51) : 190<=155
2 60 N Y (12) : 80<=130
3 0 Y
4 200 Y Y (14) : 80<=300
Y (24) : 60<=275
5 190 Y Y (25) : 60<=315
Y (45) : 200<=240
BITS Pilani, Pilani Campus
A*Search
Istheheuristicdesignedleadstooptimalsolution?

1
-A--ssuming node 3 as goal, taking only sample edges
75
70 per node below is checked for consistency
125
100 5
125
2
125
75
50 50

3 4 n h(n) Is Admissible? Is Consistent?


100
h(n) <= h*(n) For every arc (i,j):
h(i) <= g(i,j) + h(j)
1 80 Y N (51) : 190<=155
2 60 N Y (12) : 80<=130
3 0 Y
4 200 Y Y (14) : 80<=300
Y (24) : 60<=275
5 190 Y Y (25) : 60<=315
Y (45) : 200<=240
BITS Pilani, Pilani Campus
A*Search
Istheheuristicdesignedleadstooptimalsolution?

1
-A--ssuming node 3 as goal, taking only sample edges
75
70 per node below is checked for consistency
125
100 5
125
2
125
75
50 50

3 4 n h(n) Is Admissible? Is Consistent?


100
h(n) <= h*(n) For every arc (i,j):
h(i) <= g(i,j) + h(j)
1 80 Y N (51) : 190<=155
2 60 N Y (12) : 80<=130
3 0 Y
4 200 Y Y (14) : 80<=300
Y (24) : 60<=275
5 190 Y Y (25) : 60<=315
Y (45) : 200<=240
BITS Pilani, Pilani Campus
Variations of A*
Memory Bounded Heuristics

BITS Pilani, Pilani Campus


Iterative Deepening A*
Set limit for f(n)
1
1
75
70 125+40 = 165
125 3 4 2 70+94= 164
130 5
125 130+45 = 175
2
45
85
50 50 120+40
= 160 3 5 4
3 4 195+0= 195 155+45
100 165+0=165 = 200

n h(n) 5

1 60 4 220+45 = 265

Cut off value is the smallest of f-cost of any node that


exceeds the cutoff on previous iterations
2 94
Iterative Limit : Eg
3 40 f(n) = 180
f(n) = 195
f(n) = 200
4 45 .
.
.
5 0 .

BITS Pilani, Pilani Campus


BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
BITS Pilani, Pilani Campus
Recursive Best First Search A*
Remember the next best alternative f-Cost to regenerate
1 ∞
1
75 165
70 125+40 = 165
125 3 4 2 70+94= 164
130 5
125 130+45 = 175
2
55
85 165
50 50 120+40
= 160 3 4 5 195+0= 195
3 4 155+45
100 175+0=175 = 200

n h(n) 5

1 60 4 220+47 = 267

(1, 60)
2 94 (1 2 | 164) (1 3 | 165) (1 4 | 175)

(1 2 | 175) (1 4 | 175) (1 3 | 180)


3 40
(1 2 3 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200)

4 45 (1 2 3 5 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200) (1 2 3 4 | 267)

PASS
5 0

BITS Pilani, Pilani Campus


Recursive Best First Search A*
Remember the next best alternative f-Cost to regenerate
1 ∞
1
75 165
70 125+40 = 165
125 3 4 2 70+94= 164
130 5
125 130+45 = 175
2
55
85 165
50 50 120+40
= 160 3 4 5 195+0= 195
3 4 155+45
100 175+0=175 = 200

n h(n) 5

1 60 4 220+47 = 267

(1, 60)
2 94 (1 2 | 164) (1 3 | 165) (1 4 | 175)

(1 2 | 175) (1 4 | 175) (1 3 | 180)


3 40
(1 2 3 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200)

4 45 (1 2 3 5 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200) (1 2 3 4 | 267)

PASS
5 0

BITS Pilani, Pilani Campus


Recursive Best First Search A*
Remember the next best alternative f-Cost to regenerate
1 ∞
1
75 165
70 125+40 = 165
125 3 4 2 70+94= 164
130 5
125 130+45 = 175
2
55
85 165
50 50 120+40
= 160 3 4 5 195+0= 195
3 4 155+45
100 175+0=175 = 200

n h(n) 5

1 60 4 220+47 = 267

(1, 60)
2 94 (1 2 | 164) (1 3 | 165) (1 4 | 175)

(1 2 | 175) (1 4 | 175) (1 3 | 180)


3 40
(1 2 3 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200)

4 45 (1 2 3 5 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200) (1 2 3 4 | 267)

PASS
5 0

BITS Pilani, Pilani Campus


Recursive Best First Search A*
Remember the next best alternative f-Cost to regenerate
1 ∞
1
75 180 175
70 125+40 = 165
125 3 4 2 70+94= 164
130 5
125 130+45 = 175
2
55
85 175
50 50 120+40
= 160 3 4 5 195+0= 195
3 4 155+45
100 175+0=175 = 200

n h(n) 5

1 60 4 220+47 = 267

(1, 60)
2 94 (1 2 | 164) (1 3 | 165) (1 4 | 175)

(1 2 | 175) (1 4 | 175) (1 3 | 180)


3 40
(1 2 3 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200)

4 45 (1 2 3 5 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200) (1 2 3 4 | 267)

PASS
5 0

BITS Pilani, Pilani Campus


Recursive Best First Search A*
Remember the next best alternative f-Cost to regenerate
1 ∞
1
75 175 175
70 125+40 = 165
125 3 4 2 70+94= 164
130 5
125 130+45 = 175
2
55
85 175
50 50 120+40
= 160 3 4 5 195+0= 195
4
3 4 155+45
100 225+45 175+0=175 = 200
= 270 5
n h(n) 5
180+0= 180
1 60 4 220+47 = 267

(1, 60)
2 94 (1 2 | 164) (1 3 | 165) (1 4 | 175)

(1 2 | 175) (1 4 | 175) (1 3 | 180)


3 40
(1 2 3 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200)

4 45 (1 2 3 5 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200) (1 2 3 4 | 267)

PASS
5 0

BITS Pilani, Pilani Campus


Recursive Best First Search A*
Remember the next best alternative f-Cost to regenerate
1 ∞
1
75 175 175
70 125+40 = 165
125 3 4 2 70+94= 164
130 5
125 130+45 = 175
2
55
85 175
50 50 120+40
= 160 3 4 5 195+0= 195
4
3 4 155+45
100 225+45 175+0=175 = 200
= 270 5
n h(n) 5
180+0= 180
1 60 4 220+47 = 267

(1, 60)
2 94 (1 2 | 164) (1 3 | 165) (1 4 | 175)

(1 2 | 175) (1 4 | 175) (1 3 | 180)


3 40
(1 2 3 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200)

4 45 (1 2 3 5 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200) (1 2 3 4 | 267)

PASS
5 0

BITS Pilani, Pilani Campus


Recursive Best First Search A*
Remember the next best alternative f-Cost to regenerate
1 ∞
1
75 175 175
70 125+40 = 165
125 3 4 2 70+94= 164
130 5
125 130+45 = 175
2
55
85 175
50 50 120+40
= 160 3 4 5 195+0= 195
4
3 4 155+45
100 225+45 175+0=175 = 200
= 270 5
n h(n) 5
180+0= 180
1 60 4 220+47 = 267

(1, 60)
2 94 (1 2 | 164) (1 3 | 165) (1 4 | 175)

(1 2 | 175) (1 4 | 175) (1 3 | 180)


3 40
(1 2 3 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200)

4 45 (1 2 3 5 | 175) (1 4 | 175) (1 3 | 180) (1 2 5 | 195) (1 2 4 | 200) (1 2 3 4 | 267)

PASS
5 0

BITS Pilani, Pilani Campus


Recursive Best First Search A*
Remember the next best alternative f-Cost to regenerate
1 ∞
1
75 180 175
70 125+40 = 165
125 3 4 2 70+94= 164
130 5
125 130+45 = 175
2
55
85 175
50 50 120+40
= 160 3 4 5 195+0= 195
3 4 155+45
100 175+0=175 = 200

n h(n) 5

1 60 4 220+47 = 267

If the current best leaf value > best alternative path


2 94 Best leaf value of the forgotten subtree is backed up to the
ancestors
Recursion unwinds
3 40 Else
Continue expansion

4 45
Space Usage = O(bd) very less
5 0

BITS Pilani, Pilani Campus


Case Study – Search in Network Routing

Source Credit :
AR-RBFS: Aware-Routing Protocol Based on Recursive Best-First Search Algorithm for Wireless Sensor Networks
https://doi.org/10.1155/2016/8743927

BITS Pilani, Pilani Campus


Case Study – Search in Network Routing

Source Credit :
AR-RBFS: Aware-Routing Protocol Based on Recursive Best-First Search Algorithm for Wireless Sensor Networks
https://doi.org/10.1155/2016/8743927

BITS Pilani, Pilani Campus


Case Study – Search in Network Routing

Source Credit :
AR-RBFS: Aware-Routing Protocol Based on Recursive Best-First Search Algorithm for Wireless Sensor Networks
https://doi.org/10.1155/2016/8743927

BITS Pilani, Pilani Campus

You might also like