Professional Documents
Culture Documents
Contents
Best-First Search
A and IDA
Genetic Algorithms
(University of Freiburg)
Foundations of AI
2 / 31
Best-First Search
Search procedures differ in the way they determine the next node to
expand.
Uninformed Search: Rigid procedure with no knowledge of the cost of a
given node to the goal.
Informed Search: Knowledge of the worth of expanding a node n is
given in the form of an evaluation function f (n),
which assigns a real number to each node. Mostly,
f (n) includes as a component a heuristic function
h(n), which estimates the costs of the cheapest
path from n to the goal.
Best-First Search: Informed search procedure that expands the node
with the best f -value first.
(University of Freiburg)
Foundations of AI
3 / 31
General Algorithm
Best-first
searchtheisfrontier
an instance
ofinitial
the general
Tree-Search algorithm in
initialize
using the
state of problem
which finitialize
rontierthe
is explored
a priority
queue
ordered
by
an evaluation function f .
set to be empty
loop do
When f is ifalways
correct,
we then
do not
need
to search!
the frontier
is empty
return
failure
choose a leaf node and remove it from the frontier
if the node contains a goal state then return the corresponding solution
add the node to the explored set
the chosen node, adding
theofresulting
nodes to the frontier
(University expand
of Freiburg)
Foundations
AI
4 / 31
Greedy Search
(University of Freiburg)
Foundations of AI
5 / 31
Greedy Search
(University of Freiburg)
Foundations of AI
5 / 31
Heuristics
The evaluation function h in greedy searches is also called a heuristic
function or simply a heuristic.
The word heuristic is derived from the Greek word (note
also: !)
The mathematician Polya introduced the word in the context of problem
solving techniques.
In AI it has two meanings:
Heuristics are fast but in certain situations incomplete methods for
problem-solving [Newell, Shaw, Simon 1963] (The greedy search is actually
generally incomplete).
Heuristics are methods that improve the search in the average-case.
(University of Freiburg)
Foundations of AI
6 / 31
Oradea
71
75
Neamt
Zerind
87
151
Iasi
Arad
140
Sibiu
92
99
Fagaras
118
111
Vaslui
80
Rimnicu Vilcea
Timisoara
Lugoj
Pitesti
97
142
211
70
98
Mehadia
75
Dobreta
146
85
101
86
138
Bucharest
120
Craiova
(University of Freiburg)
Hirsova
Urziceni
90
Giurgiu
Foundations of AI
Arad
Bucharest
Craiova
Drobeta
Eforie
Fagaras
Giurgiu
Hirsova
Iasi
Lugoj
Mehadia
Neamt
Oradea
Pitesti
Rimnicu Vilcea
Sibiu
Timisoara
Urziceni
Vaslui
Zerind
366
0
160
242
161
176
77
151
226
244
241
234
380
100
193
253
329
80
199
374
Eforie
7 / 31
Arad
Arad
366
Sibiu
Timisoara
Zerind
253
329
374
Timisoara
Zerind
329
374
Timisoara
Zerind
329
374
Arad
Sibiu
Arad
Fagaras
Oradea
Rimnicu Vilcea
366
176
380
193
Arad
Sibiu
Arad
Fagaras
Oradea
Rimnicu Vilcea
380
193
366
Sibiu
Bucharest
253
(University of Freiburg)
Foundations of AI
8 / 31
Arad
Arad
366
Sibiu
Timisoara
Zerind
253
329
374
Timisoara
Zerind
329
374
Timisoara
Zerind
329
374
Arad
Sibiu
Arad
Fagaras
Oradea
Rimnicu Vilcea
366
176
380
193
Arad
Sibiu
Arad
Fagaras
Oradea
Rimnicu Vilcea
380
193
366
Sibiu
Bucharest
253
(University of Freiburg)
Foundations of AI
8 / 31
Arad
Arad
366
Sibiu
Timisoara
Zerind
253
329
374
Timisoara
Zerind
329
374
Timisoara
Zerind
329
374
Arad
Sibiu
Arad
Fagaras
Oradea
Rimnicu Vilcea
366
176
380
193
Arad
Sibiu
Arad
Fagaras
Oradea
Rimnicu Vilcea
380
193
366
(University of Freiburg)
Sibiu
Bucharest
253
Foundations of AI
8 / 31
Arad
Arad
366
Sibiu
Timisoara
Zerind
253
329
374
Timisoara
Zerind
329
374
Timisoara
Zerind
329
374
Arad
Sibiu
Arad
Fagaras
Oradea
Rimnicu Vilcea
366
176
380
193
Arad
Sibiu
Arad
Fagaras
Oradea
Rimnicu Vilcea
380
193
366
(University of Freiburg)
Sibiu
Bucharest
253
Foundations of AI
8 / 31
(University of Freiburg)
Foundations of AI
9 / 31
Foundations of AI
10 / 31
A Search Example
Oradea
71
75
Neamt
Zerind
87
151
Iasi
Arad
140
Sibiu
92
99
Fagaras
118
111
Vaslui
80
Rimnicu Vilcea
Timisoara
Lugoj
Pitesti
97
142
211
70
98
Mehadia
75
Dobreta
146
85
101
86
138
Bucharest
120
Craiova
(University of Freiburg)
Hirsova
Urziceni
90
Giurgiu
Foundations of AI
Arad
Bucharest
Craiova
Drobeta
Eforie
Fagaras
Giurgiu
Hirsova
Iasi
Lugoj
Mehadia
Neamt
Oradea
Pitesti
Rimnicu Vilcea
Sibiu
Timisoara
Urziceni
Vaslui
Zerind
366
0
160
242
161
176
77
151
226
244
241
234
380
100
193
253
329
80
199
374
Eforie
11 / 31
Arad
366=0+366
Arad
Sibiu
393=140+253
Timisoara
Zerind
447=118+329
449=75+374
Arad
Timisoara
Zerind
447=118+329
449=75+374
Sibiu
Arad
Fagaras
Oradea
Rimnicu Vilcea
Arad
Sibiu
Arad
Fagaras
Oradea
Timisoara
Zerind
447=118+329
449=75+374
Rimnicu Vilcea
Pitesti
Sibiu
Arad
Foundations of AI
12 / 31
Arad
366=0+366
Arad
Sibiu
393=140+253
Timisoara
Zerind
447=118+329
449=75+374
Arad
Timisoara
Zerind
447=118+329
449=75+374
Sibiu
Arad
Fagaras
Oradea
Rimnicu Vilcea
Arad
Sibiu
Arad
Fagaras
Oradea
Timisoara
Zerind
447=118+329
449=75+374
Rimnicu Vilcea
Pitesti
Sibiu
Arad
Foundations of AI
12 / 31
Arad
366=0+366
Arad
Sibiu
393=140+253
Fagaras
Zerind
449=75+374
Arad
Sibiu
Arad
Timisoara
447=118+329
Oradea
Timisoara
Zerind
447=118+329
449=75+374
Rimnicu Vilcea
Arad
Sibiu
Arad
Fagaras
Oradea
Timisoara
Zerind
447=118+329
449=75+374
Rimnicu Vilcea
Pitesti
Sibiu
Arad
Foundations of AI
12 / 31
Arad
366=0+366
Arad
Sibiu
393=140+253
Fagaras
Zerind
449=75+374
Arad
Sibiu
Arad
Timisoara
447=118+329
Oradea
Timisoara
Zerind
447=118+329
449=75+374
Rimnicu Vilcea
Arad
Sibiu
Arad
Fagaras
Oradea
Timisoara
Zerind
447=118+329
449=75+374
Rimnicu Vilcea
Pitesti
Sibiu
Arad
Foundations of AI
12 / 31
Arad
Fagaras
Oradea
Rimnicu Vilcea
Craiova
Pitesti
Sibiu
Arad
Sibiu
Arad
Fagaras
Rimnicu Vilcea
Bucharest
591=338+253 450=450+0
Craiova
Pitesti
Arad
Sibiu
Fagaras
Arad
Sibiu
Sibiu
646=280+366
Zerind
449=75+374
671=291+380
646=280+366
Sibiu
Oradea
Timisoara
447=118+329
Timisoara
Zerind
447=118+329
449=75+374
Rimnicu Vilcea
Oradea
671=291+380
Bucharest
591=338+253 450=450+0
Craiova
Pitesti
526=366+160
Bucharest
Sibiu
553=300+253
Craiova
Rimnicu Vilcea
(University of Freiburg)
Foundations of AI
12 / 31
Arad
Fagaras
Oradea
Rimnicu Vilcea
Craiova
Pitesti
Sibiu
Arad
Sibiu
Arad
Fagaras
Rimnicu Vilcea
Bucharest
591=338+253 450=450+0
Craiova
Pitesti
Arad
Sibiu
Fagaras
Arad
Sibiu
Sibiu
646=280+366
Zerind
449=75+374
671=291+380
646=280+366
Sibiu
Oradea
Timisoara
447=118+329
Timisoara
Zerind
447=118+329
449=75+374
Rimnicu Vilcea
Oradea
671=291+380
Bucharest
591=338+253 450=450+0
Craiova
Pitesti
526=366+160
Bucharest
Sibiu
553=300+253
Craiova
Rimnicu Vilcea
(University of Freiburg)
Foundations of AI
12 / 31
(University of Freiburg)
Foundations of AI
13 / 31
Optimality of A
Claim: The first solution found has the minimum path cost.
Proof: Suppose there exists a goal node G with optimal path cost f , but
A has found another node G2 with g(G2 ) > f .
Start
(University of Freiburg)
G2
Foundations of AI
14 / 31
Optimality of A
Let n be a node on the path from the start to G that has not yet been
expanded. Since h is admissible, we have
f (n) f .
Since n was not expanded before G2 , the following must hold:
f (G2 ) f (n)
and
f (G2 ) f .
It follows from h(G2 ) = 0 that
g(G2 ) f .
Contradicts the assumption!
(University of Freiburg)
Foundations of AI
15 / 31
Foundations of AI
16 / 31
5
8
Goal State
Start State
(University of Freiburg)
Foundations of AI
17 / 31
5
8
Goal State
Start State
h1 = the number of tiles in the wrong position
(University of Freiburg)
Foundations of AI
17 / 31
5
8
Goal State
Start State
(University of Freiburg)
Foundations of AI
17 / 31
Empirical Evaluation
d = distance from goal
Average over 100 instances
d
2
4
6
8
10
12
14
16
18
20
22
24
(University of Freiburg)
Foundations of AI
Variants of A
(University of Freiburg)
Foundations of AI
19 / 31
(University of Freiburg)
Foundations of AI
20 / 31
12
14
13
13
12
14
14
14
16
13
15
12
14
12
16
14
12
18
13
15
12
14
14
15
14
14
13
16
13
16
14
17
15
14
16
16
16
18
15
15
15
14
17
12
14
17
(University of Freiburg)
18
14
14
14
13
15
Foundations of AI
16
12
18
21 / 31
Hill Climbing
Figure 4.2
The hill-climbing search algorithm, which is the most basic local sea
each step the current node is replaced by the best neighbor; in this version, that m
with the highest VALUE, but if a heuristic cost estimate h is used, we would find the
lowest h.
(University of Freiburg)
Foundations of AI
22 / 31
1
2
3
0
(University of Freiburg)
Foundations of AI
23 / 31
(University of Freiburg)
Foundations of AI
24 / 31
(University of Freiburg)
Foundations of AI
25 / 31
(University of Freiburg)
Foundations of AI
26 / 31
(University of Freiburg)
Foundations of AI
27 / 31
Figure Annealing
4.2
The hill-climbing search algorithm, which is the most basic local search technique.
Simulated
each step the current node is replaced by the best neighbor; in this version, that means the neigh
with the highest VALUE, but if a heuristic cost estimate h is used, we would find the neighbor with
lowest h.
Has been
usedmoves
sincearethe
earlyDownhill
80s for
VSLI
layoutreadily
and early
other
optimization
downhill
allowed.
moves
are accepted
in the
annealing schedule
then less often as time goes on. The schedule input determines the value of the temperature T a
problems.
function of time.
(University of Freiburg)
Foundations of AI
28 / 31
Genetic Algorithms
(University of Freiburg)
Foundations of AI
29 / 31
Foundations of AI
30 / 31
Summary
Heuristics focus the search
Best-first search expands the node with the highest worth (defined by
any measure) first.
With the minimization of the evaluated costs to the goal h we obtain a
greedy search.
The minimization of f (n) = g(n) + h(n) combines uniform and greedy
searches. When h(n) is admissible, i.e., h is never overestimated, we
obtain the A search, which is complete and optimal.
IDA is a combination of the iterative-deepening and A searches.
Local search methods only ever work on one state, attempting to
improve it step-wise.
Genetic algorithms imitate evolution by combining good solutions.
(University of Freiburg)
Foundations of AI
31 / 31