Class ParameterFreeLinearCooling

  • All Implemented Interfaces:
    Splittable<AnnealingSchedule>, AnnealingSchedule

    public final class ParameterFreeLinearCooling
    extends Object
    implements AnnealingSchedule

    This class implements a parameter-free version of the linear cooling schedule for simulated annealing. In this parameter-free version of the linear cooling schedule, the initial temperature, the value of Δt, and the step size are all computed by the ParameterFreeLinearCooling object based on an estimate of the cost difference between random neighbors, and the run length specified upon calling the init(int) method.

    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.

    The 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 Summary

      Constructor Description
      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.
    • Constructor Detail

      • ParameterFreeLinearCooling

        public 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.
    • Method Detail

      • init

        public void init​(int maxEvals)
        Description copied from interface: AnnealingSchedule
        Perform 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:
        init in interface AnnealingSchedule
        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.
      • accept

        public boolean accept​(double neighborCost,
                              double currentCost)
        Description copied from interface: AnnealingSchedule
        Determine 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.
        Specified by:
        accept in interface AnnealingSchedule
        neighborCost - The cost of the neighboring solution under consideration.
        currentCost - The cost of the current solution.
        true if simulated annealing should accept the neighbor, and false otherwise.
      • split

        public ParameterFreeLinearCooling split()
        Description copied from interface: Splittable
        Generates 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 Copyable interface. 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.
        Specified by:
        split in interface Splittable<AnnealingSchedule>
        A functionally identical copy of the object, or a reference to this if it is both safe and efficient for multiple threads to share a single instance of this Splittable object.