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
Modifier and TypeFieldDescriptionprotected final Archive
protected final IndividualCompleter
protected final Control
protected final Iteration
protected final Set<OptimizerIterationListener>
protected boolean
protected final Population
protected final Set<OptimizerStateListener>
-
Constructor Summary
ConstructorDescriptionAbstractOptimizer
(Population population, Archive archive, IndividualCompleter completer, Control control, Iteration iteration) Constructs anAbstractOptimizer
with aPopulation
, anArchive
, anIndividualFactory
, and aIndividualCompleter
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds anOptimizerIterationListener
to this optimizer.void
Adds anOptimizerStateListener
to this optimizer.int
Return the current iteration.protected void
injectListeners
(Set<OptimizerStateListener> stateListeners, Set<OptimizerIterationListener> iterationListeners) boolean
Returnstrue
if theOptimizer
is running.protected void
Call this method if a new iteration started.void
Removes anOptimizerIterationListener
from this optimizer.void
Removes anOptimizerStateListener
from this optimizer.void
This method is called once the optimization process has started.void
This 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 anAbstractOptimizer
with 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:Optimizer
Return the current iteration.- Specified by:
getIteration
in interfaceOptimizer
- Returns:
- the current iteration
-
isRunning
public boolean isRunning()Description copied from interface:Optimizer
Returnstrue
if theOptimizer
is 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:Optimizer
This method is called once the optimization process has started.- Specified by:
startOptimization
in interfaceOptimizer
-
stopOptimization
public void stopOptimization()Description copied from interface:Optimizer
This method is called once the optimization process has stopped.- Specified by:
stopOptimization
in interfaceOptimizer
-
addOptimizerIterationListener
Description copied from interface:Optimizer
Adds anOptimizerIterationListener
to this optimizer.- Specified by:
addOptimizerIterationListener
in interfaceOptimizer
- Parameters:
listener
- the OptimizerIterationListener to add- See Also:
-
addOptimizerStateListener
Description copied from interface:Optimizer
Adds anOptimizerStateListener
to this optimizer.- Specified by:
addOptimizerStateListener
in interfaceOptimizer
- Parameters:
listener
- the OptimizerStateListener to add- See Also:
-
removeOptimizerIterationListener
Description copied from interface:Optimizer
Removes anOptimizerIterationListener
from this optimizer.- Specified by:
removeOptimizerIterationListener
in interfaceOptimizer
- Parameters:
listener
- the OptimizerIterationListener to remove- See Also:
-
removeOptimizerStateListener
Description copied from interface:Optimizer
Removes anOptimizerStateListener
from this optimizer.- Specified by:
removeOptimizerStateListener
in interfaceOptimizer
- Parameters:
listener
- the OptimizerStateListener to remove- See Also:
-