The Encog Project

org.encog.solve.anneal
Class SimulatedAnnealing<UNIT_TYPE>

java.lang.Object
  extended by org.encog.solve.anneal.SimulatedAnnealing<UNIT_TYPE>
Type Parameters:
UNIT_TYPE - What type of data makes up the solution.

public abstract class SimulatedAnnealing<UNIT_TYPE>
extends java.lang.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
SimulatedAnnealing()
           
 
Method Summary
abstract  double determineError()
          Subclasses should provide a method that evaluates the error 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 getError()
           
 double getStartTemperature()
           
 double getStopTemperature()
           
 double getTemperature()
           
 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 cycles)
           
 void setError(double error)
          Set the error.
 void setStartTemperature(double startTemperature)
           
 void setStopTemperature(double stopTemperature)
           
 void setTemperature(double temperature)
           
 
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

determineError

public abstract double determineError()
Subclasses should provide a method that evaluates the error for the current solution. Those solutions with a lower error are better.

Returns:
Return the error, as a percent.

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

getError

public double getError()
Returns:
the globalError

getStartTemperature

public double getStartTemperature()
Returns:
the startTemperature

getStopTemperature

public double getStopTemperature()
Returns:
the stopTemperature

getTemperature

public double getTemperature()
Returns:
the temperature

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 cycles)
Parameters:
cycles - the cycles to set

setError

public void setError(double error)
Set the error.

Parameters:
error - The globalError to set.

setStartTemperature

public void setStartTemperature(double startTemperature)
Parameters:
startTemperature - the startTemperature to set

setStopTemperature

public void setStopTemperature(double stopTemperature)
Parameters:
stopTemperature - the stopTemperature to set

setTemperature

public void setTemperature(double temperature)
Parameters:
temperature - the temperature to set

The Encog Project