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

public interface Algorithm extends Stateful, Extensible
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 Type
    Method
    Description
    void
    evaluate(Solution solution)
    Evaluates the specified solution for the problem being solved by this algorithm.
    default void
    Evaluates the specified solutions.
    default void
    evaluateAll(Solution[] solutions)
    Evaluates the specified solutions.
    int
    Returns the number of times the evaluate method was invoked.
    Returns the problem being solved by this algorithm.
    Returns the current best-known result.
    void
    Performs any initialization that is required by this algorithm.
    boolean
    Returns true if this algorithm has been initialized; false otherwise.
    boolean
    Returns true 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
    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

    Methods inherited from interface org.moeaframework.core.Stateful

    loadState, saveState
  • Method Details

    • getProblem

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

      Returns the current best-known result.
      Returns:
      the current best-known result
    • isInitialized

      boolean isInitialized()
      Returns true 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 no-op or throw AlgorithmInitializationException 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 checking isTerminated() after each step to detect when termination conditions are reached. However, if the implementation is unable to continue, this method should throw AlgorithmTerminationException.

    • 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. Use getNumberOfEvaluations() to verify the actual number of evaluations.
      Parameters:
      evaluations - the number of function evaluations
    • run

      default void run(TerminationCondition terminationCondition)
      Executes this algorithm until the terminal condition signals it to stop.
      Parameters:
      terminationCondition - the termination condition
    • evaluateAll

      default void evaluateAll(Iterable<Solution> solutions)
      Evaluates the specified solutions. This method calls evaluate(Solution) on each of the solutions. Subclasses should prefer calling this method over evaluate whenever possible, as this ensures the solutions can be evaluated in parallel.
      Parameters:
      solutions - the solutions to evaluate
    • evaluateAll

      default void evaluateAll(Solution[] solutions)
      Evaluates the specified solutions. This method is equivalent to evaluateAll(Arrays.asList(solutions)).
      Parameters:
      solutions - the solutions to evaluate
    • evaluate

      void evaluate(Solution solution)
      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 the evaluate 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()
      Returns true 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 using run(TerminationCondition), but can also be invoked directly if executing the algorithm step-by-step with step().

      Implementations should always call super.terminate() to ensure the algorithm is terminated correctly.