Class SimulatedAnnealing

All Implemented Interfaces:
Algorithm, Configurable, Stateful

public class SimulatedAnnealing extends AbstractSimulatedAnnealingAlgorithm
Implementation of single-objective simulated annealing.

References:

  1. Kirkpatrick, S., Gelatt Jr, C. D., and Vecchi, M. P. (1983). "Optimization by Simulated Annealing". Science. 220 (4598): 671–680.
  • Field Details

    • comparator

      protected AggregateObjectiveComparator comparator
      The aggregate objective comparator.
    • numberOfIterationsPerTemperature

      protected int numberOfIterationsPerTemperature
      The number of iterations at each temperature
  • Constructor Details

    • SimulatedAnnealing

      public SimulatedAnnealing(Problem problem)
      Creates a new instance of the Simulated Annealing (SA) algorithm with default settings.
      Parameters:
      problem - the problem to solve
    • SimulatedAnnealing

      public SimulatedAnnealing(Problem problem, double initialTemperature, CoolingSchedule coolingSchedule, Initialization initialization, Mutation mutation, TemperatureBasedTerminationCondition terminationCondition, int numberOfIterationsPerTemperature)
      Creates a new instance of the Simulated Annealing (SA) algorithm.
      Parameters:
      problem - the problem to solve
      initialTemperature - the initial temperature
      coolingSchedule - the cooling schedule
      initialization - the method for initializing solutions
      mutation - the mutation operator
      terminationCondition - the termination condition
      numberOfIterationsPerTemperature - the number of iterations at each temperature
  • Method Details

    • getNumberOfIterationsPerTemperature

      public int getNumberOfIterationsPerTemperature()
      Returns the number of iterations performed at each temperature. Note that all iterations for the same temperature are evaluated in a single call to AbstractSimulatedAnnealingAlgorithm.step().
      Returns:
      the number of iterations
    • setNumberOfIterationsPerTemperature

      public void setNumberOfIterationsPerTemperature(int numberOfIterationsPerTemperature)
      Sets the number of iterations performed at each temperature.
      Parameters:
      numberOfIterationsPerTemperature - the number of iterations
    • getComparator

      public AggregateObjectiveComparator getComparator()
      Returns the aggregate objective comparator that scalarizes multiple objectives into a single fitness value.
      Returns:
      the aggregate objective comparator
    • setComparator

      public void setComparator(AggregateObjectiveComparator comparator)
      Sets the aggregate objective comparator that scalarizes multiple objectives into a single fitness value.
      Parameters:
      comparator - the aggregate objective comparator
    • initialize

      protected void initialize()
      Description copied from class: AbstractAlgorithm
      Performs any initialization that is required by this algorithm. This method is called automatically on the first invocation of AbstractAlgorithm.step(). Implementations should always invoke super.initialize() to ensure the algorithm is initialized correctly.
      Overrides:
      initialize in class AbstractSimulatedAnnealingAlgorithm
    • iterate

      protected void iterate()
      Description copied from class: AbstractAlgorithm
      Performs one iteration of the algorithm. This method should be overridden by implementations to perform each logical iteration of the algorithm.
      Specified by:
      iterate in class AbstractAlgorithm
    • updateCurrentPoint

      protected void updateCurrentPoint(Solution newPoint)
      Updates the current point and, if configured, adds the point to the archive.
      Parameters:
      newPoint - the new point
    • applyConfiguration

      public void applyConfiguration(TypedProperties properties)
      Description copied from interface: Configurable
      Applies the properties to this instance. It is strongly recommended to apply a configuration immediately after creating the instance, as some properties can not be changed after the class is used. Exceptions may be thrown if attempting to set such properties. After calling this method, we encourage users to call TypedProperties.warnIfUnaccessedProperties() to verify all properties were processed. This can identify simple mistakes like typos. If overriding this method, properties should only be updated if a new value is provided. Additionally, if updating any Configurable objects inside this object, they should be updated before calling super.applyConfiguration(properties).
      Parameters:
      properties - the user-defined properties
    • getConfiguration

      public TypedProperties getConfiguration()
      Description copied from interface: Configurable
      Gets the current configuration of this instance. In theory, these properties should be able to create a duplicate instance. Note however, they are unlikely to behave identically due to random numbers and other transient fields.
      Returns:
      the properties defining this instance