CS473| Autumn2001
Lectures #9 {10
Today: Local Search
R&N Sec. 4.4, Sec. 6.4, Exer. 6.15, Sec. 20.8
Next: Knowledge Representation
R&N Ch. 6,7, selected parts of Ch. 8, 9,10
Henry Kautz
Slide CSE 573{1
A Dierent Approach
Sofar, we have considered methodsthat systematically
explore the full search space, possibly using
principled pruning(A* etc.).
The current best such algorithms(IDA* /SMA*) can handle
search spaces of up to 10 100
states /around
500 binary valued variables.
(These are \ballpark " gures only!)
of up to10 30;000
states?
A completelydierent kindof methodis called for:
LocalSearch Methods or
Iterative Improvement Methods
Slide CSE 573{3
Local Search Methods
Approachquite general: any NP-complete problem/ CSP.
Other examples: planning, scheduling, TSP, graphcoloring,
and time-tabling.
In fact, many (most?) largeOperations Research problems
are solved using localsearch.
E.g. Delta airlines(near-optimal!)
Q. What's the \competitor" inOR?
(a) Select (random) initial state
(initial guess at solution)
(b) Make local modification to try
to improve current state.
(c) repeat (b) till goal state found
(or out of time).
Slide CSE 573{5
Example
Graph coloring.
(a) start with random coloringof nodes
(b) changethe coloringof one of the nodes toreduce
con icts
(c) repeat (b)
1
1 2 2 3 3 4
4
#1 #2 #3 #4 || # conflicts
R R B R || 3
Slide CSE 573{7
evaluation
current
state
function H ILL -C LIMBING ( problem) returns a solution state inputs: problem, a problem
static: current, a node next, a node
current M AKE -N ODE (I NITIAL -S TATE [problem]) loop do
next a highest-valued successor of current if V ALUE [next] < V ALUE [current] then return current current next
end
Slide CSE 573{9
Notes
\successor" normally called \neighbor"
You search intheneighborhoodof current state.
When does Hill-Climbingstop?
Current approaches: Often simply keep going!
Use: time limit.
Simple method: very fast, uses minimal memory,
surprisingly eective!
100;000+ variables, 1;000;000+ constraints.
A wide variety of key CS problems can be translated into a
propositional logicalformalization
e.g., (A _B _ C) ^ (:B ^ C_ D) ^ (A _:C _ D)
and solved by nding atruth assignmentto the propositional
variables(A, B, C,...) that makes it true,i.e., amodel.
Ifa formulahas amodel, we say that itis \satisable".
ConjunctiveNormal Form (CNF)
Specialkindof CSP.
Slide CSE 573{11
Applications:
planningand scheduling
circuit diagnosisand synthesis
deductive reasoning
software testing
etc.
Best-known method: Davis-PutnamProcedure (1960)
Backtrack search (DFS) through the space of
truth assignments
Arc consistency for CNF is calledunit-propagation
Q.Howwould that work?
Slide CSE 573{13
= Z
Z
Z
~
F T
B
= Z
Z
Z
~ A
F T
C^(B_:C) C^(B_:C)^:B
(A_C)^(:A_C)^(B_:C)^(A_:B)
C^:C
complete method.
Used inverication, planning...
However, there are classes of formulas where the procedure
scales badly.
Consider an incomplete localsearch procedure.
Slide CSE 573{15
Greedy Local Search | GSAT
Beginwith a randomtruth assignment (assumeCNF).
Flip the value assigned tothe variablethat
yieldsthe greatest number of satised clauses.
(Note: Flip even ifthere isno improvement.)
Repeat untila model is found, or have performed
a speciedmaximum numberof ips.
Ifa modelis stillnot found, repeat the entire process,
startingfrom a dierent initialrandom assignment.
F F F
p p
2
F F T
p p
2
F T T
p p p
3
(Selman,Levesque, and Mitchell1992)
Slide CSE 573{17
How well does it work?
First intuition: It willget stuck inlocalminima,
with a few unsatised clauses.
Note we are not interested inalmost satisfyingassignments
E.g., a plan with one \magic"step isuseless.
Contrastwith optimizationproblems.
Surprise: It often nds globalminimum!
I.e., nds satisfyingassignments.
vars m. ips retries time choices depth time
50 250 6 0.5sec 77 11 1sec
70 350 11 1sec 42 15 15 sec
100 500 42 6sec 10
3
19 3 min
120 600 82 14 sec 10
5
22 18 min
140 700 53 14 sec 10
6
27 5 hrs
150 1500 100 45 sec | | |
200 2000 248 3min | | |
300 6000 232 12min | | |
500 10000 996 2 hrs 10 30
>100 10 19
yrs
Slide CSE573{19
Search space
Issue: Howto movemore quickly tosuccessively
lowerplateaus?
Avoidgetting \stuck" /local minima.
Idea: introduceuphill moves (\noise") toescape
fromlong plateaus(or true localminima)
Noisestrategies:
(a) Simulated Annealing
Kirkpatricket al. 1982; Metropolis etal. 1953
(b) Mixed Random Walk
Selman andKautz1993
Slide CSE 573{21
Simulated Annealing
Noisemodel based onstatistical mechanics.
Pick a randomvariable
If ip improves assignment: doit.
else ip with probability p=e Æ=T
(\upward").
Æ numberofadditional clausesbecoming unsatised
T =\temperature"
Higher temperature =greater likelihoodof upward moves.
Way togrow crystals.
Kirkpatricketal. 1982;Metropoliset al. 1953
Physicalanalogy remains elusive.
Can prove that with exponentialschedule willconverge to
global optimum.
DiÆcult tobe more precise about convergence rate.
Seerecentwork onrapidly mixing Markov chains.
Keyaspect: upwards moves / sideways moves.
Expensive, but if youhave time can be best.
(hundredsofpapers peryear/ manyapplications)
Slide CSE 573{23
Random Walk
Random walk SAT algorithm:
I Pick random truth assignment.
II Repeat until all clauses satised:
Flip variable from any unsatised clause.
Solves 2-SAT (2variables perclause) in O(n 2
) ips.
(Papadimitriou 1992) Why?
Withprobability p,walk,
i.e., pick a variable insome
unsatised clause and ip it;
with probability (1 p) make agreedy ip,
i.e., one that makes greatest decrease innumberof
unsatised clauses.
Value for parameter p determined empirically,
by ndingbest settingfor a problemclass.
(see also DJP32001)
Slide CSE 573{25
Inside-out: Walksat
1. Pick aunsatised clause atrandom.
2. With probabilityp, ip any variablein the clause;
with probability(1 p) ip avariable
in the clause that minimizesnumberunsat clauses.
VeryeÆcient to implement!
Incrementally computeeect of ipping
Comparableto GSAT+walk, but faster ips.
GSAT Simul. Ann.
basic walk
vars time e. time e. time e.
100 .4 .12 .2 1.0 .6 .88
200 22 .01 4 .97 21 .86
400 122 .02 7 .95 75 .93
600 1471 .01 35 1.0 427 .3
800 * * 286 .95 * *
1000 * * 1095 .85 * *
2000 * * 3255 .95 * *
Slide CSE 573{27
Time inseconds(SGI Challenge).
Eectiveness: probabilitythatrandominitialassignment leads
to asolution.
Complete methods, suchas DP,upto 650 variables.
Mixed Walk (or Walksat) betterthan
Simul. Ann. better than
Backtracking (Davis-Putnam).
1. local minimum (maximum): rate of change is
positive(negative)in alldirections (maze problem|
may have tomove away fromgoal to nd the (best)
solution)
2. plateaus: all of the localsteps look the same
True local minima are rarein high dimensionspace.
Termoften relaxed to include plateaus.
Slide CSE 573{29
Approaches
1. Simulated annealing (done)
2. Mixed-in random walk (done)
3. Random restarts
4. Tabu search
5. Genetic algorithms/programming
state after apre-dened number of localsteps.
2. Tabu: prevent returning quickly tosame state.
Implementation: Keep xed lengthqueue (\tabu list"):
add most recent step toqueue; drop \oldest" step.
Never makestep that'scurrently on the tabu list.
Slide CSE 573{31
without tabu:
ip var1, var 2,var 4, var2, var 10,
var11, var 1, var 10, var 3...
with tabu (length 5): | possible sequence:
ip var1, var 2,var 4, var10,var11,
var3, var 7,var 2, var6 ...
Tabu quitepowerful; competitive with simulatedannealing
Approach mimicsevolution.
SeeSection20.8 R&N.
Often presented using richnew vocabulary:
tness function, population, inviduals,
\genes", crossover, mutations, etc.
Still,can be viewed quite directly interms of
standard local search.
Note: insome sense,natural evolution performs a local
search toimprove species: \survivalofthe ttest",
\local searchin thegenepool"
What is the evaluation function?
Slide CSE 573{33
What are some of the special aspect of the
evolutionary search process?
(Friedberg 1958;Holland 1975;Koza 1992)
New individuals (\next state / neighboring states")
derived from\parents"
(Greedy) selectionnext generation:
Survival of the ttest.
Slide CSE 573{35
General Idea
Maintain a populationof strings (states /individuals /
candidate solutions)
Generate a sequence of generations:
From the currentgeneration, select pairs of strings
(based ontness) togenerate new strings,
using crossover.
Introduce some noise through randommutations.
Average and maximum tness increases over time.
1
1 2 2 3 3 4 4 5 5
#1 #2 #3 #4 #5 fitness
1 G B G R B
2 R G G R B
3 R R R G B
4 G G R R B
generation 1
Slide CSE 573{37
Example Crossover
\parents" \children"
#1 #2 #3 #4 #5 #1 #2 #3 #4 #5 tness
1 G B G R B G B R G B
3 R R R G B R R G R B
examplemutation:
In practice, several 100 to 1000's of strings.
What if you have only mutations?
What makes this work for graph coloring?
Could this work for SAT testing (GSAT etc.)?
Slide CSE 573{39
Remarks
In practice, several 100 to1000's of strings.
What if you have only mutations?
Parallel noisylocalsearch
What makes this work for graph coloring?
Locality!
Could this work for SAT testing (GSATetc.)?
Depends on geometryof \near solutions"
4,7, 12,13,14,15, 16,20,21
Slide CSE 573{41
Perspective
Jury stillout onGenetic Algorithmsingeneral,
but naturesuggests itcan be ahighlypowerful
mechanism for evolvinghighly complexsystems.
Schema theory starts to allowanalysis,
but stillfar fromdeep understanding
offormal properties.
Surprisingly eÆcient search method.
Widerange of applications.
anytype ofoptimization /search task
Formal properties elusive.
Why dosomanynaturally-occuringproblems
have \near-convex" search spaces?
Often best method evailablefor poorly understood
problems | How evolution builtus::: .
Slide CSE 573{43