some material adopted from notes by charles r. dyer, university … · 2009. 9. 28. · • a...

30
Some material adopted from notes by Charles R. Dyer, University of Wisconsin-Madison

Upload: others

Post on 18-Sep-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Some material adopted from notes by Charles R. Dyer, University of

Wisconsin-Madison

Page 2: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Today’sclass:localsearch

•  Itera&veimprovementmethods– Hillclimbing– Simulatedannealing– Localbeamsearch– Gene&calgorithms

•  Onlinesearch

Page 3: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

HillClimbing

•  Extendedthecurrentpathwithasuccessornodewhichisclosertothesolu&onthantheendofthecurrentpath

•  Ifourgoalistogettothetopofahill,thenalwaystakeasteptheleadsyouup

•  Simplehillclimbing–takeanyupwardstep

•  Steepestascenthillclimbing–considerallpossiblesteps,andtaketheonethatgoesupthemost

•  Nomemory

Page 4: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Hillclimbingonasurfaceofstates

HeightDefinedbyEvalua&onFunc&on

Page 5: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Hill‐climbingsearch• Ifthereexistsasuccessorsforthecurrentstatensuchthat–  h(s)<h(n)–  h(s)<=h(t)forallthesuccessorstofn

thenmovefromntos.Otherwise,haltatn• LooksonestepaheadtodetermineifasuccessorisbeLerthanthecurrentstate;ifso,movetothebestsuccessor.

• LikeGreedysearchinthatitusesh,butdoesn’tallowbacktrackingorjumpingtoanalterna&vepathsinceitdoesn’t“remember”whereithasbeen.

• IsBeamsearchwithabeamwidthof1(i.e.,themaximumsizeofthenodeslistis1).• Notcompletesincethesearchwillterminateat"localminima,""plateaus,"and"ridges."

Page 6: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Hillclimbingexample2 8 3 1 6 4 7 5

2 8 3 1 4 7 6 5

2 3 1 8 4 7 6 5

1 3 8 4

7 6 5

2

3 1 8 4 7 6 5

2

1 3 8 4 7 6 5

2 start goal

-5

h = -3

h = -3

h = -2

h = -1

h = 0 h = -4

-5

-4

-4 -3

-2

f(n) = -(number of tiles out of place)

Page 7: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Image from: http://classes.yale.edu/fractals/CA/GA/Fitness/Fitness.html

local maximum

ridge

plateau

ExploringtheLandscape

• LocalMaxima:peaksthataren’tthehighestpointinthespace

• Plateaus:thespacehasabroadflatregionthatgivesthesearchalgorithmnodirec&on(randomwalk)

• Ridges:flatlikeaplateau,butwithdrop‐offstothesides;stepstotheNorth,East,SouthandWestmaygodown,butasteptotheNWmaygoup.

Page 8: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Drawbacksofhillclimbing

•  Problems:localmaxima,plateaus,ridges•  Remedies:– Randomrestart:keeprestar&ngthesearchfromrandomloca&onsun&lagoalisfound.

– ProblemreformulaDon:reformulatethesearchspacetoeliminatetheseproblema&cfeatures

•  Someproblemspacesaregreatforhillclimbingandothersareterrible.

Page 9: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

ExampleofalocalopDmum

1 2 5 7 4

8 6 3 4

1 2 3 8 7 6 5

1 2 5 7 4 8 6 3

2 5 1 7 4 8 6 3

1 2 5 8 7 4

6 3

-3

-4

-4

-4

0

start goal

Page 10: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

HillClimbingand8Queens

Page 11: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Gradientascent/descent

•  Gradientdescentprocedureforfindingtheargxminf(x)

– chooseini&alx0randomly– repeat

•  xi+1←xi–ηf'(xi)

– un&lthesequencex0,x1,…,xi,xi+1converges•  Stepsizeη(eta)issmall(perhaps0.1or0.05)

Images from http://en.wikipedia.org/wiki/Gradient_descent

Page 12: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Gradientmethodsvs.Newton’smethod

• AreminderofNewton’smethodfromCalculus:xi+1←xi–ηf'(xi)/f''(xi)

• Newton’smethoduses2ndorderinforma&on(secondderiva&ve,or,curvature)totakeamoredirectroutetotheminimum.

• Thesecond‐orderinforma&onismoreexpensivetocompute,butconvergesquicker.

Contour lines of a function Gradient descent (green) Newton’s method (red)

Image from http://en.wikipedia.org/wiki/Newton's_method_in_optimization

Page 13: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Annealing

•  Inmetallurgy,annealingisatechniqueinvolvinghea&ngandcontrolledcoolingofamaterialtoincreasethesizeofitscrystalsandreducetheirdefects•  Theheatcausestheatomstobecomeunstuckfromtheirini&alposi&ons(alocalminimumoftheinternalenergy)andwanderrandomlythroughstatesofhigherenergy.•  Theslowcoolinggivesthemmorechancesoffindingconfigura&onswithlowerinternalenergythantheini&alone.

Page 14: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Simulatedannealing(SA)•  SAexploitstheanalogybetweenhowmetalcoolsandfreezesintoaminimum‐energycrystallinestructure&searchforaminimum/maximuminageneralsystem

