Class LogarithmicCooling

  • All Implemented Interfaces:
    Splittable<AnnealingSchedule>, AnnealingSchedule

    public final class LogarithmicCooling
    extends Object
    implements AnnealingSchedule

    This class implements logarithmic cooling, a classic annealing schedule. This annealing schedule is of theoretical interest, but in general is not practical. The classic convergence results for simulated annealing depend upon logarithmic cooling. In particular, with logarithmic cooling, if the temperature begins sufficiently high, then in the limit simulated annealing converges to the globally optimal solution. However, the temperature cools so slowly with logarithmic cooling that for any practical search length, the search remains essentially a random walk, and does not come anywhere close to the limit behavior. We have included the logarithmic cooling schedule in the library in the interests of being complete.

    In logarithmic cooling, the k-th temperature is defined as: tk = c / ln(k + d), where c and d are constants. The value of c should be set based on cost differences between random neighbors, and d is usually set equal to 1. In our case, since we start k at 0, a value of d=1 would lead to a division by 0. Additionally, to simplify initialization for the programmer using this annealing schedule, our implementation sets d=e (i.e., to the base of the natural logarithm). Logarithms are so slow growing that small differences in the value of d don't change the behavior of the schedule in any significant way. When k=0, the denominator is thus ln(e)=1. Thus, c can be set to the desired initial temperature. Therefore, our implementation redefines the cooling schedule as: tk = t0 / ln(k + e), where e is the base of the natural logarithm.

    • Constructor Summary

      Constructor Description
      LogarithmicCooling​(double t0)
      Constructs a logarithmic cooling schedule with a specified initial temperature.
    • Constructor Detail

      • LogarithmicCooling

        public LogarithmicCooling​(double t0)
        Constructs a logarithmic cooling schedule with a specified initial temperature.
        t0 - The initial temperature, which must be positive
        IllegalArgumentException - if t0 ≤ 0.0
    • Method Detail

      • init

        public void init​(int maxEvals)
        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 - This cooling schedule doesn't depend upon run length, so 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 LogarithmicCooling 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.