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 java.lang.ObjectSimulated 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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract doublecalculateScore()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.intgetCycles()doublegetScore()doublegetStartTemperature()doublegetStopTemperature()doublegetTemperature()booleanisShouldMinimize()voiditeration()Called to perform one cycle of the annealing process.abstract voidputArray(UNIT_TYPE[] array)Store the array.abstract voidrandomize()Randomize the weight matrix.voidsetCycles(int theCycles)voidsetScore(double theScore)Set the score.voidsetShouldMinimize(boolean theShouldMinimize)Should the score be minimized.voidsetStartTemperature(double theStartTemperature)voidsetStopTemperature(double theStopTemperature)voidsetTemperature(double theTemperature)
-
-
-
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
-
-
DMelt 3.0 © DataMelt by jWork.ORG