04 Informed Search Annot
04 Informed Search Annot
G. Lakemeyer
Best-First Search: always expand the node with the “best” f -value.
AI/WS-2024/25 2 / 20
Greedy Search Example
Straight−line distance
Oradea to Bucharest
71
Neamt Arad 366
Bucharest 0
Zerind 87
75
151 Craiova 160
Iasi Dobreta 242
Arad
140
Eforie 161
92 Fagaras
-
Sibiu
178
99 Fagaras Giurgiu 77
118 Hirsova 151
Vaslui
80 Iasi 226
Rimnicu Vilcea Lugoj
Timisoara 244
Mehadia 241
142
111 Pitesti 211 Neamt 234
Lugoj 97 Oradea 380
70 98 Pitesti 98
85 Hirsova
Mehadia 146 101 Urziceni Rimnicu Vilcea 193
86 Sibiu 253
Copdine
75 138 Bucharest Timisoara 329
120 Urziceni
Dobreta
90
80
Craiova Eforie Vaslui 199
Zerind
© G. Lakemeyer
Giurgiu 374
Arad
h=366
Arad
Sibiu
h=253
Timisoara
h=329
Zerind
h=374
ninte
Arad
Sibiu Bucharest
h=253 h=0
AI/WS-2024/25 3 / 20
A⇤
combines uniform cost search with greedy search.
f (n) = is the estimated cost of the cheapest path which passes through n.
© G. Lakemeyer
Let h⇤ (n) be the actual cost of the optimal path from n to the nearest goal.
Admissible Heuristic
h is called admissible if we have for all n:
h (n ) h ⇤ (n ) .
Path-Max Equation
Let n, n0 be nodes, where is n parent of n0 . Then let
n(n) = 4 ⑪ g(ni = 3 =
f(n) =
7
in
G
© G. Lakemeyer
un =
2 g(n = 4
AI/WS-2024/25 6 / 20
Example Why A⇤ is Optimal
Start
u (A) = 13
⑪
⑤
⑤
h(r)
95/ &
=
1 t = 25
greD (D = 0
i A
© G. Lakemeyer
15
j =
if h(d =
20 (non-admissible. !)
then the optimal solution
in not
found .
AI/WS-2024/25 7 / 20
Contour Lines in A⇤
nodes outside the
contour lives are
O
never expanded.
- N
Z
I
A
380 S
F -gas e V
© G. Lakemeyer
400
T R
L P
H
M U
B
D f
= 420
E
C
G
AI/WS-2024/25 8 / 20
Another Example Illustrating Contour Lines
-
-
48
5 40-
=
40
O
!
D -
=
© G. Lakemeyer
time and
space complexity O(ba)
note expansion is exponential
=> in
general
except when
(let *Cl) be the optimue cost
of reaching a
gorl from n)
1Scn) -
Sen = O
(log n (h)
AI/WS-2024/25 9 / 20
Theorem: A⇤ is Optimal for Admissible h
Proof by contradiction :
,
beanopen
Suppose At pick G'
for expansion
since n was
⑤ expansion ,
f(G)
⑳ his a
leaf f(n) =
( * /(6)
node in the nence
searchite
on the path
Since is
G' a
gal
Jo G h(G) = 0
AI/WS-2024/25
Then 10 / 20
Heuristic Function 1
5 4 5
1 4
2 3
S G
6 1 88 6
8 84
7 3 22 7 6 25
AI/WS-2024/25 11 / 20
Heuristic Function 1
5 4 5
1 4
2 3
6 1 88 6
8 84
7 3 22 7 6 25
AI/WS-2024/25 11 / 20
Heuristic Function 2
tant
e
i
d
· IDS
Search Cost
A*(h1 ) A*(h2 ) IDS
Effective Branching Factor
A*(h1 ) A*(h2 )
2 10 6 6 2.45 1.79 1.79
4 112 13 12 2.87 1.48 1.45
6 680 20 18 2.73 1.34 1.30
© G. Lakemeyer
AI/WS-2024/25 12 / 20
How to Find a Heuristic
General Strategy:
Simplify the problem
Compute the exact solution for the simplified problem
Use the solution cost as heuristic
© G. Lakemeyer
AI/WS-2024/25 13 / 20
How to Find a Heuristic
General Strategy:
Simplify the problem
Compute the exact solution for the simplified problem
Use the solution cost as heuristic
© G. Lakemeyer
For example:
h1 is the solution cost for the simplified 8-puzzle where tiles can be
placed at an arbitrary position with a single action.
h2 corresponds to the exact solution, if tiles can be moved to an arbitrary
position but actions are restricted to moving a tile to a neighboring
position.
AI/WS-2024/25 13 / 20
Pattern Databases
7 2 4 1 2
5 6 3 4 5
8 3 1 6 7 8
2 4 1 2
© G. Lakemeyer
5 6 3 4
5 6
8 3 1 7 8
Idea: Compute the exact solution for each pattern with four numbers and use
that value as heuristic. When more than one pattern applies, use the
maximum value. cannot take the sum of the
Better than Manhattan! voitures 2 patterns that match
for
because they sharemoves.
AI/WS-2024/25
/solution here :
only court moves
If 14 / 20
numbered tils .
Iterative Deepening A⇤
Combination of A⇤ and iterative deepening search.
Instead of fixed level increase use f -costs instead.
840 .....
20
o 40
G --------
-
>
g -
40
O -- _ T
© G. Lakemeyer
-- Ol
-do DFS
using currentf-cost
- remember
f cost of the
first mode
large
than the current f-cost
- pick the smallest of those for the
next iteration .
AI/WS-2024/25 15 / 20
IDA⇤ Algorithm
function IDA*( problem) returns a solution sequence
inputs: problem, a problem
static: f-limit, the current f - COST limit
root, a node
root MAKE-NODE(INITIAL-STATE[problem])
f-limit f - COST(root)
loop do
solution, f-limit DFS-CONTOUR(root, f-limit)
if solution is non-null then return solution
© G. Lakemeyer
function DFS-CONTOUR(node, f-limit) returns a solution sequence and a new f - COST limit
inputs: node, a node
f-limit, the current f - COST limit
static: next-f, the f - COST limit for the next contour, initially
AI/WS-2024/25 16 / 20
Hill Climbing
evaluation
o start with
current
state better Er
many randomly
Schoen
© G. Lakemeyer
state
AI/WS-2024/25 18 / 20
Beam Search
AI/WS-2024/25 19 / 20
Simulated Annealing
current MAKE-NODE(INITIAL-STATE[problem])
for t 1 to do
T schedule[t]
if T=0 then return current
next a randomly selected successor of current
-
∆E VALUE[next] – VALUE[current]
if ∆E > 0 then current next
else current next only with probability e∆E/T
AI/WS-2024/25 20 / 20