Class SimulatedAnnealing
java.lang.Object
org.moeaframework.algorithm.AbstractAlgorithm
org.moeaframework.algorithm.sa.AbstractSimulatedAnnealingAlgorithm
org.moeaframework.algorithm.single.SimulatedAnnealing
- All Implemented Interfaces:
Extensible
,Algorithm
,Configurable
,Stateful
Implementation of single-objective simulated annealing.
References:
- Kirkpatrick, S., Gelatt Jr, C. D., and Vecchi, M. P. (1983). "Optimization by Simulated Annealing". Science. 220 (4598): 671–680.
-
Field Summary
Modifier and TypeFieldDescriptionprotected AggregateObjectiveComparator
The aggregate objective comparator.protected int
The number of iterations at each temperatureFields inherited from class org.moeaframework.algorithm.sa.AbstractSimulatedAnnealingAlgorithm
archive, coolingSchedule, currentPoint, initialization, initialTemperature, mutation, temperature, terminationCondition
Fields inherited from class org.moeaframework.algorithm.AbstractAlgorithm
initialized, numberOfEvaluations, problem, terminated
-
Constructor Summary
ConstructorDescriptionSimulatedAnnealing
(Problem problem) Creates a new instance of the Simulated Annealing (SA) algorithm with default settings.SimulatedAnnealing
(Problem problem, double initialTemperature, CoolingSchedule coolingSchedule, Initialization initialization, Mutation mutation, TemperatureBasedTerminationCondition terminationCondition, int numberOfIterationsPerTemperature) Creates a new instance of the Simulated Annealing (SA) algorithm. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyConfiguration
(TypedProperties properties) Applies the properties to this instance.Returns the aggregate objective comparator that scalarizes multiple objectives into a single fitness value.Gets the current configuration of this instance.int
Returns the number of iterations performed at each temperature.void
Performs any initialization that is required by this algorithm.protected void
iterate
(double temperature) Performs one iteration of this SA instance using the given temperature.void
setComparator
(AggregateObjectiveComparator comparator) Sets the aggregate objective comparator that scalarizes multiple objectives into a single fitness value.void
setNumberOfIterationsPerTemperature
(int numberOfIterationsPerTemperature) Sets the number of iterations performed at each temperature.protected void
updateCurrentPoint
(Solution newPoint) Updates the current point and, if configured, adds the point to the archive.Methods inherited from class org.moeaframework.algorithm.sa.AbstractSimulatedAnnealingAlgorithm
getArchive, getCoolingSchedule, getCurrentPoint, getInitialization, getInitialTemperature, getMutation, getResult, getTemperature, getTerminationCondition, iterate, loadState, saveState, setArchive, setCoolingSchedule, setInitialization, setInitialTemperature, setMutation, setTerminationCondition
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.algorithm.extension.Extensible
addExtension, removeExtension
-
Field Details
-
comparator
The aggregate objective comparator. -
numberOfIterationsPerTemperature
protected int numberOfIterationsPerTemperatureThe number of iterations at each temperature
-
-
Constructor Details
-
SimulatedAnnealing
Creates a new instance of the Simulated Annealing (SA) algorithm with default settings.- Parameters:
problem
- the problem to solve
-
SimulatedAnnealing
public SimulatedAnnealing(Problem problem, double initialTemperature, CoolingSchedule coolingSchedule, Initialization initialization, Mutation mutation, TemperatureBasedTerminationCondition terminationCondition, int numberOfIterationsPerTemperature) Creates a new instance of the Simulated Annealing (SA) algorithm.- Parameters:
problem
- the problem to solveinitialTemperature
- the initial temperaturecoolingSchedule
- the cooling scheduleinitialization
- the method for initializing solutionsmutation
- the mutation operatorterminationCondition
- the termination conditionnumberOfIterationsPerTemperature
- the number of iterations at each temperature
-
-
Method Details
-
getNumberOfIterationsPerTemperature
public int getNumberOfIterationsPerTemperature()Returns the number of iterations performed at each temperature. Note that all iterations for the same temperature are evaluated in a single call toAbstractAlgorithm.step()
.- Returns:
- the number of iterations
-
setNumberOfIterationsPerTemperature
public void setNumberOfIterationsPerTemperature(int numberOfIterationsPerTemperature) Sets the number of iterations performed at each temperature.- Parameters:
numberOfIterationsPerTemperature
- the number of iterations
-
getComparator
Returns the aggregate objective comparator that scalarizes multiple objectives into a single fitness value.- Returns:
- the aggregate objective comparator
-
setComparator
Sets the aggregate objective comparator that scalarizes multiple objectives into a single fitness value.- Parameters:
comparator
- the aggregate objective comparator
-
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 classAbstractSimulatedAnnealingAlgorithm
-
iterate
protected void iterate(double temperature) Description copied from class:AbstractSimulatedAnnealingAlgorithm
Performs one iteration of this SA instance using the given temperature.- Specified by:
iterate
in classAbstractSimulatedAnnealingAlgorithm
- Parameters:
temperature
- the current temperature
-
updateCurrentPoint
Updates the current point and, if configured, adds the point to the archive.- Parameters:
newPoint
- the new point
-
applyConfiguration
Description copied from interface:Configurable
Applies the properties to this instance. It is strongly recommended to apply a configuration immediately after creating the instance, as some properties can not be changed after the class is used. Exceptions may be thrown if attempting to set such properties. After calling this method, we encourage users to callTypedProperties.warnIfUnaccessedProperties()
to verify all properties were processed. This can identify simple mistakes like typos. If overriding this method, properties should only be updated if a new value is provided. Additionally, if updating anyConfigurable
objects inside this object, they should be updated before callingsuper.applyConfiguration(properties)
.- Parameters:
properties
- the user-defined properties
-
getConfiguration
Description copied from interface:Configurable
Gets the current configuration of this instance. In theory, these properties should be able to create a duplicate instance. Note however, they are unlikely to behave identically due to random numbers and other transient fields.- Returns:
- the properties defining this instance
-