SLIDE 3 3
CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart
13
Hill Climbing
- Always t ake a st ep in t he direct ion t hat
improves t he current solut ion value t he most
– Greedy
- Good t hings about hill climbing
– Easy t o progr am! – Requires no memory of where we have been! – I t is import ant t o have a “good” set of moves
- Not t oo many, not t oo f ew
CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart
14
Hill Climbing
- I ssues wit h hill climbing
– I t can get st uck! – Local maximum (local minimum) – Plat eaus
current state
state space global maximum local maximum "flat" local maximum shoulder
CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart
15
I mproving on hill climbing
– Allow f or sideways moves, but be caref ul since may move sideways f orever!
– Random rest art s: “I f at f irst you do not succeed, t ry, t ry again” – Random rest art s works well in pract ice
– Like hill climbing except you choose a random stat e f rom the move set , and t hen move t o it if it is bet t er t han current st at e. Cont inue unt il you are bored
CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart
16
Hill climbing example: GSAT
Av~BvC 1 ~AvCvD 1 BvDv~E 0 ~Cv~Dv~E 1 ~Av~CvE 1
Conf igurat ion A=1, B=0, C=1, D=0, E=1
Goal is t o maximize t he number of sat isf ied clauses: Eval(conf ig)=# sat isf ied clauses GSAT Move_Set: Flip any 1 variable WALKSAT (Randomized GSAT) Pick a random unsat isf ied clause; Consider f lipping each variable in t he clause I f any improve Eval, t hen accept t he best I f none improve Eval, t hen wit h prob p pick t he move t hat is least bad; prob (1-p) pick a random
CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart
17
Simulated Annealing
- Hill climbing algor it hms which never
make downhill moves ar e incomplet e
– Can get st uck at local maxima (minima)
- A r andom walk is complet e but ver y
inef f icient
New I dea:
Allow t he algorit hm t o make some “bad” moves in
- rder t o escape local maxima.
CS486/686 Lecture Slides (c) 2005 K. Larson and P. Poupart
18
Simulated annealing
- 1. Let S be t he init ial conf igurat ion and
V=Eval(S)
- 2. Let i be a random move f rom t he
moveset and let Si be t he next conf igurat ion, Vi=Eval(Si)
Vi t hen S=Si and V=Vi
- 4. Else wit h probabilit y p, S=Si and V=Vi
- 5. Got o 2 unt il you are bored