In linear cooling, the k-th temperature, tk, is determined as follows: tk = t0 - k * Δt, where t0 is the initial temperature and Δt is the difference between two consecutive temperature values. The new temperature is usually computed incrementally from the previous with: tk = tk-1 - Δt. In some applications, the temperature update occurs with each simulated annealing evaluation, while in others it is updated periodically, such as every s steps (i.e., iterations) of simulated annealing.
accept method of this class use the classic, and most common, Boltzmann
distribution for determining whether to accept a neighbor. With the Boltzmann distribution,
simulated annealing accepts a neighbor with higher cost than the current state with probability
e(c-n)/t where c is the cost of the current state, n > c is the cost of the random
neighbor, and t is the current temperature. Note that if n ≤ c, then simulated annealing
always accepts the neighbor.
A classic approach to setting the initial temperature t0 is to randomly sample the space of solutions to compute an estimate of ΔC, the average difference in cost between random neighbors, and to then set t0 = -ΔC / ln(P), where P < 1 is an initial target acceptance probability near 1. To see why, plug -ΔC / ln(P) into the Boltzmann distribution for t, and assume the cost c of the current state and the neighbor cost n exhibits the average difference, then you'd derive the following acceptance probability e(c-n)/t = e(c-n)/(-ΔC / ln(P)) = e-ΔC/(-ΔC / ln(P)) = eln(P) = P.
We use the following variation of this approach to determine an initial temperature. We initially accept all neighbors until we have seen 10 transitions between states with different cost values. We then use those 10 transitions to compute ΔC, by averaging the absolute value of the difference in costs across the 10 pairs of neighboring solutions, and set t0 = -ΔC / ln(0.95).
We then set Δt and steps (number of transitions between temperature changes) based on
the run length specified in the maxEvals parameter of
init(int) such that the temperature t
declines to 0.001 by the end of the run. Specifically, we set Δt = (t0 - 0.001)
/ ceiling(k / steps), where k is the number of remaining iterations (maxEvals reduced by the
number of iterations necessary to obtain the 10 samples used to compute t0) and where
steps is set to the lowest power of 2 such that the Δt we compute is Δt ≥
10-6. The rationale for setting steps to a power of 2 is for efficiency in computing
Δt and steps (start steps at 1 and double until Δt is in target range, very few
iterations needed and usually terminates after first).
Constructor SummaryConstructorDescriptionConstructs a linear cooling schedule that uses first few samples to estimate cost difference between random neighbors, and then uses that estimate to set the initial temperature, temperature delta, and step size.
Method SummaryModifier and TypeMethodDescription
(double neighborCost, double currentCost)Determine whether or not to accept a neighboring solution based on its cost and the current cost, both passed as parameters.
(int maxEvals)Perform any initialization necessary for the annealing schedule at to the start of a run of simulated annealing.
split()Generates a functionally identical copy of this object, for use in multithreaded implementations of search algorithms.
ParameterFreeLinearCoolingpublic ParameterFreeLinearCooling()Constructs a linear cooling schedule that uses first few samples to estimate cost difference between random neighbors, and then uses that estimate to set the initial temperature, temperature delta, and step size.
initpublic void init
(int maxEvals)Description copied from interface:
AnnealingSchedulePerform any initialization necessary for the annealing schedule at to the start of a run of simulated annealing. This includes initializing the temperature parameter. This method is called once by implementations of simulated annealing at the start of the run. Implementations of simulated annealing that perform reannealing will also call this once at the start of each reanneal.
- Specified by:
maxEvals- The maximum length of the run of simulated annealing about to start. Some annealing schedules depend upon prior knowledge of run length. For those annealing schedules that don't depend upon run length, this parameter is ignored.
acceptpublic boolean accept
(double neighborCost, double currentCost)Description copied from interface:
AnnealingScheduleDetermine whether or not to accept a neighboring solution based on its cost and the current cost, both passed as parameters. Lower cost indicates better solution. This method must also update the temperature and any other state data related to the annealing schedule.
splitpublic ParameterFreeLinearCooling split()Description copied from interface:
SplittableGenerates a functionally identical copy of this object, for use in multithreaded implementations of search algorithms. The state of the object that is returned may or may not be identical to that of the original. Thus, this is a distinct concept from the functionality of the
Copyableinterface. Classes that implement this interface must ensure that the object returned performs the same functionality, and that it does not share any state data that would be either unsafe or inefficient for concurrent access by multiple threads. The split method is allowed to simply return the this reference, provided that it is both safe and efficient for multiple threads to share a single copy of the Splittable object. The intention is to provide a multithreaded search with the capability to provide spawned threads with their own distinct search operators. Such multithreaded algorithms can call the split method for each thread it spawns to generate a functionally identical copy of the operator, but with independent state.