Package org.moeaframework.algorithm.sa
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 Summary
Modifier and TypeFieldDescriptionprotected NondominatedPopulation
The archive storing the non-dominated solutions.protected CoolingSchedule
The cooling (or reduction) schedule that determines how the temperature decreases over time.protected Solution
The current point.protected Initialization
The initialization operator.protected double
The initial, or maximum, temperature.protected Mutation
The mutation operator used to generate neighbors of the current point.protected double
The current temperature.protected TemperatureBasedTerminationCondition
Self-terminates the execution of this algorithm when the temperature drops below a minimum threshold.Fields inherited from class org.moeaframework.algorithm.AbstractAlgorithm
initialized, numberOfEvaluations, problem, terminated
-
Constructor Summary
ConstructorDescriptionAbstractSimulatedAnnealingAlgorithm
(Problem problem, double initialTemperature, CoolingSchedule coolingSchedule, Initialization initialization, Mutation mutation) Constructs a new, abstract simulated annealing algorithm. -
Method Summary
Modifier and TypeMethodDescriptionprotected NondominatedPopulation
Returns the archive used by this algorithm.Returns the cooling (or reduction) schedule that determines how the temperature decreases over time.Returns the current point.Returns the initialization method for generating solutions in the initial population.double
Returns the initial, or maximum, temperature.Returns the mutation operator.Returns the current best-known result.double
Returns the current temperature.Returns the temperature-based termination condition.void
Performs any initialization that is required by this algorithm.protected void
iterate()
Performs one iteration of the algorithm.protected abstract void
iterate
(double temperature) Performs one iteration of this SA instance using the given temperature.void
loadState
(ObjectInputStream stream) Loads the state of this object from the stream.void
saveState
(ObjectOutputStream stream) Writes the state of this object to the stream.protected void
setArchive
(NondominatedPopulation archive) Sets the archive used by this algorithm.protected void
setCoolingSchedule
(CoolingSchedule coolingSchedule) Sets the cooling (or reduction) schedule that determines how the temperature decreases over time.void
setInitialization
(Initialization initialization) Sets the initialization method for generating solutions in the initial population.void
setInitialTemperature
(double initialTemperature) Sets the initial, or maximum, temperature.void
setMutation
(Mutation mutation) Sets the mutation operator.protected void
setTerminationCondition
(TemperatureBasedTerminationCondition terminationCondition) Sets the temperature-based termination condition.Methods inherited from class org.moeaframework.algorithm.AbstractAlgorithm
assertNotInitialized, evaluate, getExtensions, getNumberOfEvaluations, getProblem, isInitialized, isTerminated, step, terminate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.moeaframework.core.Algorithm
evaluateAll, evaluateAll, run, run
Methods inherited from interface org.moeaframework.core.configuration.Configurable
applyConfiguration, getConfiguration
Methods inherited from interface org.moeaframework.algorithm.extension.Extensible
addExtension, removeExtension
-
Field Details
-
initialTemperature
protected double initialTemperatureThe initial, or maximum, temperature. -
coolingSchedule
The cooling (or reduction) schedule that determines how the temperature decreases over time. -
terminationCondition
Self-terminates the execution of this algorithm when the temperature drops below a minimum threshold. Ifnull
, will not self-terminate and instead runs until some other termination condition is reached. -
initialization
The initialization operator. -
mutation
The mutation operator used to generate neighbors of the current point. -
temperature
protected double temperatureThe current temperature. -
currentPoint
The current point. -
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 solveinitialTemperature
- the initial, or maximum, temperaturecoolingSchedule
- the cooling schedule that determines how the temperature decreases over timeinitialization
- the initialization methodmutation
- 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
Returns the cooling (or reduction) schedule that determines how the temperature decreases over time.- Returns:
- the cooling schedule
-
setCoolingSchedule
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
Returns the temperature-based termination condition.- Returns:
- the temperature-based termination condition, or
null
if not set
-
setTerminationCondition
Sets the temperature-based termination condition.- Parameters:
terminationCondition
- the temperature-based termination condition, ornull
if none is used
-
getInitialization
Returns the initialization method for generating solutions in the initial population.- Returns:
- the initialization method
-
setInitialization
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
Returns the mutation operator.- Returns:
- the mutation operator
-
setMutation
Sets the mutation operator.- Parameters:
mutation
- the mutation operator
-
getTemperature
public double getTemperature()Returns the current temperature.- Returns:
- the current temperature
-
getCurrentPoint
Returns the current point.- Returns:
- the current point
-
getArchive
Returns the archive used by this algorithm.- Returns:
- the archive used by this algorithm
-
setArchive
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 throwAlgorithmInitializationException
if called multiple times.Implementations should always call
super.initialize()
to ensure the algorithm is initialized correctly.- Specified by:
initialize
in interfaceAlgorithm
- Overrides:
initialize
in classAbstractAlgorithm
-
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 classAbstractAlgorithm
-
iterate
protected abstract void iterate(double temperature) Performs one iteration of this SA instance using the given temperature.- Parameters:
temperature
- the current temperature
-
getResult
Description copied from interface:Algorithm
Returns the current best-known result. -
saveState
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 callingsuper.saveState(stream)
followed by writing each field.- Specified by:
saveState
in interfaceStateful
- Overrides:
saveState
in classAbstractAlgorithm
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurred
-
loadState
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 inStateful.saveState(ObjectOutputStream)
.- Specified by:
loadState
in interfaceStateful
- Overrides:
loadState
in classAbstractAlgorithm
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurredClassNotFoundException
- if the stream referenced a class that is not defined
-