Class AbstractSimulatedAnnealingAlgorithm

java.lang.Object
org.moeaframework.algorithm.AbstractAlgorithm
org.moeaframework.algorithm.sa.AbstractSimulatedAnnealingAlgorithm
All Implemented Interfaces:
Extensible, Algorithm, Configurable, Stateful
Direct Known Subclasses:
AMOSA, SimulatedAnnealing

public abstract class AbstractSimulatedAnnealingAlgorithm extends AbstractAlgorithm implements Configurable
Abstract class of fundamental simulated annealing algorithm. While the iterations of evolving SA algorithms vary, fundamental mechanics of SA algorithm stands on solidification of fluids. This includes the current, initial (max), and stopping (min) temperatures.
  • Field Details

    • initialTemperature

      protected double initialTemperature
      The initial, or maximum, temperature.
    • coolingSchedule

      protected CoolingSchedule coolingSchedule
      The cooling (or reduction) schedule that determines how the temperature decreases over time.
    • terminationCondition

      protected TemperatureBasedTerminationCondition terminationCondition
      Self-terminates the execution of this algorithm when the temperature drops below a minimum threshold. If null, will not self-terminate and instead runs until some other termination condition is reached.
    • initialization

      protected Initialization initialization
      The initialization operator.
    • mutation

      protected Mutation mutation
      The mutation operator used to generate neighbors of the current point.
    • temperature

      protected double temperature
      The current temperature.
    • currentPoint

      protected Solution currentPoint
      The current point.
    • archive

      protected NondominatedPopulation archive
      The archive storing the non-dominated solutions.
  • Constructor Details

    • AbstractSimulatedAnnealingAlgorithm

      public AbstractSimulatedAnnealingAlgorithm(Problem problem, double initialTemperature, CoolingSchedule coolingSchedule, Initialization initialization, Mutation mutation)
      Constructs a new, abstract simulated annealing algorithm.
      Parameters:
      problem - the problem to solve
      initialTemperature - the initial, or maximum, temperature
      coolingSchedule - the cooling schedule that determines how the temperature decreases over time
      initialization - the initialization method
      mutation - the mutation operator used to generate neighbors of the current point
  • Method Details

    • getInitialTemperature

      public double getInitialTemperature()
      Returns the initial, or maximum, temperature.
      Returns:
      the initial temperature
    • setInitialTemperature

      public void setInitialTemperature(double initialTemperature)
      Sets the initial, or maximum, temperature. This value can only be set before initialization.
      Parameters:
      initialTemperature - the initial temperature
    • getCoolingSchedule

      public CoolingSchedule getCoolingSchedule()
      Returns the cooling (or reduction) schedule that determines how the temperature decreases over time.
      Returns:
      the cooling schedule
    • setCoolingSchedule

      protected void setCoolingSchedule(CoolingSchedule coolingSchedule)
      Sets the cooling (or reduction) schedule that determines how the temperature decreases over time. This can only be set before initializing the algorithm.
      Parameters:
      coolingSchedule - the cooling schedule
    • getTerminationCondition

      public TemperatureBasedTerminationCondition getTerminationCondition()
      Returns the temperature-based termination condition.
      Returns:
      the temperature-based termination condition, or null if not set
    • setTerminationCondition

      protected void setTerminationCondition(TemperatureBasedTerminationCondition terminationCondition)
      Sets the temperature-based termination condition.
      Parameters:
      terminationCondition - the temperature-based termination condition, or null if none is used
    • getInitialization

      public Initialization getInitialization()
      Returns the initialization method for generating solutions in the initial population.
      Returns:
      the initialization method
    • setInitialization

      public void setInitialization(Initialization initialization)
      Sets the initialization method for generating solutions in the initial population. This can only be set before initializing the algorithm.
      Parameters:
      initialization - the initialization method
    • getMutation

      public Mutation getMutation()
      Returns the mutation operator.
      Returns:
      the mutation operator
    • setMutation

      public void setMutation(Mutation mutation)
      Sets the mutation operator.
      Parameters:
      mutation - the mutation operator
    • getTemperature

      public double getTemperature()
      Returns the current temperature.
      Returns:
      the current temperature
    • getCurrentPoint

      public Solution getCurrentPoint()
      Returns the current point.
      Returns:
      the current point
    • getArchive

      protected NondominatedPopulation getArchive()
      Returns the archive used by this algorithm.
      Returns:
      the archive used by this algorithm
    • setArchive

      protected void setArchive(NondominatedPopulation archive)
      Sets the archive used by this algorithm. This value can not be set after initialization.
      Parameters:
      archive - the archive
    • 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 AbstractAlgorithm
    • 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
    • iterate

      protected abstract void iterate(double temperature)
      Performs one iteration of this SA instance using the given temperature.
      Parameters:
      temperature - the current temperature
    • getResult

      public NondominatedPopulation getResult()
      Description copied from interface: Algorithm
      Returns the current best-known result.
      Specified by:
      getResult in interface Algorithm
      Returns:
      the current best-known result
    • saveState

      public void saveState(ObjectOutputStream stream) throws IOException
      Description copied from interface: Stateful
      Writes the state of this object to the stream. The order that objects are written to the stream is important. We recommend first calling super.saveState(stream) followed by writing each field.
      Specified by:
      saveState in interface Stateful
      Overrides:
      saveState in class AbstractAlgorithm
      Parameters:
      stream - the stream
      Throws:
      IOException - if an I/O error occurred
    • loadState

      public void loadState(ObjectInputStream stream) throws IOException, ClassNotFoundException
      Description copied from interface: Stateful
      Loads the state of this object from the stream. The order for reading objects from the stream must match the order they are written to the stream in Stateful.saveState(ObjectOutputStream).
      Specified by:
      loadState in interface Stateful
      Overrides:
      loadState in class AbstractAlgorithm
      Parameters:
      stream - the stream
      Throws:
      IOException - if an I/O error occurred
      ClassNotFoundException - if the stream referenced a class that is not defined