36
CMSC 671 CMSC 671 Fall 2005 Fall 2005 Class #5 – Thursday, September 15

c5 Inf Search

Embed Size (px)

Citation preview

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 1/37

CMSC 671CMSC 671

Fall 2005Fall 2005

Class #5 – Thursday, September 15

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 2/37

Today’s class

• Heuristic search

• Best-first search –  Greedy search

 –  Beam search –  A, A*

 –  Examples

• Memory-conservin variations of A*

• Heuristic functions

• !terative improvement methods

 –  Hill clim"in –  #imulated annealin

 –  $ocal "eam search –  Genetic alorithms

• %nline search

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 3/37

!"ormed!"ormed

SearchSearchChapter Chapter

#ome material adopted from notes

 "y &harles '( )yer, niversity of

+isconsin-Madison

$ote% +e ill sip #ection .(.

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 4/37

&eur'st'c

(ebster)s *e+'sed !abr'd-ed .'ct'o!ary /11 /3eb11

Heuristic /Heu*ris0tic/, a( 1Gr( 2 to discover(3 #ervin to discover or find

out(

The Free 4!l'!e .'ct'o!ary o" Comput'!- /15Feb

heuristic 4( 5prorammin6 A rule of thum", simplification or educateduess that reduces or limits the search for solutions in domains that are

difficult and poorly understood( nlie alorithms, heuristics do not

uarantee feasi"le solutions and are often used ith no theoretical

uarantee( 7( 5alorithm6 approximation alorithm( 

From (ord$et /r 16 heuristic ad8 49 :computer science; relatin to or usin a heuristic rule 79

of or relatin to a eneral formulation that serves to uide investiation

1ant9 alorithmic3 n 9 a commonsense rule :or set of rules; intended to

increase the pro"a"ility of solvin some pro"lem 1syn9 heuristic rule,

heuristic proram3 

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 5/37

!"ormed methods add

doma'!spec'"'c '!"ormat'o!• Add domain-specific information to select the "est path

alon hich to continue searchin

• )efine a heuristic function, h/!, that estimates the

<oodness= of a node n(

• #pecifically, h:n; > est'mated cost :or distance; of minimal

cost path from n to a -oal state(

•?he heuristic function is an estimate, "ased on domain-specific information that is computa"le from the current

state description, of ho close e are to a oal

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 6/37

&eur'st'cs• 8ll doma'! 9!o3led-e used in the search is encoded in the

heur'st'c "u!ct'o! h(

• Heuristic search is an example of a <3ea9 method= "ecause

of the limited ay that domain-specific information is used to

solve the pro"lem(

• Examples9 –  Missionaries and &anni"als9 @um"er of people on startin river "an 

 –  -pule9 @um"er of tiles out of place

 –  -pule9 #um of distances each tile is from its oal position

• !n eneral9 –  h:n; 6> C for all nodes n

 –  h:n; > C implies that n is a oal node

 –  h:n; > infinity implies that n is a dead-end from hich a oal cannot

 "e reached

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 7/37

(ea9 +s stro!- methods

• +e use the term ea methods to refer to methods that areextremely eneral and not tailored to a specific situation(

• Examples of ea methods include

 –  Mea!se!ds a!alys's is a stratey in hich e try to represent the current

situation and here e ant to end up and then loo for ays to shrin the

differences "eteen the to( –  Space spl'tt'!- is a stratey in hich e try to list the possi"le solutions

to a pro"lem and then try to rule out classes of these possi"ilities(

 –  Sub-oal'!- means to split a lare pro"lem into several smaller ones that

can "e solved one at a time(

• &alled <ea= methods "ecause they do not tae advantae ofmore poerful domain-specific heuristics

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 8/37

:est"'rst search

• %rder nodes on the nodes list "y increasin

value of an evaluation function, "/!, that

incorporates domain-specific information in

some ay(

• ?his is a eneric ay of referrin to the class

of informed methods(

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 9/37

;reedy search

• se as an evaluation function f:n; > h:n;,

sortin nodes "y increasin values of f(

• #elects node to expand "elieved to "e

closest :hence <reedy=; to a oal node:i(e(, select node ith smallest f value;

•  @ot complete

•  @ot admissi"le, as in the example(

Assumin all arc costs are 4, then reedysearch ill find oal , hich has a

solution cost of D, hile the optimal

solution is the path to oal 7 ith cost (

a

hb

c

d

e

-

'

-2

h<2

h<1

h<1

h<1

h<0

h<

h<1

h<0

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 10/37

:eam search

• se an evaluation function f:n; > h:n;, "ut the maximum

sie of the nodes list is , a fixed constant

• %nly eeps "est nodes as candidates for expansion, and

thros the rest aay

• More space efficient than reedy search, "ut may thro

aay a node that is on a solution path

• @ot complete

•  @ot admissi"le

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 11/37

8l-or'thm 8•

se as an evaluation function"/! < -/! = h/!

• :n; > minimal-cost path from the start

state to state n(

• ?he :n; term adds a <"readth-first=component to the evaluation function(

• 'ans nodes on search frontier "y

estimated cost of solution from start

node throuh the iven node to oal(•  @ot complete if h:n; can eFual infinity(

•  @ot admissi"le(

S

:8

.

;

1 5

8

1

5

C

1

9

5

 g(d)=4

h(d)=9

C is chosennext to expand 

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 12/37

8l-or'thm 8

4( ut the start node # on the nodes list, called %E@

7( !f %E@ is empty, exit ith failure

( #elect node in %E@ ith minimal f:n; and place on &$%#E)

.( !f n is a oal node, collect path "ac to start and stop(

D( Expand n, eneratin all its successors and attach to them pointers "ac to n( or each successor nI of n

4( !f nI is not already on %E@ or &$%#E)

•  put n I on %E@

• compute h:nI;, :nI;>:n;J c:n,nI;, f:nI;>:nI;Jh:nI;7( !f nI is already on %E@ or &$%#E) and if :nI; is loer for

the ne version of nI, then9

• 'edirect pointers "acard from nI alon path yieldin loer :nI;(

• ut nI on %E@( 

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 13/37

8l-or'thm 8>

• Alorithm A ith constraint that h/! ?< h>/!

• h>/! > true cost of the minimal cost path from n to a oal(

• h is adm'ss'ble hen h:n; 5> h*:n; holds(• sin an admissi"le heuristic uarantees that the first solution

found ill "e an optimal one(

• A* is complete henever the "ranchin factor is finite, and

every operator has a fixed positive cost• A* is adm'ss'ble 

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 14/37

Some obser+at'o!s o! 8

• @er"ect heur'st'c% !f h:n; > h*:n; for all n, then only the nodes on

the optimal solution path ill "e expanded( #o, no extra or ill

 "e performed(

• $ull heur'st'c% !f h:n; > C for all n, then this is an admissi"le

heuristic and A* acts lie niform-&ost #earch(• :etter heur'st'c% !f h4:n; 5 h7:n; 5> h*:n; for all non-oal nodes,

then h7 is a "etter heuristic than h4

 –  !f A4* uses h4, and A7* uses h7, then every node expanded "y A7* is also

expanded "y A4*(

 –  !n other ords, A4 expands at least as many nodes as A7*(

 –  +e say that A7* is "etter informed than A4*(

• ?he closer h is to h*, the feer extra nodes that ill "e expanded

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 15/37

ABample search space

S

C:8

. ;A

1 5

5

7

8

84 3

∞  ∞   0

start state

oal state

arc cost

h value

 parent pointer 

C

4

. K

D

value

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 16/37

ABample

!-/! h/! "/! h>/!#C K

A 4 K K

B D . K .

& 44 D

) . inf inf inf  

E inf inf inf  

G K C K C• h*:n; is the :hypothetical; perfect heuristic(

• #ince h:n; 5> h*:n; for all n, h is admissi"le

• %ptimal path > # B G ith cost K(

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 17/37

;reedy search

f:n; > h:n; 

node expanded nodes list

  { S(8) }

  S { C(3) B(4) A(8) }

  C { G(0) B(4) A(8) }

  G { B(4) A(8) }

• #olution path found is # & G, nodes expanded(

• #ee ho fast the search isLL But it is @%? optimal(

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 18/37

8> search

"/! < -/! = h/! 

node exp. nodes list

  { S(8) }

 S { A(9) B(9) C(11) }

 A { B(9) G(10) C(11) D(inf) E(inf) }

 B { G(9) G(10) C(11) D(inf) E(inf) }

G { C(11) D(inf) E(inf) }

• #olution path found is # B G, . nodes expanded((

• #till pretty fast( And optimal, too(

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 19/37

@roo" o" the opt'mal'ty o" 8>

• +e assume that A* has selected G7, a oal state ith a

su"optimal solution ::G7; 6 f*;(

• +e sho that this is impossi"le(

 – &hoose a node n on the optimal path to G(

 – Because h:n; is admissi"le, f* 6> f:n;(

 – !f e choose G7 instead of n for expansion, f:n;6>f:G7;(

 – ?his implies f*6>f:G7;(

 – G7 is a oal state9 h:G7; > C, f:G7; > :G7;(

 – ?herefore f* 6> :G7;

 – &ontradiction(

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 20/37

.eal'!- 3'th hard problems

• or lare pro"lems, A* often reFuires too much space(

• ?o variations conserve memory9 !)A* and #MA*

• !)A* -- iterative deepenin A* -- uses successive iterationith roin limits on f, e((

 –  A* "ut dont consider any node n here f:n; 64C

 –  A* "ut dont consider any node n here f:n; 67C

 –  A* "ut dont consider any node n here f:n; 6C, (((

• #MA* -- #implified Memory-Bounded A*

 –  uses a Fueue of restricted sie to limit memory use(

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 21/37

(hat’s a -ood heur'st'c

• !f h4:n; 5 h7:n; 5> h*:n; for all n, h7 is "etter than:dom'!ates; h4(

• 'elaxin the pro"lem9 remove constraints to create a

:much; easier pro"lemN use the solution cost for this pro"lem as the heuristic function

• &om"inin heuristics9 tae the max of several admissi"leheuristics9 still have an admissi"le heuristic, and its "etterL

• se statistical estimates to compute 9 may loseadmissi"ility

• !dentify ood features, then use a learnin alorithm to finda heuristic function9 also may lose admissi"ility

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 22/37

CD8SS AEA*CSA

• $ets revisit the #udou pro"lem from "efore(

• +hat ould an admissi"le heuristic function loo lie2

• +hat ould a ood heuristic function loo lie2

4

7

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 23/37

Docal /a9a '!creme!tal

'mpro+eme!tG search• Another approach to search involves startin ith

an initial uess at a solution and radually

improvin it until it is one(

• #ome examples9

 – Hill clim"in

 – #imulated annealin

 – $ocal "eam search – Genetic alorithms

 – ?a"u search

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 24/37

&'ll cl'mb'!- o! a sur"ace o" states

Heiht )efined "y

Evaluation unction

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 25/37

&'llcl'mb'!- search

• !f there exists a successor s for the current state n such that –  h:s; 5 h:n;

 –  h:s; 5> h:t; for all the successors t of n,

• then move from n to s( %therise, halt at n(

• $oos one step ahead to determine if any successor is "etterthan the current stateN if there is, move to the "est successor(

• #imilar to Greedy search in that it uses h, "ut does not

allo "actracin or 8umpin to an alternative path since it

doesnt <remem"er= here it has "een(• &orresponds to Beam search ith a "eam idth of 4 :i(e(,

the maximum sie of the nodes list is 4;(

•  @ot complete since the search ill terminate at 0local

minima,0 0plateaus,0 and 0rides(0

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 26/37

&'ll cl'mb'!- eBample

7

4 O .

P D

7 4 .

P O D

7

4 .

P O D

4 .

P O D

7

4 .

P O D

7

4

.

P O D

7

start oal

-D

h > -

h > -

h > -7

h > -4

h > Ch > -.

-D

-.

-.-

-7

"/! < /!umber o" t'les out o" place 

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 27/37

.ra3bac9s o" h'll cl'mb'!-• ro"lems9

 – Docal MaB'ma9 peas that arent the hihest point inthe space

 – @lateaus% the space has a "road flat reion that ives

the search alorithm no direction :random al; – *'d-es% flat lie a plateau, "ut ith dropoffs to the

sidesN steps to the @orth, East, #outh and +est mayo don, "ut a step to the @+ may o up(

• 'emedies9 –  'andom restart

 –  ro"lem reformulation

• #ome pro"lem spaces are reat for hill clim"in andothers are terri"le(

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 28/37

ABample o" a local opt'mum

4 7 D

P .

O

.

4 7

P O D

4 7 D

 P .

O

7 D

4 P .

O

4 7 D

  P .

O

0

start goal  

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 29/37

S'mulated a!!eal'!-

• #imulated annealin :#A; exploits an analoy "eteen the ayin hich a metal cools and freees into a minimum-enery

crystalline structure :the annealin process; and the search for a

minimum 1or maximum3 in a more eneral system(

• #A can avoid "ecomin trapped at local minima(

• #A uses a random search that accepts chanes that increase

o"8ective function f, as 3ell as some that decrease it(

• #A uses a control parameter ?, hich "y analoy ith the

oriinal application is non as the system <temperature=• ? starts out hih and radually decreases toard C(

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 30/37

S'mulated a!!eal'!- /co!t

• A <"ad= move from A to B is accepted ith a pro"a"ility  -:f:B;-f:A;Q?;

e• ?he hiher the temperature, the more liely it is that a "ad

move can "e made(• As ? tends to ero, this pro"a"ility tends to ero, and #A

 "ecomes more lie hill clim"in

• !f ? is loered sloly enouh, #A is complete and

admissi"le(

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 31/37

The s'mulated a!!eal'!- al-or'thm

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 32/37

Docal beam search

• Bein ith random states

• Generate all successors of these states

•Reep the "est states

• #tochastic "eam search9 ro"a"ility of eepin a state is a

 function of its heuristic value

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 33/37

;e!et'c al-or'thms

• #imilar to stochastic "eam search

• #tart ith random states :the initial population)

•  @e states are enerated "y <mutatin= a sinle state or

<reproducin= :com"inin; to parent states :selected

accordin to their fitness)

• Encodin used for the <enome= of an individual stronly

affects the "ehavior of the search

• Genetic alorithms Q enetic prorammin are a lare and

active area of research

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 34/37

Tabu search

• ro"lem9 Hill clim"in can et stuc on local maxima

• #olution9 Maintain a list of k previously visited states, and

 prevent the search from revisitin them

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 35/37

CD8SS AEA*CSA

• +hat ould a local search approach to solvin a #udou

 pro"lem loo lie2

4

7

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 36/37

4!l'!e search

• !nterleave computation and action :search some, act some;

• Exploration9 &ant infer outcomes of actionsN must actually perform them to learn hat ill happen

• &ompetitive ratio9 ath cost found* Q ath cost that ould "efound if the aent ne the nature of the space, and could useoffline search

* %n averae, or in an adversarial scenario :orst case;

• 'elatively easy if actions are reversi"le :%@$!@E-)#-AGE@?;

• $'?A* :$earnin 'eal-?ime A*;9 pdate h:s; :in state ta"le; "ased on experience

• More a"out these issues hen e et to the chapters on $oic

and $earninL

8/9/2019 c5 Inf Search

http://slidepdf.com/reader/full/c5-inf-search 37/37

Summary% !"ormed search

• :est"'rst search is eneral search here the minimum-cost nodes :accordin to some measure;

are expanded first(

• ;reedy search uses minimal estimated cost h:n; to the oal state as measure( ?his reduces the

search time, "ut the alorithm is neither complete nor optimal(

• 8> search com"ines uniform-cost search and reedy search9 f:n; > :n; J h:n;( A* handles state

repetitions and h:n; never overestimates(

 –  A* is complete and optimal, "ut space complexity is hih(

 –  ?he time complexity depends on the Fuality of the heuristic function(

 –  !)A* and #MA* reduce the memory reFuirements of A*(

• &'llcl'mb'!- al-or'thms eep only a sinle state in memory, "ut can et stuc on local optima(

• S'mulated a!!eal'!- escapes local optima, and is complete and optimal iven a <lon enouh=

coolin schedule(

• ;e!et'c al-or'thms can search a lare space "y modelin "ioloical evolution(

• 4!l'!e search alorithms are useful in state spaces ith partialQno information(