31
Simulated Annealing Katrina Ellison Geltman Hacker School February 20, 2014

Simulated Annealing

Embed Size (px)

DESCRIPTION

A basic overview of the simulated annealing algorithm

Citation preview

Page 1: Simulated Annealing

Simulated AnnealingKatrina Ellison Geltman

Hacker School February 20, 2014

Page 2: Simulated Annealing

What is simulated annealing?

Page 3: Simulated Annealing

It’s an algorithm for finding a good solution to an optimization problem

Page 4: Simulated Annealing

What’s an optimization problem?

Page 5: Simulated Annealing

It’s the problem of finding the best solution from all feasible solutions. (Wikipedia)

Page 6: Simulated Annealing

Canonical Example: Traveling Salesman

Page 7: Simulated Annealing

Canonical Example: Traveling Salesman

• The salesman needs to minimize the number of miles he travels. An itinerary is better if it is shorter.

• There are many feasible itineraries to choose from. We are looking for the best one.

Page 8: Simulated Annealing

Simulated annealing solves this type of problem.

Page 9: Simulated Annealing

Why ‘annealing’?

Page 10: Simulated Annealing

• Simulated annealing is inspired by a metalworking process called annealing.

• It uses the equation that describes changes in a metal’s embodied energy during the annealing process

Page 11: Simulated Annealing

How does it work?

Page 12: Simulated Annealing

The Process

!

!

!

Page 13: Simulated Annealing

The Process• Generate a random solution!

• Assess its cost!

!

!

!

Page 14: Simulated Annealing

The Process• Generate a random solution!

• Assess its cost!

• Find a neighboring solution!

• Assess its cost!

!

Page 15: Simulated Annealing

The Process• Generate a random solution!

• Assess its cost!

• Find a neighboring solution!

• Assess its cost!

!• If cnew < cold: move!!

• If cnew > cold: maybe move

Page 16: Simulated Annealing

The Process• Generate a random solution!

• Assess its cost!

• Find a neighboring solution!

• Assess its cost!

!• If cnew < cold: move!!

• If cnew > cold: maybe move

Why??

Page 17: Simulated Annealing

… To escape local maxima

Page 18: Simulated Annealing

… To escape local maxima

Page 19: Simulated Annealing

… To escape local maxima

Page 20: Simulated Annealing

… To escape local maxima

Page 21: Simulated Annealing

… To escape local maxima

Page 22: Simulated Annealing

The probability of accepting a worse solution depends on:

> How much worse it is

> Which iteration you’re on

Page 23: Simulated Annealing

The probability of accepting a worse solution depends on:

! ! > How much worse it is!

> Which iteration you’re on

Page 24: Simulated Annealing

The probability of accepting a worse solution depends on:

! ! > How much worse it is!

> Which iteration you’re on

Typically calculated using

Metropolis-Hastings algorithm

Page 25: Simulated Annealing

The probability of accepting a worse solution depends on:

> How much worse it is

! ! > Which iteration you’re on

Page 26: Simulated Annealing

The probability of accepting a worse solution depends on:

> How much worse it is

! ! > Which iteration you’re on(later iteration = less likely)

Page 27: Simulated Annealing

The probability of accepting a worse solution depends on:

> How much worse it is

! ! > Which iteration you’re on

Analogous to temperature in the

physical annealing equation(later iteration = less likely)

Page 28: Simulated Annealing

Big jumps to worse states happen early.

!

After many iterations, the algorithm hones in on a local optimum.

!

So a good-enough solution is usually found.

Page 29: Simulated Annealing

The algorithm’s parameters must be tuned correctly, which requires some guesswork.

Page 30: Simulated Annealing

But overall, simulated annealing is generally considered a good choice for solving optimization problems.

Page 31: Simulated Annealing

The End!