Package org.opt4j.core.optimizer
Class AbstractOptimizer
java.lang.Object
org.opt4j.core.optimizer.AbstractOptimizer
- All Implemented Interfaces:
Optimizer
- Direct Known Subclasses:
DifferentialEvolution,EvolutionaryAlgorithm,MOPSO,RandomSearch,SimulatedAnnealing
This
AbstractOptimizer is an abstract implementation of a
population-based Optimizer. All population based optimizers can be
derived from this class.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Archiveprotected final IndividualCompleterprotected final Controlprotected final Iterationprotected final Set<OptimizerIterationListener>protected booleanprotected final Populationprotected final Set<OptimizerStateListener> -
Constructor Summary
ConstructorsConstructorDescriptionAbstractOptimizer(Population population, Archive archive, IndividualCompleter completer, Control control, Iteration iteration) Constructs anAbstractOptimizerwith aPopulation, anArchive, anIndividualFactory, and aIndividualCompleter. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds anOptimizerIterationListenerto this optimizer.voidAdds anOptimizerStateListenerto this optimizer.intReturn the current iteration.protected voidinjectListeners(Set<OptimizerStateListener> stateListeners, Set<OptimizerIterationListener> iterationListeners) booleanReturnstrueif theOptimizeris running.protected voidCall this method if a new iteration started.voidRemoves anOptimizerIterationListenerfrom this optimizer.voidRemoves anOptimizerStateListenerfrom this optimizer.voidThis method is called once the optimization process has started.voidThis method is called once the optimization process has stopped.
-
Field Details
-
iteration
-
population
-
archive
-
completer
-
control
-
stateListeners
-
iterationListeners
-
optimizing
protected boolean optimizing
-
-
Constructor Details
-
AbstractOptimizer
public AbstractOptimizer(Population population, Archive archive, IndividualCompleter completer, Control control, Iteration iteration) Constructs anAbstractOptimizerwith aPopulation, anArchive, anIndividualFactory, and aIndividualCompleter.- Parameters:
population- the specified populationarchive- the specified archivecompleter- the specified completercontrol- the controliteration- the iteration counter
-
-
Method Details
-
injectListeners
@Inject protected void injectListeners(Set<OptimizerStateListener> stateListeners, Set<OptimizerIterationListener> iterationListeners) -
getIteration
public int getIteration()Description copied from interface:OptimizerReturn the current iteration.- Specified by:
getIterationin interfaceOptimizer- Returns:
- the current iteration
-
isRunning
public boolean isRunning()Description copied from interface:OptimizerReturnstrueif theOptimizeris running. -
nextIteration
Call this method if a new iteration started.- Throws:
StopException- if the optimization is stoppedTerminationException- if the optimization is terminated
-
startOptimization
public void startOptimization()Description copied from interface:OptimizerThis method is called once the optimization process has started.- Specified by:
startOptimizationin interfaceOptimizer
-
stopOptimization
public void stopOptimization()Description copied from interface:OptimizerThis method is called once the optimization process has stopped.- Specified by:
stopOptimizationin interfaceOptimizer
-
addOptimizerIterationListener
Description copied from interface:OptimizerAdds anOptimizerIterationListenerto this optimizer.- Specified by:
addOptimizerIterationListenerin interfaceOptimizer- Parameters:
listener- the OptimizerIterationListener to add- See Also:
-
addOptimizerStateListener
Description copied from interface:OptimizerAdds anOptimizerStateListenerto this optimizer.- Specified by:
addOptimizerStateListenerin interfaceOptimizer- Parameters:
listener- the OptimizerStateListener to add- See Also:
-
removeOptimizerIterationListener
Description copied from interface:OptimizerRemoves anOptimizerIterationListenerfrom this optimizer.- Specified by:
removeOptimizerIterationListenerin interfaceOptimizer- Parameters:
listener- the OptimizerIterationListener to remove- See Also:
-
removeOptimizerStateListener
Description copied from interface:OptimizerRemoves anOptimizerStateListenerfrom this optimizer.- Specified by:
removeOptimizerStateListenerin interfaceOptimizer- Parameters:
listener- the OptimizerStateListener to remove- See Also:
-