\begin{figure}[!t]
\scriptsize
~\hrule~
\begin{center}
\begin{verbatim}
function sa(kmax) 
  s := s0; e := E(s)           // Initial state, energy.
  sb := s; eb := e             // Initial "best" solution
  k := 0                       // Energy evaluation count.
  while k < kmax and e > emax  // Loop
    sn := neighbour(s)         //   Pick some neighbour.
    en := E(sn)                //   Compute its energy.
    if en < eb then            //   Is this a new best?
      sb := sn; eb := en       //     Yes, save it.
    if random() < P(e, en, temp(k/kmax)) 
     then s := sn; e := en     //     Maybe jump
    k := k + 1                 //   One more evaluation done
  return sb                    // Return best
\end{verbatim}
\end{center}
~\hrule~
\caption[SA pseudo-code]{SA pseudo-code:
a new solution $sn$ (with new energy $en$) replaces the current solution                                  
if (a)~it has a lower energy or (b)~the acceptance predicate $P$
endorses it. Only in the case of (a)
should the new solution
replaces the current best solution.
} \label{fig:sa}
\end{figure}
