Class BaseOptimizer<PAIR>

  • Type Parameters:
    PAIR - Type of the point/value pair returned by the optimization algorithm.
    Direct Known Subclasses:
    BaseMultivariateOptimizer, UnivariateOptimizer

    public abstract class BaseOptimizer<PAIR>
    extends Object
    Base class for implementing optimizers. It contains the boiler-plate code for counting the number of evaluations of the objective function and the number of iterations of the algorithm. It also stores a convergence checker, as well as default tolerances (how the checker and tolerances are used is determined by subclasses). It is not a "user" class.
    Since:
    3.1
    • Constructor Detail

      • BaseOptimizer

        protected BaseOptimizer​(ConvergenceChecker<PAIR> checker,
                                int maxEval,
                                int maxIter)
        Parameters:
        checker - Convergence checker.
        maxEval - Maximum number of objective function evaluations.
        maxIter - Maximum number of algorithm iterations.
    • Method Detail

      • getMaxEvaluations

        public int getMaxEvaluations()
        Gets the maximal number of function evaluations.
        Returns:
        the maximal number of function evaluations.
      • getEvaluations

        public int getEvaluations()
        Gets the number of evaluations of the objective function. The number of evaluations corresponds to the last call to the optimize method. It is 0 if the method has not been called yet.
        Returns:
        the number of evaluations of the objective function.
      • getMaxIterations

        public int getMaxIterations()
        Gets the maximal number of iterations.
        Returns:
        the maximal number of iterations.
      • getIterations

        public int getIterations()
        Gets the number of iterations performed by the algorithm. The number iterations corresponds to the last call to the optimize method. It is 0 if the method has not been called yet.
        Returns:
        the number of evaluations of the objective function.
      • optimize

        public PAIR optimize​(OptimizationData... optData)
        Stores data and performs the optimization.

        The list of parameters is open-ended so that sub-classes can extend it with arguments specific to their concrete implementations.

        When the method is called multiple times, instance data is overwritten only when actually present in the list of arguments: when not specified, data set in a previous call is retained (and thus is optional in subsequent calls).

        Important note: Subclasses must override parseOptimizationData(OptimizationData[]) if they need to register their own options; but then, they must also call super.parseOptimizationData(optData) within that method.

        Parameters:
        optData - Optimization data. This method will register the following data:
        Returns:
        a point/value pair that satisfies the convergence criteria.
        Throws:
        TooManyEvaluationsException - if the maximal number of evaluations is exceeded.
        TooManyIterationsException - if the maximal number of iterations is exceeded.
      • doOptimize

        protected abstract PAIR doOptimize()
        Performs the bulk of the optimization algorithm.
        Returns:
        the point/value pair giving the optimal value of the objective function.