A Fast Algorithm for Simulated Annealing
Total Page:16
File Type:pdf, Size:1020Kb
Physica Scripta. Vol. T38, 40-44, 1991. A Fast Algorithm for Simulated Annealing Hong Guo, Martin Zuckermann, R. Harris and Martin Grant Centre for the Physics of Materials, Department of Physics, McGill University, 3600 University Street, Montreal, Quebec, Canada H3A 2T8 Received September 24, 1990; accepted October 26, 1990 Abstract Gaussian distribution (Gaussian model), or takes values of We present a new deterministic algorithm for simulated annealing and fJ with equal probability ( f J model). The sum is over all demonstrate its applicability with several classical examples: the ground state the nearest neighbor pairs. The spin glass system is highly energies of the 2d and 3d short range king spin glasses, the traveling salesman frustrated and has a large number of metastable states with problem, and pattern recognition in computer vision. Our algorithm is based similar energies. Its ground state also has high degeneracy. At on a microcanonical Monte Carlo method and is shown to be a powerful tool low temperatures it can be trapped in one of the metastable for the analysis of a variety of problems involving combinatorial optimiz- states. Thermal noise then induces uphill steps in energy ation. We show that the deterministic method generates optimal solutions faster and often better than the standard Metropolis method. space which in principle eventually brings the system to equilibrium. The simulated annealing method starts with the system at high temperature and lowers the temperature in 1. Introduction small steps according to a prescribed annealing schedule. For Over the last two decades extensive analytical and numerical a SG, the system energy is used as the cost function. At each work has been performed in order to obtain approximate temperature, enough simulation steps (spin flip trials) must solutions to optimization problems involving many par- be performed in order to ensure the system is equilibrated ameters and conflicting constraints [ 11. Classic examples of [3, 41. At very low temperature, this process causes the SG such problems include the traveling salesman problem (TSP), system to freeze into a state which is at least an approxi- the three dimensional spin glass ground state, and the wiring mation to the true ground state. For other combinational of gates in chip design. There exists an entire class of these optimization problems, a temperature is also introduced as a problems which is termed “NP-complete” (non-deterministic control parameter measured in units of the cost function. polynomial time complete) because the computational effort Usually simulated annealing is performed using the used to find an exact solution increases exponentially as the Metropolis [5] algorithm with temperature T fixed at each total number of degrees of freedom, N, of the problem. This state of the annealing schedule. The total cost function of the implies that approximation methods are required for further system is lowered due to local ordering and the temperature analysis. Indeed, heuristic methods are widely used for such provides the activation necessary to bring the system out of practical optimization problems in computer science and its metastable states. However, for metastable states with engineering and they prove to be extremely fruitful. However, high energy barriers, it is very hard for the thermal noise to these methods are usually problem-oriented and their domain provide enough activation. Thus the system can be locked of application is restricted to the particular problem which into a local minimum of the cost function space. This is the they are designed to solve. As the value of N for a particular reason that the annealing schedule must be carefully designed problem increases, algorithms based on statistical method and the annealing steps must be small [3, 41. become useful, and allow unified treatment of the NP-complete In this paper we present a study of an algorithm for problems. The most successful statistical method to date is simulated annealing which directly and deterministically the stochastic model of simulated annealing introduced by minimizes the cost function. The method is based on a micro- Kirkpatrick, Gelatt, and Vecchi in 1983 [2]. canonical ensemble in which the system of interest is in In simulated annealing, a cost function is constructed to contact with an auxiliary system (a “demon”) and the cost characterize the optimization process and minimization of function (energy) is exchanged between both systems. In this this function gives an approximation to the optimal solution method the temperature is actually a derived quantity. This of the problem. A controlled thermal treatment followed by allows large local temperature fluctuations which are essen- slow cooling give the system the chance to jump out of local tial for bringing the system out of metastable states. The minima of the cost function to improve solutions. Construct- methodology of the microcanonical Monte Carlo was first ing the cost function can in principle be problematic, although proposed by Creutz [6] to study the Ising model and has in practice the choice is often straightforward. For instance, subsequently been applied to a variety of physical systems [7]. the distance the salesman travels is the cost function of TSP. Although equilibrium statistical mechanics using the canonical Simulated annealing has been applied to the problem of and microcanonical ensembles are equivalent, the dynamics finding the ground state of a spin glass (SG) which is an of the algorithms based on these ensembles are different. We NP-complete problem in three dimensions [3, 41. A short find that this microcanonical Monte Carlo method is very range Ising spin glass is described by the Hamiltonian naturally applicable to optimization problems because it is deterministic and allows large temperature fluctuations. To our knowledge, an early attempt to use microcanonical where Si = f 1 is the spin at site i of a cubic lattice; Jij is Monte Carlo to study low temperature properties of a spin- usually assumed to be a random number drawn from a glass was due to Dasgupta, Ma and Hu [8]. Recently, Sourlas Physica Scripta T38 A Fast Algorithm for Simulated Annealing 41 [9] has also applied a microcanonical method to investigate We have applied our method to study both spin glass the ergodicity properties of a spin-glass. While the ideas are models. In 2d, the systems were on square lattices with up to similar, the algorithm to be presented below is most close to 100’ spins. In 3d, cubic lattices with up to 303spins were used. the one proposed by Clover [lo]. Periodic boundary conditions were used for all simulations. In Section 2 we present the method and apply it to several The units of energy were taken as J for the fJ model and 6J classic problems: the Ising spin glass, the STP and a short for the Gaussian model. discussion on its application to computer vision. Section 3 is For the 2d Gaussian model, we started with Er= 8 and reserved for a short summary and conclusion. All of our annealed down to Er= 0 with equal steps of 1. The simulations were performed on a SUN 3/50 workstation. systems used consisted of 100’ spins, and 400 or 800 Monte Carlo trials per spin were done for each Er.10 runs were 2. Method and results averaged to give the value Eo/GJ x - 1.30 f 0.004, which is in good agreement with that given by the transfer matrix Although the microcanonical Monte Carlo method has been method. Our results also compare favorably with those of the discussed in detail by Creutz [6], we briefly present it here Metropolis algorithm. for completenes. Consider a nearest neighbor Ising model For the 3d Gaussian model, the range of we used was described by Hamiltonian (1) with J,j = J, from 8 down to 0 with steps of 1 for the first 5 stages and 0.5 for the last 5 stages. For lattices with 163 spins, 600 Monte Elsing = - J SiS’. (2) 1 Carlo trials per spin were done for each of the r.Averaging To study its equilibrium properties, a microcanonical ensemble 30 independent runs gave Eo/SJ x - 1.674 f 0.0015 which is constructed by letting a demon with energy Ed interact with is somewhat higher than the transfer matrix estimate, although the spins such that the total energy E = Elsing+ Ed is con- within the error bars, but considerably lower than that found served. In a Monte Carlo simulation, the energy required to using the Metropolis Monte Carlo [3]. For lattices with 303 flip a spin, 6E, is compared with Ed, and if Ed 2 GE, the flip spins, test runs were also done using the same annealing is permitted and an amount of 6E is subtracted from Ed. schedule but with only 300 Monte Carlo trials per spin per Otherwise the trial is abandoned. It is easy to show [6] that the Er, we foundf Eo/6J = - 1.667 after averaging 5 runs. average demon energy measures the temperature of the Ising Since the transfer matrix calculation quoted above is per- system in equilibrium. formed on systems with 43 spins, and there is very little The microcanonical Monte Carlo method is generalized information about the ground state energy for larger systems, for simulated annealing as follows. We begin the simulation our results could provide a benchmark for further simulations. with the system at a disordered high temperature state and The 2d & J model was studied by using from 16 allow it to interact with the demon. At each stage of the down to 0 in steps of 4, with either 800 or 1600 Monte Carlo annealing schedule a maximum value of the demon cost steps per spin for each of the Eron lattices with 50’ spins.