Class SimulatedAnnealing

All Implemented Interfaces:
Extensible, 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 AbstractAlgorithm.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

      public void initialize()
      Description copied from interface: Algorithm
      Performs any initialization that is required by this algorithm. This method should only be called once, though the specific implementation may choose to no-op or throw AlgorithmInitializationException if called multiple times.

      Implementations should always call super.initialize() to ensure the algorithm is initialized correctly.

      Specified by:
      initialize in interface Algorithm
      Overrides:
      initialize in class AbstractSimulatedAnnealingAlgorithm
    • iterate

      protected void iterate(double temperature)
      Description copied from class: AbstractSimulatedAnnealingAlgorithm
      Performs one iteration of this SA instance using the given temperature.
      Specified by:
      iterate in class AbstractSimulatedAnnealingAlgorithm
      Parameters:
      temperature - the current temperature
    • 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