•  SAcanavoidbecomingtrappedatlocalminima•  SAusesarandomsearchthatacceptschangesincreasingobjec&vefunc&onfandsomethatdecreaseit

•  SAusesacontrolparameterT,whichbyanalogywiththeoriginalapplica&onisknownasthesystem“temperature”

•  Tstartsouthighandgraduallydecreasestoward0

Page 15: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

SAintuiDons

•  combineshillclimbing(efficiency)withrandomwalk(completeness)

•  Analogy:gekngaping‐pongballintothedeepestdepressioninabumpysurface–  shakethesurfacetogettheballoutofthelocalminima

–  nottoohardtodislodgeitfromtheglobalminimum

•  Simulatedannealing:–  startbyshakinghard(hightemperature)andgraduallyreduceshakingintensity(lowerthetemperature)

–  escapethelocalminimabyallowingsome“bad”moves–  butgraduallyreducetheirsizeandfrequency

Page 16: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Simulatedannealing•  A“bad”movefromAtoBisacceptedwithaprobability

‐(f(B)‐f(A)/T)e

•  Thehigherthetemperature,themorelikelyitisthatabadmovecanbemade

•  AsTtendstozero,thisprobabilitytendstozero,andSAbecomesmorelikehillclimbing

•  IfTisloweredslowlyenough,SAiscompleteandadmissible

Page 17: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Simulatedannealingalgorithm

Page 18: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Localbeamsearch

•  Basicidea– Beginwithkrandomstates

– Generateallsuccessorsofthesestates– Keepthekbeststatesgeneratedbythem

•  Providesasimple,efficientwaytosharesomeknowledgeacrossasetofsearches

•  Stochas3cbeamsearchisavaria&on:

– Probabilityofkeepingastateisafunc3onofitsheuris&cvalue

Page 19: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

GeneDcalgorithms(GA)•  Asearchtechniqueinspiredbyevolu3on•  Similartostochas&cbeamsearch•  Startwithkrandomstates(theini3alpopula3on)•  Newstatesaregeneratedby“muta&ng”asinglestateor“reproducing”(combining)twoparentstates(selectedaccordingtotheirfitness)

•  Encodingusedforthe“genome”ofanindividualstronglyaffectsthebehaviorofthesearch

•  Gene&calgorithms/gene&cprogrammingarealargeandac&veareaofresearch

Page 20: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

MaandPasoluDons

Page 21: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

8Queensproblem

• Representstatebyastringof8digitsin{1..8}

• S=‘32752411’• Fitnessfunc&on=#ofnon‐aLackingpairs

• f(Sol)=8*7/2=28• F(S)=24

Page 22: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

GeneDcalgorithms

•  Fitnessfunc&on:numberofnon‐aLackingpairsofqueens(min=0,max=(8×7)/2=28)

•  24/(24+23+20+11)=31%•  23/(24+23+20+11)=29%etc

Page 23: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

GeneDcalgorithms

Page 24: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

GApseudo‐code

Page 25: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

AntColonyOpDmizaDon(ACO)Aprobabilis&csearchtechniqueforproblemsreducibletofindinggoodpathsthroughgraphs

InspiraDon•  Antsleavenest•  Discoverfood•  Returntonest,preferringshorterpaths

•  Leavepheromone trail

•  Shortestpathisreinforced

Page 26: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Tabusearch

•  Problem:Hillclimbingcangetstuckonlocalmaxima

•  Solu&on:Maintainalistofkpreviouslyvisitedstates,andpreventthesearchfromrevisi&ngthem

Page 27: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

CLASSEXERCISE

•  WhatwouldalocalsearchapproachtosolvingaSudokuproblemlooklike?

3

1

3

2

Page 28: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Onlinesearch•  Interleavecomputa&on&ac&on(searchsome,actsome)

•  Explora&on:Can’tinferoutcomesofac&ons;mustactuallyperformthemtolearnwhatwillhappen

•  Compe&&vera&o:Pathcostfound/Pathcostthatwouldbefoundiftheagentknewthenatureofthespace,andcoulduseofflinesearch*Onaverage,orinanadversarialscenario(worstcase)

•  Rela&velyeasyifac&onsarereversible(ONLINE‐DFS‐AGENT)

•  LRTA*(LearningReal‐TimeA*):Updateh(s)(instatetable)basedonexperience

•  MoreabouttheseinchaptersonLogicandLearning!

Page 29: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Othertopics

•  Searchincon&nuousspaces– Differentmath

•  Searchwithuncertainac&ons– Mustmodeltheprobabili&esofanac&onsresults

•  Searchwithpar&alobserva&ons– Acquiringknowledgeasaresultofsearch

Page 30: Some material adopted from notes by Charles R. Dyer, University … · 2009. 9. 28. · • A reminder of Newton’s method from Calculus: x i+1 ← x i – η f '(x i) / f ''(x i)

Summary:Informedsearch• Hill‐climbingalgorithmskeeponlyasinglestateinmemory,butcangetstuckonlocalop&ma.

• Simulatedannealingescapeslocalop&ma,andiscompleteandop&malgivena“longenough”coolingschedule.

• GeneDcalgorithmscansearchalargespacebymodelingbiologicalevolu&on.• Onlinesearchalgorithmsareusefulinstatespaceswithpar&al/noinforma&on.