simulated annealing

20
Simulated Annealing

Upload: jason-larsen

Post on 30-Jun-2015

482 views

Category:

Technology


6 download

DESCRIPTION

An introduction to the local search algorithm simulated annealing.

TRANSCRIPT

Page 1: Simulated Annealing

Simulated Annealing

Page 2: Simulated Annealing

Classical Search• Observable

• Deterministic

• Known Environment

• Solution of sequence of actions

Page 3: Simulated Annealing

Local Search• All that matters is the solution state

• Don't care about solution path

Page 4: Simulated Annealing

Advantages of Local Search• Very little memory — usually constant amount

• Can often find reasonable solutions in infinite (continuous) state spaces

Page 5: Simulated Annealing

Steepest Ascent Hill Climbing

(a.k.a. greedy local search)

Page 6: Simulated Annealing

Hill Climbing

1. Pick a random point.

2. Look at your neighbors.

3. Keep going up until you find the local maximum.

Page 7: Simulated Annealing

Hill Climbing & 8-Queens• Gets stuck 86% of the time

• avg 3 steps when it gets stuck

• avg 4 steps to solve optimally

Page 8: Simulated Annealing

Hill Climbing with Sidesteps• Gets stuck only 6% of the time on 8-queens

• avg 64 steps when it gets stuck

• avg 21 steps to solve optimally

Page 9: Simulated Annealing

Random-restart hill climbing• expected restarts = 1/p, p is the probability of success

• expected steps = 1 successful iteration + cost of (1-p)/p cost of failure, roughly 22 steps

• even for 3 Million-Queens finds a solution in under 1 minute

Page 10: Simulated Annealing

Simulated Annealing

Page 11: Simulated Annealing

MetallurgyAnnealing is the process used to temper or harden metals and glass by heating them to a high temperature and then gradually cooling them, thus allowing the material to reach a low-energy crystalline state.

Page 12: Simulated Annealing

Simulated Annealing1. Choose a random initial state, high initial temperature, and

cooling rate

2. Choose random neighbor of current state

3. If it's better than the current state, pick it

4. If not, randomly decide to take it anyway based on temperature

5. Reduce temperature

6. Repeat steps 2-5 until cooled

Page 13: Simulated Annealing
Page 14: Simulated Annealing

// Loop until system has cooledwhile (temp > 1) { Tour newSolution = randomNeighbor(currentSolution);

// Get energy of solutions int currentEnergy = currentSolution.getDistance(); int neighbourEnergy = newSolution.getDistance();

// Decide if we should accept the neighbour if (acceptanceProbability(currentEnergy, neighbourEnergy, temp) > Math.random()) { currentSolution = new Tour(newSolution.getTour()); }

// Keep track of the best solution found if (currentSolution.getDistance() < best.getDistance()) { best = new Tour(currentSolution.getTour()); }

// Cool system temp *= 1-coolingRate;}

Page 15: Simulated Annealing

Choosing Cooling Rate• No silver bullet.

• Picking a high temperature and low cooling rate is generally best.

Page 16: Simulated Annealing

Advantages of Simulated Annealing• can deal with arbitrary systems and cost functions

• is relatively easy to code, even for complex problems

• generally gives a "good" solution

Page 17: Simulated Annealing

Complete?

NO

Page 18: Simulated Annealing

Optimal?

With loose enough cooling schedule

Page 19: Simulated Annealing

Time Complexity

O(1)

Page 20: Simulated Annealing

Space Complexity

O(1)