Choose an initial state s0 and an initial temperature T0 s = s0; T = T0; while ( termination condition is not satisfied ) do repeat the following a fixed number of times if ( state s is a solution ) then return(s); choose a new state s' from the neighbourhood of s; if ( state s' is a solution ) then return(s'); E := energy(s); E' := energy(s'); if ( E' < E or random() < e-(E-E')/kT ) then {s := s';E :=E';} end repeat; decrease the temperature T; end while return(s); // whatever found so far
Figure 1: High-level description of the SA algorithm.