Class SimulatedAnnealing
java.lang.Object
org.moeaframework.algorithm.AbstractAlgorithm
org.moeaframework.algorithm.sa.AbstractSimulatedAnnealingAlgorithm
org.moeaframework.algorithm.single.SimulatedAnnealing
- All Implemented Interfaces:
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.protected void
Performs any initialization that is required by this algorithm.protected void
iterate()
Performs one iteration of the algorithm.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, loadState, saveState, setArchive, setCoolingSchedule, setInitialization, setInitialTemperature, setMutation, setTerminationCondition, step
Methods inherited from class org.moeaframework.algorithm.AbstractAlgorithm
assertNotInitialized, evaluate, evaluateAll, evaluateAll, getNumberOfEvaluations, getProblem, isInitialized, isTerminated, terminate
-
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 toAbstractSimulatedAnnealingAlgorithm.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
protected void initialize()Description copied from class:AbstractAlgorithm
Performs any initialization that is required by this algorithm. This method is called automatically on the first invocation ofAbstractAlgorithm.step()
. Implementations should always invokesuper.initialize()
to ensure the algorithm is initialized correctly.- Overrides:
initialize
in classAbstractSimulatedAnnealingAlgorithm
-
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
-
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
-