Class AdaptiveTimeContinuationExtension
java.lang.Object
org.moeaframework.algorithm.extension.PeriodicExtension
org.moeaframework.algorithm.continuation.AdaptiveTimeContinuationExtension
- All Implemented Interfaces:
Extension
,Configurable
,Stateful
- Direct Known Subclasses:
EpsilonProgressContinuationExtension
Decorator for
EvolutionaryAlgorithm
s to add time continuation (restarts). Restarts occur if either
- the number of fitness function evaluations since the last restart exceeds
maxWindowSize
; or - the population-to-archive ratio exceeds
populationRatio
by more than25%
.
populationRatio
, the the new population is filled with solutions selected from
algorithm.getArchive()
and mutated using the specified Selection
and Variation
operators.
References:
- Goldberg, D. E. "Sizing Populations for Serial and Parallel Genetic Algorithms." In 3rd International Conference on Genetic Algorithms, pp. 70-79, 1989.
- Srivastava, R. P. "Time Continuation in Genetic Algorithms." Technical report, Illinois Genetic Algorithm Laboratory, 2002.
- Kollat, J. B., and Reed, P. M. "Comparison of Multi-Objective Evolutionary Algorithms for Long-Term Monitoring Design." Advances in Water Resources, 29(6):792-807, 2006.
-
Field Summary
Fields inherited from class org.moeaframework.algorithm.extension.PeriodicExtension
frequency, frequencyType, iteration, lastInvocation
-
Constructor Summary
ConstructorDescriptionCreates the adaptive time continuation extension with default settings.AdaptiveTimeContinuationExtension
(int windowSize, int maxWindowSize, double injectionRate, int minimumPopulationSize, int maximumPopulationSize, Selection restartSelection, Variation restartVariation) Creates the adaptive time continuation extension. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRestartListener
(RestartListener listener) Adds a listener to be notified whenever a restart occurs.protected RestartType
Performs a check to determine if a restart should occur.void
The action that is called by this extension.double
Returns the percentage of the population that, during a restart, are introduced into the new population.int
Returns the maximum size of the population.int
Returns the maximum number of iterations allowed since the last restart before forcing a restart.int
Returns the minimum size of the population.int
Returns the number of iterations between invocations ofcheck
.void
loadState
(ObjectInputStream stream) Loads the state of this object from the stream.void
onRegister
(Algorithm algorithm) Called when this extension is registered with an algorithm.void
removeRestartListener
(RestartListener listener) Removes the specified listener so it no longer receives notifications whenever a restart occurs.protected void
restart
(Algorithm algorithm, RestartType type) Performs a restart.void
saveState
(ObjectOutputStream stream) Writes the state of this object to the stream.void
setInjectionRate
(double injectionRate) Sets the percentage of the population that, during a restart, are introduced into the new population.void
setMaximumPopulationSize
(int maximumPopulationSize) Sets the maximum size of the population.void
setMaxWindowSize
(int maxWindowSize) Sets the maximum number of iterations allowed since the last restart before forcing a restart.void
setMinimumPopulationSize
(int minimumPopulationSize) Sets the minimum size of the population.void
setWindowSize
(int windowSize) Sets the number of iterations between invocations ofcheck
.Methods inherited from class org.moeaframework.algorithm.extension.PeriodicExtension
onStep
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.configuration.Configurable
applyConfiguration, getConfiguration
Methods inherited from interface org.moeaframework.algorithm.extension.Extension
onInitialize, onTerminate
-
Constructor Details
-
AdaptiveTimeContinuationExtension
public AdaptiveTimeContinuationExtension()Creates the adaptive time continuation extension with default settings. -
AdaptiveTimeContinuationExtension
public AdaptiveTimeContinuationExtension(int windowSize, int maxWindowSize, double injectionRate, int minimumPopulationSize, int maximumPopulationSize, Selection restartSelection, Variation restartVariation) Creates the adaptive time continuation extension.- Parameters:
algorithm
- the algorithm being decoratedwindowSize
- the number of iterations between invocations ofcheck
maxWindowSize
- the maximum number of iterations allowed since the last restart before forcing a restartinjectionRate
- the injection rate percentageminimumPopulationSize
- the minimum size of the populationmaximumPopulationSize
- the maximum size of the populationrestartSelection
- the selection operator for selecting solutions from the archive during a restartrestartVariation
- the variation operator for mutating solutions selected from the archive during a restart
-
-
Method Details
-
getWindowSize
public int getWindowSize()Returns the number of iterations between invocations ofcheck
.- Returns:
- the window size, in iterations
-
setWindowSize
public void setWindowSize(int windowSize) Sets the number of iterations between invocations ofcheck
.- Parameters:
windowSize
- the window size, in iterations
-
getMaxWindowSize
public int getMaxWindowSize()Returns the maximum number of iterations allowed since the last restart before forcing a restart.- Returns:
- the maximum window size, in iterations
-
setMaxWindowSize
public void setMaxWindowSize(int maxWindowSize) Sets the maximum number of iterations allowed since the last restart before forcing a restart.- Parameters:
maxWindowSize
- the maximum window size, in iterations
-
getInjectionRate
public double getInjectionRate()Returns the percentage of the population that, during a restart, are introduced into the new population.- Returns:
- the injection rate
-
setInjectionRate
public void setInjectionRate(double injectionRate) Sets the percentage of the population that, during a restart, are introduced into the new population. The population will be resized to holdarchive.size() / injectionRate
solutions.- Parameters:
injectionRate
- the injection rate
-
getMinimumPopulationSize
public int getMinimumPopulationSize()Returns the minimum size of the population.- Returns:
- the minimum size of the population
-
setMinimumPopulationSize
public void setMinimumPopulationSize(int minimumPopulationSize) Sets the minimum size of the population.- Parameters:
minimumPopulationSize
- the minimum size of the population
-
getMaximumPopulationSize
public int getMaximumPopulationSize()Returns the maximum size of the population.- Returns:
- the maximum size of the population
-
setMaximumPopulationSize
public void setMaximumPopulationSize(int maximumPopulationSize) Sets the maximum size of the population.- Parameters:
maximumPopulationSize
- the maximum size of the population
-
addRestartListener
Adds a listener to be notified whenever a restart occurs.- Parameters:
listener
- the listener to be notified whenever a restart occurs
-
removeRestartListener
Removes the specified listener so it no longer receives notifications whenever a restart occurs.- Parameters:
listener
- the listener to be removed
-
onRegister
Description copied from interface:Extension
Called when this extension is registered with an algorithm. This can be used to perform any type checking or initialization.- Specified by:
onRegister
in interfaceExtension
- Overrides:
onRegister
in classPeriodicExtension
- Parameters:
algorithm
- the algorithm associated with this extension
-
check
Performs a check to determine if a restart should occur. ReturnsRestartType.NONE
if no restart should occur; orRestartType.HARD
if the population-to-archive ratio exceedspopulationRatio
by more than25%
or the number of fitness evaluations since the last restart exceedsmaxWindowSize
.- Parameters:
algorithm
- the evolutionary algorithm- Returns:
RestartType.NONE
if no restart should occur; orRestartType.HARD
if the population-to-archive ratio exceedspopulationRatio
by more than25%
or if the number of fitness evaluations since the last restart exceedsmaxWindowSize
-
restart
Performs a restart. If the type isRestartType.HARD
, the population is emptied, resized and filled with solutions selected and mutated from the archive. If the type isRestartType.SOFT
, the population is not emptied; new solutions are only added to fill any empty slots.- Parameters:
algorithm
- the evolutionary algorithmtype
- the type of restart
-
doAction
Description copied from class:PeriodicExtension
The action that is called by this extension.- Specified by:
doAction
in classPeriodicExtension
- Parameters:
algorithm
- the algorithm associated with this extension
-
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 classPeriodicExtension
- 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 classPeriodicExtension
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurredClassNotFoundException
- if the stream referenced a class that is not defined
-