Class SimulatedAnnealing
java.lang.Object
org.moeaframework.algorithm.AbstractAlgorithm
org.moeaframework.algorithm.sa.AbstractSimulatedAnnealingAlgorithm
org.moeaframework.algorithm.single.SimulatedAnnealing
- All Implemented Interfaces:
Algorithm,Extensible,Configurable,Named,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
FieldsModifier and TypeFieldDescriptionprotected AggregateObjectiveComparatorThe aggregate objective comparator.protected intThe number of iterations at each temperatureFields inherited from class org.moeaframework.algorithm.sa.AbstractSimulatedAnnealingAlgorithm
archive, coolingSchedule, currentPoint, initialization, initialTemperature, mutation, temperature, terminationConditionFields inherited from class org.moeaframework.algorithm.AbstractAlgorithm
initialized, numberOfEvaluations, problem, terminated -
Constructor Summary
ConstructorsConstructorDescriptionSimulatedAnnealing(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 TypeMethodDescriptionvoidapplyConfiguration(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.getName()Returns the name of this algorithm.intReturns the number of iterations performed at each temperature.voidPerforms any initialization that is required by this algorithm.protected voiditerate(double temperature) Performs one iteration of this SA instance using the given temperature.voidsetComparator(AggregateObjectiveComparator comparator) Sets the aggregate objective comparator that scalarizes multiple objectives into a single fitness value.voidsetNumberOfIterationsPerTemperature(int numberOfIterationsPerTemperature) Sets the number of iterations performed at each temperature.protected voidupdateCurrentPoint(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, setTerminationConditionMethods 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, run, runMethods 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
-
getName
Description copied from interface:AlgorithmReturns the name of this algorithm. Whenever possible, this name should match the name recognized byAlgorithmFactory.- Returns:
- the name of this algorithm
-
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: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 classAbstractSimulatedAnnealingAlgorithm
-
iterate
protected void iterate(double temperature) Description copied from class:AbstractSimulatedAnnealingAlgorithmPerforms one iteration of this SA instance using the given temperature.- Specified by:
iteratein 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:ConfigurableApplies 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 call
TypedProperties.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 any
Configurableobjects inside this object, they should be updated before callingsuper.applyConfiguration(properties).- Parameters:
properties- the user-defined properties
-
getConfiguration
Description copied from interface:ConfigurableGets 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
-