Docsity

Local Search Algorithms for Optimization Problems - Prof. Dana S. Nau, Study notes of Computer Science

Partial preview of the text

Download Local Search Algorithms for Optimization Problems - Prof. Dana S. Nau and more Study notes Computer Science in PDF only on Docsity!

Last update: September 11, 2008

Local search algorithms

CMSC 421: Chapter 4, Sections 3–

Outline

♦ Hill-climbing ♦ Simulated annealing ♦ Genetic algorithms (briefly) ♦ Local search in continuous spaces (very briefly)

Example: Travelling Salesperson Problem

Start with any complete tour, perform pairwise exchanges

Variants of this approach get within 1% of optimal very quickly with thou- sands of cities

Example: n-queens

Put n queens on an n × n board with no two queens on the same row, column, or diagonal

Move a queen to reduce number of conflicts

h = 5 h = 2 h = 0

Even for very large n (e.g., n = 1 million), usually solves n-queens problems almost instantly

Hill-climbing, continued

Useful to consider state space landscape

current state

objective function

state space

global maximum

local maximum "flat" local maximum

shoulder

Random-restart hill climbing: repeat with randomly chosen starting points Russell & Norvig say it’s trivially complete; they’re almost right

If finitely many local maxima, then limrestarts→∞P (complete) = 1

Simulated annealing

Idea: escape local maxima by allowing some “bad” moves but gradually decrease their size and frequency

function Simulated-Annealing( problem, schedule) returns a solution state inputs: problem, a problem schedule, a mapping from time to “temperature” local variables: current, a node next, a node T, a “temperature” controlling prob. of downward steps current ← Make-Node(Initial-State[problem]) for i ← 1 to ∞ do T ← schedule[i] if T = 0 then return current next ← a randomly selected successor of current ∆E ← Value[next] – Value[current] if ∆E > 0 then current ← next else with probability e∆E/T^ , set current ← next

A very simple example

    1. Results of calling anneal(10,100). Read each column downward.

Properties of simulated annealing

At fixed “temperature” T , probability of being in any given state x reaches Boltzman distribution

p(x) = αe

E(x) kT

for every state x other than x∗^ and for small T ,

p(x∗)/p(x) = e

E(x∗) kT (^) /e

E(x) kT (^) = e

E(x∗)−E(x) kT (^)  1

From this it can be shown that if we decrease T slowly enough, Pr[reach x∗] approaches 1

Is this necessarily an interesting guarantee?

Devised by Metropolis et al., 1953, for physical process modelling

Widely used in VLSI layout, airline scheduling, etc.

Genetic algorithms

Genetic algorithms = stochastic local beam search + generate successors from pairs of states

32252124

Selection Cross−Over Mutation

24748552

32752411

24415124

24 23 20

32543213^11

29%

31%

26% 14%

32752411 24748552 32752411 24415124

32748552 24752411 32752124 24415411

24752411

32748152

24415417

Fitness Pairs

Genetic algorithms contd.

GAs require states encoded as strings (GPs use programs)

Crossover helps iff substrings are meaningful components

+ =

GAs 6 = evolution for example, real genes encode replication machinery

Hill-climbing in continuous state spaces

A technique from numerical analysis:

Given a surface z = f (x, y), and a point (x, y), a gradient is a vector

∇f (x, y) =

  

∂f ∂x

∂f ∂y

  

that points in the direction of the steepest slope. The vector’s length is proportional to the slope.

Gradient methods compute ∇f and use it to increase/reduce f , e.g., by x ← x + α∇f (x)

If ∇f = 0 then you’ve reached a local max- imum/minimum

Hill-climbing in continuous state spaces

Suppose we want to put three airports in Romania – what locations?

∇f =

 ^ ∂f ∂x 1

∂f ∂y 1

∂f ∂x 2

∂f ∂y 2

∂f ∂x 3

∂f ∂y 3

 

Bucharest

Giurgiu

Urziceni

Hirsova

Eforie

Neamt Oradea

Zerind

Arad

Timisoara

Lugoj Mehadia

Dobreta

Craiova

Sibiu

Fagaras

Pitesti Rimnicu Vilcea

Vaslui

Iasi

Straight−line distanceto Bucharest

160 242 161 77 151

241

366

193

178

253 329 80 199

244

380

226

234

374

98

Giurgiu

Urziceni Hirsova

Eforie

Neamt

Oradea

Zerind Arad

Timisoara Lugoj Mehadia Dobreta Craiova

Sibiu (^) Fagaras

Pitesti

Vaslui

Iasi

Rimnicu Vilcea

Bucharest

71

75

118

111 70 75 120

151 140 99 80

97 101

211

138

146 85

90

98

142

92

87

86