simulated annealing

Post on 30-Jun-2015

482 Views

Category:

Technology

6 Downloads

Preview:

Click to see full reader

DESCRIPTION

An introduction to the local search algorithm simulated annealing.

TRANSCRIPT

Simulated Annealing

Classical Search• Observable

• Deterministic

• Known Environment

• Solution of sequence of actions

Local Search• All that matters is the solution state

• Don't care about solution path

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

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

Steepest Ascent Hill Climbing

(a.k.a. greedy local search)

Hill Climbing

1. Pick a random point.

2. Look at your neighbors.

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

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

• avg 3 steps when it gets stuck

• avg 4 steps to solve optimally

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

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

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.

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

// 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;}

Choosing Cooling Rate• No silver bullet.

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

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

Complete?

NO

Optimal?

With loose enough cooling schedule

Time Complexity

O(1)

Space Complexity

O(1)

top related