s m h t i r o lg a - unibo.it · 2013-02-09 · c) i st i r eu = e t a m i est of cost om r f n to...
TRANSCRIPT
Informed
search
algorit
hms
Chapter
4,Sectio
ns
1–2
Chapte
r4,Sec
tions
1–2
1
Outlin
e
!B
est-
first
sear
ch
!A!
sear
ch
!H
eurist
ics
Chapte
r4,Sec
tions
1–2
2
Rev
iew
:Tre
ese
arc
h
functi
on
Tree-S
earch(p
robl
em,f
ringe
)re
turn
sa
solu
tion
,or
failu
refr
inge
!In
sert(M
ake-N
ode(I
nit
ial-S
tate[p
robl
em])
,fri
nge
)lo
op
do
iffr
inge
isem
ptyth
en
retu
rnfa
ilure
nod
e!
Remove-F
ront(fri
nge
)if
Goal-T
est
[pro
blem
]ap
plie
dto
State(n
ode)
succ
eeds
retu
rnnod
e
frin
ge!
Inse
rtA
ll(E
xpand
(nod
e,pro
blem
),fr
inge
)
Ast
rate
gyis
defin
edby
pick
ing
theord
er
ofnode
expansi
on
Chapte
r4,Sec
tions
1–2
3
Bes
t-firs
tse
arc
h
Idea
:us
ean
eval
uation
func
tion
for
each
node
–es
tim
ate
of“d
esirab
ility
”
"Exp
and
mos
tde
sira
ble
unex
pand
edno
de
Impl
emen
tation
:fr
inge
isa
queu
eso
rted
inde
crea
sing
orde
rof
desira
bilit
y
Spec
ialca
ses:
gree
dyse
arch
A!
sear
ch
Chapte
r4,Sec
tions
1–2
4
Rom
ania
with
step
cost
sin
km
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti
Rim
nicu
Vilc
ea
Vaslui
Iasi
Stra
ight−l
ine
dista
nce
to B
ucha
rest
0160
242
161 77 151
241
366
193
178
253
329 80 199
244
380
226
234
37498
Giurgiu
Urziceni
Hirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
Dobreta
Craiova
Sibiu
Fagaras
Pitesti
Vaslui
Iasi
Rim
nicu
Vilc
ea
Bucharest
71
75
118
111
70 75120
151
140
99
80
97
10121
1
138
146
85
90
9814292
87
86
Chapte
r4,Sec
tions
1–2
5
Gre
edy
searc
h
Eva
luat
ion
func
tion
h(n
)(h
eurist
ic)
=es
tim
ate
ofco
stfrom
nto
the
clos
est
goal
E.g
.,h
SLD(n
)=
stra
ight
-lin
edi
stan
cefrom
nto
Buc
hare
st
Gre
edy
sear
chex
pand
sth
eno
deth
atappears
tobe
clos
est
togo
al
Chapte
r4,Sec
tions
1–2
6
Gre
edy
searc
hex
am
ple
Arad
366
Chapte
r4,Sec
tions
1–2
7
Gre
edy
searc
hex
am
ple
Zerind
Arad
Sibiu
Timisoara
253
329
374
Chapte
r4,Sec
tions
1–2
8
Gre
edy
searc
hex
am
ple
Rimn
icu V
ilcea
Zerind
Arad
Sibiu
Arad
Fagaras
Oradea
Timisoara
329
374
366
176
380
193
Chapte
r4,Sec
tions
1–2
9
Gre
edy
searc
hex
am
ple
Rimn
icu V
ilcea
Zerind
Arad
Sibiu
Arad
Fagaras
Oradea
Timisoara
Sibiu
Bucharest
329
374
366
380
193
253
0
Chapte
r4,Sec
tions
1–2
10
Pro
per
ties
ofgre
edy
searc
h
Com
plet
e??
Chapte
r4,Sec
tions
1–2
11
Pro
per
ties
ofgre
edy
searc
h
Com
plet
e??
No–
can
get
stuc
kin
loop
s,e.
g.,w
ith
Ora
dea
asgo
al,
Iasi#
Nea
mt#
Iasi#
Nea
mt#
Com
plet
ein
finite
spac
ew
ith
repe
ated
-sta
tech
ecki
ng
Tim
e??
Chapte
r4,Sec
tions
1–2
12
Pro
per
ties
ofgre
edy
searc
h
Com
plet
e??
No–
can
get
stuc
kin
loop
s,e.
g.,
Iasi#
Nea
mt#
Iasi#
Nea
mt#
Com
plet
ein
finite
spac
ew
ith
repe
ated
-sta
tech
ecki
ng
Tim
e??
O(b
m),
but
ago
odhe
uristic
can
give
dram
atic
impr
ovem
ent
Spac
e??
Chapte
r4,Sec
tions
1–2
13
Pro
per
ties
ofgre
edy
searc
h
Com
plet
e??
No–
can
get
stuc
kin
loop
s,e.
g.,
Iasi#
Nea
mt#
Iasi#
Nea
mt#
Com
plet
ein
finite
spac
ew
ith
repe
ated
-sta
tech
ecki
ng
Tim
e??
O(b
m),
but
ago
odhe
uristic
can
give
dram
atic
impr
ovem
ent
Spac
e??
O(b
m)—
keep
sal
lno
des
inm
emor
y
Opt
imal
??
Chapte
r4,Sec
tions
1–2
14
Pro
per
ties
ofgre
edy
searc
h
Com
plet
e??
No–
can
get
stuc
kin
loop
s,e.
g.,
Iasi#
Nea
mt#
Iasi#
Nea
mt#
Com
plet
ein
finite
spac
ew
ith
repe
ated
-sta
tech
ecki
ng
Tim
e??
O(b
m),
but
ago
odhe
uristic
can
give
dram
atic
impr
ovem
ent
Spac
e??
O(b
m)—
keep
sal
lno
des
inm
emor
y
Opt
imal
??N
o
Chapte
r4,Sec
tions
1–2
15
A!se
arc
h
Idea
:av
oid
expa
ndin
gpa
ths
that
are
alre
ady
expe
nsiv
e
Eva
luat
ion
func
tion
f(n
)=
g(n
)+
h(n
)
g(n
)=
cost
sofa
rto
reac
hn
h(n
)=
estim
ated
cost
togo
alfrom
nf(n
)=
estim
ated
tota
lco
stof
path
thro
ugh
nto
goal
A!
sear
chus
esan
adm
issibl
ehe
uristic
i.e.,
h(n
)$
h!(n
)w
here
h!(n
)is
thetr
ue
cost
from
n.
(Also
requ
ire
h(n
)%
0,so
h(G
)=
0fo
ran
ygo
alG
.)
E.g
.,h
SLD(n
)ne
ver
over
estim
ates
the
actu
alro
addi
stan
ce
The
orem
:A!
sear
chis
optim
al
Chapte
r4,Sec
tions
1–2
16
A!se
arc
hex
am
ple
Arad
366=0+366
Chapte
r4,Sec
tions
1–2
17
A!se
arc
hex
am
ple
Zerind
Arad
Sibiu
Timisoara
447=118+329
449=75+374
393=140+253
Chapte
r4,Sec
tions
1–2
18
A!se
arc
hex
am
ple
Zerind
Arad
Sibiu
Arad
Timisoara
Rimn
icu V
ilcea
Fagaras
Oradea
447=118+329
449=75+374
646=280+366
413=220+193
415=239+176671=291+380
Chapte
r4,Sec
tions
1–2
19
A!se
arc
hex
am
ple
Zerind
Arad
Sibiu
Arad
Timisoara
Fagaras
Oradea
447=118+329
449=75+374
646=280+366
415=239+176
Rimn
icu V
ilcea
Craiova
Pitesti
Sibiu
526=366+160
553=300+253
417=317+100
671=291+380
Chapte
r4,Sec
tions
1–2
20
A!se
arc
hex
am
ple
Zerind
Arad
Sibiu
Arad
Timisoara
Sibiu
Bucharest
Rimn
icu V
ilcea
Fagaras
Oradea
Craiova
Pitesti
Sibiu
447=118+329
449=75+374
646=280+366
591=338+253
450=450+0
526=366+160
553=300+253
417=317+100
671=291+380
Chapte
r4,Sec
tions
1–2
21
A!se
arc
hex
am
ple
Zerind
Arad
Sibiu
Arad
Timisoara
Sibiu
Bucharest
Rimn
icu V
ilcea
Fagaras
Oradea
Craiova
Pitesti
Sibiu
Bucharest
Craiova
Rimn
icu V
ilcea
418=418+0
447=118+329
449=75+374
646=280+366
591=338+253
450=450+0
526=366+160
553=300+253
615=455+160
607=414+193
671=291+380
Chapte
r4,Sec
tions
1–2
22
Optim
ality
ofA
!(s
tandard
pro
of)
Supp
ose
som
esu
bopt
imal
goal
G2
has
been
gene
rate
dan
dis
inth
equ
eue.
Letn
bean
unex
pand
edno
deon
ash
orte
stpa
thto
anop
tim
algo
alG
1.
G
n
G2
Start
f(G
2)
=g(G
2)
sinc
eh(G
2)
=0
>g(G
1)
sinc
eG
2is
subop
tim
al
%f(n
)si
nce
his
adm
issi
ble
Sinc
ef(G
2)>
f(n
),A!
will
neve
rse
lect
G2
for
expa
nsio
n
Chapte
r4,Sec
tions
1–2
23
Optim
ality
ofA
!(m
ore
use
ful)
Lem
ma:
A!
expa
nds
node
sin
orde
rof
incr
easing
fva
lue!
Gra
dual
lyad
ds“f
-con
tour
s”of
node
s(c
f.br
eadt
h-fir
stad
dsla
yers
)Con
tour
iha
sal
lno
des
with
f=
fi,
whe
ref i
<f i
+1
O
Z
A T
L M
DC
R
F
P
G
BU
H E
V
I
N
380
400
420
S
Chapte
r4,Sec
tions
1–2
24
Pro
per
ties
ofA
!
Com
plet
e??
Chapte
r4,Sec
tions
1–2
25
Pro
per
ties
ofA
!
Com
plet
e??
Yes
,un
less
ther
ear
ein
finitel
ym
any
node
sw
ith
f$
f(G
)
Tim
e??
Chapte
r4,Sec
tions
1–2
26
Pro
per
ties
ofA
!
Com
plet
e??
Yes
,un
less
ther
ear
ein
finitel
ym
any
node
sw
ith
f$
f(G
)
Tim
e??
Exp
onen
tial
in[rel
ativ
eer
ror
inh&
leng
thof
soln
.]
Spac
e??
Chapte
r4,Sec
tions
1–2
27
Pro
per
ties
ofA
!
Com
plet
e??
Yes
,un
less
ther
ear
ein
finitel
ym
any
node
sw
ith
f$
f(G
)
Tim
e??
Exp
onen
tial
in[rel
ativ
eer
ror
inh&
leng
thof
soln
.]
Spac
e??
Kee
psal
lno
des
inm
emor
y
Opt
imal
??
Chapte
r4,Sec
tions
1–2
28
Pro
per
ties
ofA
!
Com
plet
e??
Yes
,un
less
ther
ear
ein
finitel
ym
any
node
sw
ith
f$
f(G
)
Tim
e??
Exp
onen
tial
in[rel
ativ
eer
ror
inh&
leng
thof
soln
.]
Spac
e??
Kee
psal
lno
des
inm
emor
y
Opt
imal
??Yes
—ca
nnot
expa
ndf
i+1
untilf i
isfin
ishe
d
A!
expa
nds
allno
des
with
f(n
)<
C!
A!
expa
nds
som
eno
des
with
f(n
)=
C!
A!
expa
nds
nono
des
with
f(n
)>
C!
Chapte
r4,Sec
tions
1–2
29
Pro
ofofle
mm
a:
Consi
sten
cy
Ahe
uristic
isco
nsiste
ntif
nc(n,a,n’) h(n’)
h(n) G
n’
h(n
)$
c(n,a
,n" )
+h(n
" )
Ifh
isco
nsiste
nt,we
have
f(n
" )=
g(n
" )+
h(n
" )
=g(n
)+
c(n,a
,n" )
+h(n
" )
%g(n
)+
h(n
)
=f(n
)
I.e.,
f(n
)is
nond
ecre
asin
gal
ong
any
path
.
Chapte
r4,Sec
tions
1–2
30
Adm
issi
ble
heu
rist
ics
E.g
.,fo
rth
e8-
puzz
le:
h1(n
)=
num
ber
ofm
ispl
aced
tile
sh
2(n
)=
tota
lM
anha
ttan
dist
ance
(i.e
.,no
.of
squa
res
from
desire
dlo
cation
ofea
chtile
)
2
Star
t Sta
teG
oal S
tate
5 13
46
785
1
2 3
4 6
7 85
h1(S
)=
??h
2(S
)=
??
Chapte
r4,Sec
tions
1–2
31
Adm
issi
ble
heu
rist
ics
E.g
.,fo
rth
e8-
puzz
le:
h1(n
)=
num
ber
ofm
ispl
aced
tile
sh
2(n
)=
tota
lM
anha
ttan
dist
ance
(i.e
.,no
.of
squa
res
from
desire
dlo
cation
ofea
chtile
)
2
Star
t Sta
teG
oal S
tate
5 13
46
785
1
2 3
4 6
7 85
h1(S
)=
??6
h2(S
)=
??4+
0+3+
3+1+
0+2+
1=
14
Chapte
r4,Sec
tions
1–2
32
Dom
inance
Ifh
2(n
)%
h1(n
)fo
ral
ln
(bot
had
missibl
e)th
enh
2do
min
ates
h1
and
isbe
tter
for
sear
ch
Typ
ical
sear
chco
sts:
d=
14ID
S=
3,47
3,94
1no
des
A!(h
1)
=53
9no
des
A!(h
2)
=11
3no
des
d=
24ID
S'
54,0
00,0
00,0
00no
des
A!(h
1)
=39
,135
node
sA!(h
2)
=1,
641
node
s
Giv
enan
yad
missibl
ehe
uristics
ha,h
b,
h(n
)=
max
(ha(n
),h
b(n))
isal
soad
missibl
ean
ddo
min
ates
ha,h
b
Chapte
r4,Sec
tions
1–2
33
Rel
axed
pro
ble
ms
Adm
issibl
ehe
uristics
can
bede
rive
dfrom
theexact
solu
tion
cost
ofa
rela
xed
vers
ion
ofth
epr
oble
m
Ifth
eru
les
ofth
e8-
puzz
lear
ere
laxe
dso
that
atile
can
mov
eanyw
here
,th
enh
1(n
)gi
ves
the
shor
test
solu
tion
Ifth
eru
les
are
rela
xed
soth
ata
tile
can
mov
eto
any
adja
cent
square
,th
enh
2(n
)gi
ves
the
shor
test
solu
tion
Key
poin
t:th
eop
tim
also
lution
cost
ofa
rela
xed
prob
lem
isno
grea
ter
than
the
optim
also
lution
cost
ofth
ere
alpr
oble
m Chapte
r4,Sec
tions
1–2
34
Rel
axed
pro
ble
ms
contd
.
Wel
l-kn
own
exam
ple:
trav
ellin
gsa
lesp
erso
npr
oble
m(T
SP)
Fin
dth
esh
orte
stto
urvi
siting
allci
ties
exac
tly
once
Min
imum
span
ning
tree
can
beco
mpu
ted
inO
(n2)
and
isa
lower
boun
don
the
shor
test
(ope
n)to
ur
Chapte
r4,Sec
tions
1–2
35
Sum
mary
Heu
rist
icfu
nction
ses
tim
ate
cost
sof
shor
test
path
s
Goo
dhe
uristics
can
dram
atic
ally
redu
cese
arch
cost
Gre
edy
best
-firs
tse
arch
expa
nds
lowes
th
–in
com
plet
ean
dno
tal
way
sop
tim
al
A!
sear
chex
pand
slo
wes
tg
+h
–co
mpl
ete
and
optim
al–
also
optim
ally
e!ci
ent
(up
totie-
brea
ks,fo
rfo
rwar
dse
arch
)
Adm
issibl
ehe
uristics
can
bede
rive
dfrom
exac
tso
lution
ofre
laxe
dpr
oble
ms
Chapte
r4,Sec
tions
1–2
36