Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

Simulated Annealing

Katrina Ellison Geltman


Hacker School
February 20, 2014
What is
simulated annealing?
It’s an algorithm for finding a good solution to an
optimization problem
What’s an optimization
problem?
It’s the problem of finding the best solution from all
feasible solutions. (Wikipedia)
Canonical Example:
Traveling Salesman
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.
Simulated annealing solves this type of problem.
Why ‘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
How does it work?
The Process

!
The Process
• Generate a random solution!

• Assess its cost!

!
The Process
• Generate a random solution!

• Assess its cost!

• Find a neighboring solution!

• Assess its cost!

!
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


The Process
• Generate a random solution!

• Assess its cost!

• Find a neighboring solution!

• Assess its cost!

• !
If cnew < cold: move!! Why??
• If cnew > cold: maybe move
… To escape local maxima
… To escape local maxima
… To escape local maxima
… To escape local maxima
… To escape local maxima
The probability of accepting a worse solution
depends on:

> How much worse it is

> Which iteration you’re on


The probability of accepting a worse solution
depends on:

! ! > How much worse it is!

> Which iteration you’re on


The probability of accepting a worse solution
depends on:

! ! > How much worse it is! Typically


calculated using
Metropolis-
> Which iteration you’re on Hastings
algorithm
The probability of accepting a worse solution
depends on:

> How much worse it is

! ! > Which iteration you’re on


The probability of accepting a worse solution
depends on:

> How much worse it is

! ! > Which iteration you’re on


(later iteration = less likely)
The probability of accepting a worse solution
depends on:

> How much worse it is Analogous to


temperature in the
physical
! ! > Which iteration you’re on annealing
equation
(later iteration = less likely)
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.


The algorithm’s parameters must be tuned
correctly, which requires some guesswork.
But overall, simulated annealing is generally
considered a good choice for solving optimization
problems.
The End!

You might also like