Package org.moeaframework.core
Interface Algorithm
 All Superinterfaces:
Extensible
,Stateful
 All Known Subinterfaces:
EpsilonBoxEvolutionaryAlgorithm
,EvolutionaryAlgorithm
 All Known Implementing Classes:
AbstractAlgorithm
,AbstractEvolutionaryAlgorithm
,AbstractPSOAlgorithm
,AbstractSimulatedAnnealingAlgorithm
,AdaptiveTimeContinuation
,AGEMOEAII
,AlgorithmWrapper
,AMOSA
,Checkpoints
,CMAES
,DBEA
,DifferentialEvolution
,EpsilonMOEA
,EpsilonNSGAII
,EpsilonProgressContinuation
,EvolutionStrategy
,GDE3
,GeneticAlgorithm
,IBEA
,InstrumentedAlgorithm
,MOEAD
,MSOPS
,NSGAII
,NSGAIII
,OMOPSO
,PAES
,PeriodicAction
,PESA2
,RandomSearch
,RepeatedSingleObjective
,RVEA
,SimulatedAnnealing
,SingleObjectiveEvolutionaryAlgorithm
,SMPSO
,SMSEMOA
,SPEA2
,UNSGAIII
,VEGA
Interface for an optimization algorithm. An optimization algorithm operates by performing a series of optimization
steps, though the amount of work performed by each step depends on the algorithm. For example, an algorithm
may completely solve a problem in one step or may require hundreds of thousands of steps.

Method Summary
Modifier and TypeMethodDescriptionvoid
Evaluates the specified solution for the problem being solved by this algorithm.default void
evaluateAll
(Iterable<Solution> solutions) Evaluates the specified solutions.default void
evaluateAll
(Solution[] solutions) Evaluates the specified solutions.int
Returns the number of times theevaluate
method was invoked.Returns the problem being solved by this algorithm.Returns the current bestknown result.void
Performs any initialization that is required by this algorithm.boolean
Returnstrue
if this algorithm has been initialized;false
otherwise.boolean
Returnstrue
if this algorithm has reached its termination condition;false
otherwise.default void
run
(int evaluations) Executes this algorithm, terminating when it reaches a target number of function evaluations.default void
run
(TerminationCondition terminationCondition) Executes this algorithm until the terminal condition signals it to stop.void
step()
Performs one logical step of this algorithm.void
Called when the termination condition is reached and the run is complete.Methods inherited from interface org.moeaframework.algorithm.extension.Extensible
addExtension, getExtensions, removeExtension

Method Details

getProblem
Problem getProblem()Returns the problem being solved by this algorithm. Returns:
 the problem being solved by this algorithm

getResult
NondominatedPopulation getResult()Returns the current bestknown result. Returns:
 the current bestknown result

isInitialized
boolean isInitialized()Returnstrue
if this algorithm has been initialized;false
otherwise. Returns:
true
if this algorithm has been initialized;false
otherwise See Also:

initialize
void initialize()Performs any initialization that is required by this algorithm. This method should only be called once, though the specific implementation may choose to noop or throwAlgorithmInitializationException
if called multiple times.Implementations should always call
super.initialize()
to ensure the algorithm is initialized correctly. Throws:
AlgorithmInitializationException
 if the algorithm has already been initialized

step
void step()Performs one logical step of this algorithm. The amount of work performed depends on the implementation. One invocation of this method may produce one or many trial solutions.In general, calling this method after
terminate()
is permitted. When this happens,isTerminated()
is reset. We recommend checkingisTerminated()
after each step to detect when termination conditions are reached. However, if the implementation is unable to continue, this method should throwAlgorithmTerminationException
. 
run
default void run(int evaluations) Executes this algorithm, terminating when it reaches a target number of function evaluations. Please note that algorithms may have additional termination conditions that could cause this method to return before reaching the target number of evaluations. UsegetNumberOfEvaluations()
to verify the actual number of evaluations. Parameters:
evaluations
 the number of function evaluations

run
Executes this algorithm until the terminal condition signals it to stop. Parameters:
terminationCondition
 the termination condition

evaluateAll
Evaluates the specified solutions. This method callsevaluate(Solution)
on each of the solutions. Subclasses should prefer calling this method overevaluate
whenever possible, as this ensures the solutions can be evaluated in parallel. Parameters:
solutions
 the solutions to evaluate

evaluateAll
Evaluates the specified solutions. This method is equivalent toevaluateAll(Arrays.asList(solutions))
. Parameters:
solutions
 the solutions to evaluate

evaluate
Evaluates the specified solution for the problem being solved by this algorithm. Parameters:
solution
 the solution to be evaluated See Also:

getNumberOfEvaluations
int getNumberOfEvaluations()Returns the number of times theevaluate
method was invoked. This is the primary measure of runtime for optimization algorithms. Returns:
 the number of times the
evaluate
method was invoked

isTerminated
boolean isTerminated()Returnstrue
if this algorithm has reached its termination condition;false
otherwise. Returns:
true
if this algorithm has reached its termination condition;false
otherwise See Also:

terminate
void terminate()Called when the termination condition is reached and the run is complete. This method is automatically called when usingrun(TerminationCondition)
, but can also be invoked directly if executing the algorithm stepbystep withstep()
.Implementations should always call
super.terminate()
to ensure the algorithm is terminated correctly.
