Package org.moeaframework.algorithm
Interface Algorithm
- All Superinterfaces:
Extensible,Named,Stateful
- All Known Subinterfaces:
EpsilonBoxEvolutionaryAlgorithm,EvolutionaryAlgorithm
- All Known Implementing Classes:
AbstractAlgorithm,AbstractEvolutionaryAlgorithm,AbstractPSOAlgorithm,AbstractSimulatedAnnealingAlgorithm,AGEMOEAII,AlgorithmWrapper,AMOSA,CMAES,DBEA,DifferentialEvolution,EpsilonMOEA,EpsilonNSGAII,EvolutionStrategy,GDE3,GeneticAlgorithm,IBEA,InstrumentedAlgorithm,MOEAD,MSOPS,NSGAII,NSGAIII,OMOPSO,PAES,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 TypeMethodDescriptionvoidEvaluates the specified solution for the problem being solved by this algorithm.default voidevaluateAll(Iterable<Solution> solutions) Evaluates the specified solutions.default voidevaluateAll(Solution[] solutions) Evaluates the specified solutions.getName()Returns the name of this algorithm.intReturns the number of times theevaluatemethod was invoked.Returns the problem being solved by this algorithm.Returns the current best-known result.voidPerforms any initialization that is required by this algorithm.booleanReturnstrueif this algorithm has been initialized;falseotherwise.booleanReturnstrueif this algorithm has reached its termination condition;falseotherwise.default voidrun(int evaluations) Executes this algorithm, terminating when it reaches a target number of function evaluations.default voidrun(TerminationCondition terminationCondition) Executes this algorithm until the terminal condition signals it to stop.voidstep()Performs one logical step of this algorithm.voidCalled 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
-
getName
String getName()Returns the name of this algorithm. Whenever possible, this name should match the name recognized byAlgorithmFactory. -
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 best-known result.- Returns:
- the current best-known result
-
isInitialized
boolean isInitialized()Returnstrueif this algorithm has been initialized;falseotherwise.- Returns:
trueif this algorithm has been initialized;falseotherwise- 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 no-op or throwAlgorithmInitializationExceptionif 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- See Also:
-
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 overevaluatewhenever 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 theevaluatemethod was invoked. This is the primary measure of runtime for optimization algorithms.- Returns:
- the number of times the
evaluatemethod was invoked
-
isTerminated
boolean isTerminated()Returnstrueif this algorithm has reached its termination condition;falseotherwise.- Returns:
trueif this algorithm has reached its termination condition;falseotherwise- 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 step-by-step withstep().Implementations should always call
super.terminate()to ensure the algorithm is terminated correctly.
-