Package org.moeaframework.algorithm.sa
Class AbstractSimulatedAnnealingAlgorithm
java.lang.Object
org.moeaframework.algorithm.AbstractAlgorithm
org.moeaframework.algorithm.sa.AbstractSimulatedAnnealingAlgorithm
- All Implemented Interfaces:
Algorithm,Extensible,Configurable,Named,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
FieldsModifier and TypeFieldDescriptionprotected NondominatedPopulationThe archive storing the non-dominated solutions.protected CoolingScheduleThe cooling (or reduction) schedule that determines how the temperature decreases over time.protected SolutionThe current point.protected InitializationThe initialization operator.protected doubleThe initial, or maximum, temperature.protected MutationThe mutation operator used to generate neighbors of the current point.protected doubleThe current temperature.protected TemperatureBasedTerminationConditionSelf-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
ConstructorsConstructorDescriptionAbstractSimulatedAnnealingAlgorithm(Problem problem, double initialTemperature, CoolingSchedule coolingSchedule, Initialization initialization, Mutation mutation) Constructs a new, abstract simulated annealing algorithm. -
Method Summary
Modifier and TypeMethodDescriptionprotected NondominatedPopulationReturns 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.doubleReturns the initial, or maximum, temperature.Returns the mutation operator.Returns the current best-known result.doubleReturns the current temperature.Returns the temperature-based termination condition.voidPerforms any initialization that is required by this algorithm.protected voiditerate()Performs one iteration of the algorithm.protected abstract voiditerate(double temperature) Performs one iteration of this SA instance using the given temperature.voidloadState(ObjectInputStream stream) Loads the state of this object from the stream.voidsaveState(ObjectOutputStream stream) Writes the state of this object to the stream.protected voidsetArchive(NondominatedPopulation archive) Sets the archive used by this algorithm.protected voidsetCoolingSchedule(CoolingSchedule coolingSchedule) Sets the cooling (or reduction) schedule that determines how the temperature decreases over time.voidsetInitialization(Initialization initialization) Sets the initialization method for generating solutions in the initial population.voidsetInitialTemperature(double initialTemperature) Sets the initial, or maximum, temperature.voidsetMutation(Mutation mutation) Sets the mutation operator.protected voidsetTerminationCondition(TemperatureBasedTerminationCondition terminationCondition) Sets the temperature-based termination condition.Methods inherited from class org.moeaframework.algorithm.AbstractAlgorithm
assertNotInitialized, evaluate, getExtensions, getNumberOfEvaluations, getProblem, isInitialized, isTerminated, step, terminateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.moeaframework.algorithm.Algorithm
evaluateAll, evaluateAll, getName, run, runMethods inherited from interface org.moeaframework.core.configuration.Configurable
applyConfiguration, getConfigurationMethods 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
nullif not set
-
setTerminationCondition
Sets the temperature-based termination condition.- Parameters:
terminationCondition- the temperature-based termination condition, ornullif 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:AlgorithmPerforms 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 throwAlgorithmInitializationExceptionif called multiple times.Implementations should always call
super.initialize()to ensure the algorithm is initialized correctly.- Specified by:
initializein interfaceAlgorithm- Overrides:
initializein classAbstractAlgorithm
-
iterate
protected void iterate()Description copied from class:AbstractAlgorithmPerforms one iteration of the algorithm. This method should be overridden by implementations to perform each logical iteration of the algorithm.- Specified by:
iteratein 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:AlgorithmReturns the current best-known result. -
saveState
Description copied from interface:StatefulWrites 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:
saveStatein interfaceStateful- Overrides:
saveStatein classAbstractAlgorithm- Parameters:
stream- the stream- Throws:
IOException- if an I/O error occurred
-
loadState
Description copied from interface:StatefulLoads 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:
loadStatein interfaceStateful- Overrides:
loadStatein classAbstractAlgorithm- Parameters:
stream- the stream- Throws:
IOException- if an I/O error occurredClassNotFoundException- if the stream referenced a class that is not defined
-