org.encog.ml.anneal

## Class SimulatedAnnealing<UNIT_TYPE>

- java.lang.Object
- - org.encog.ml.anneal.SimulatedAnnealing<UNIT_TYPE>

- Type Parameters:
    `UNIT_TYPE` - What type of data makes up the solution.
  Direct Known Subclasses:
    NeuralSimulatedAnnealingHelper

      public abstract class SimulatedAnnealing<UNIT_TYPE>
      extends Object

  Simulated annealing is a common training method. This class implements a simulated annealing algorithm that can be used both for neural networks, as well as more general cases. This class is abstract, so a more specialized simulated annealing subclass will need to be created for each intended use. This book demonstrates how to use the simulated annealing algorithm to train feedforward neural networks, as well as find a solution to the traveling salesman problem. The name and inspiration come from annealing in metallurgy, a technique involving heating and controlled cooling of a material to increase the size of its crystals and reduce their defects. The heat causes the atoms to become unstuck from their initial positions (a local minimum of the internal energy) and wander randomly through states of higher energy; the slow cooling gives them more chances of finding configurations with lower internal energy than the initial one.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimulatedAnnealing()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract double` | `calculateScore()` Subclasses should provide a method that evaluates the score for the current solution.
    `abstract UNIT_TYPE[]` | `getArray()` Subclasses must provide access to an array that makes up the solution.
    `abstract UNIT_TYPE[]` | `getArrayCopy()` Get a copy of the array.
    `int` | `getCycles()`
    `double` | `getScore()`
    `double` | `getStartTemperature()`
    `double` | `getStopTemperature()`
    `double` | `getTemperature()`
    `boolean` | `isShouldMinimize()`
    `void` | `iteration()` Called to perform one cycle of the annealing process.
    `abstract void` | `putArray(UNIT_TYPE[] array)` Store the array.
    `abstract void` | `randomize()` Randomize the weight matrix.
    `void` | `setCycles(int theCycles)`
    `void` | `setScore(double theScore)` Set the score.
    `void` | `setShouldMinimize(boolean theShouldMinimize)` Should the score be minimized.
    `void` | `setStartTemperature(double theStartTemperature)`
    `void` | `setStopTemperature(double theStopTemperature)`
    `void` | `setTemperature(double theTemperature)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SimulatedAnnealing

          public SimulatedAnnealing()

  - ### Method Detail

    - #### calculateScore

          public abstract double calculateScore()

      Subclasses should provide a method that evaluates the score for the current solution. Those solutions with a lower score are better.
      Returns:
        Return the score.

    - #### getArray

          public abstract UNIT_TYPE[] getArray()

      Subclasses must provide access to an array that makes up the solution.
      Returns:
        An array that makes up the solution.

    - #### getArrayCopy

          public abstract UNIT_TYPE[] getArrayCopy()

      Get a copy of the array.
      Returns:
        A copy of the array.

    - #### getCycles

          public int getCycles()

      Returns:
        the cycles

    - #### getScore

          public double getScore()

      Returns:
        the globalScore

    - #### getStartTemperature

          public double getStartTemperature()

      Returns:
        the startTemperature

    - #### getStopTemperature

          public double getStopTemperature()

      Returns:
        the stopTemperature

    - #### getTemperature

          public double getTemperature()

      Returns:
        the temperature

    - #### isShouldMinimize

          public boolean isShouldMinimize()

      Returns:
        True if the score should be minimized.

    - #### iteration

          public void iteration()

      Called to perform one cycle of the annealing process.

    - #### putArray

          public abstract void putArray(UNIT_TYPE[] array)

      Store the array.
      Parameters:
        `array` - The array to be stored.

    - #### randomize

          public abstract void randomize()

      Randomize the weight matrix.

    - #### setCycles

          public void setCycles(int theCycles)

      Parameters:
        `theCycles` - the cycles to set

    - #### setScore

          public void setScore(double theScore)

      Set the score.
      Parameters:
        `theScore` - The score to set.

    - #### setShouldMinimize

          public void setShouldMinimize(boolean theShouldMinimize)

      Should the score be minimized.
      Parameters:
        `theShouldMinimize` - True if the score should be minimized.

    - #### setStartTemperature

          public void setStartTemperature(double theStartTemperature)

      Parameters:
        `theStartTemperature` - the startTemperature to set

    - #### setStopTemperature

          public void setStopTemperature(double theStopTemperature)

      Parameters:
        `theStopTemperature` - the stopTemperature to set

    - #### setTemperature

          public void setTemperature(double theTemperature)

      Parameters:
        `theTemperature` - the temperature to set

Copyright © 2014. All Rights Reserved.