org.apache.commons.math3.optimization.univariate

## Class BaseAbstractUnivariateOptimizer

- java.lang.Object
- - org.apache.commons.math3.optimization.univariate.BaseAbstractUnivariateOptimizer

- All Implemented Interfaces:
    BaseOptimizer<UnivariatePointValuePair>, BaseUnivariateOptimizer<UnivariateFunction>, UnivariateOptimizer
  Direct Known Subclasses:
    BrentOptimizer

      public abstract class BaseAbstractUnivariateOptimizer
      extends Object
      implements UnivariateOptimizer

  Provide a default implementation for several functions useful to generic optimizers.
  Since:
    2.0
  Version:
    $Id: BaseAbstractUnivariateOptimizer.java 1244787 2012-02-15 23:24:33Z erans $

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `BaseAbstractUnivariateOptimizer(ConvergenceChecker<UnivariatePointValuePair> checker)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected double` | `computeObjectiveValue(double point)` Compute the objective function value.
    `protected abstract UnivariatePointValuePair` | `doOptimize()` Method for implementing actual optimization algorithms in derived classes.
    `ConvergenceChecker<UnivariatePointValuePair>` | `getConvergenceChecker()` Get the convergence checker.
    `int` | `getEvaluations()` Get the number of evaluations of the objective function.
    `GoalType` | `getGoalType()`
    `double` | `getMax()`
    `int` | `getMaxEvaluations()` Get the maximal number of function evaluations.
    `double` | `getMin()`
    `double` | `getStartValue()`
    `UnivariatePointValuePair` | `optimize(int maxEval, UnivariateFunction f, GoalType goalType, double min, double max)` Find an optimum in the given interval.
    `UnivariatePointValuePair` | `optimize(int maxEval, UnivariateFunction f, GoalType goalType, double min, double max, double startValue)` Find an optimum in the given interval, start at startValue.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BaseAbstractUnivariateOptimizer

          protected BaseAbstractUnivariateOptimizer(ConvergenceChecker<UnivariatePointValuePair> checker)

      Parameters:
        `checker` - Convergence checking procedure.

  - ### Method Detail

    - #### getMaxEvaluations

          public int getMaxEvaluations()

      Get the maximal number of function evaluations.
      Specified by:
        `getMaxEvaluations` in interface `BaseOptimizer<UnivariatePointValuePair>`
      Returns:
        the maximal number of function evaluations.

    - #### getEvaluations

          public int getEvaluations()

      Get 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.
      Specified by:
        `getEvaluations` in interface `BaseOptimizer<UnivariatePointValuePair>`
      Returns:
        the number of evaluations of the objective function.

    - #### getGoalType

          public GoalType getGoalType()

      Returns:
        the optimization type.

    - #### getMin

          public double getMin()

      Returns:
        the lower end of the search interval.

    - #### getMax

          public double getMax()

      Returns:
        the higher end of the search interval.

    - #### getStartValue

          public double getStartValue()

      Returns:
        the initial guess.

    - #### computeObjectiveValue

          protected double computeObjectiveValue(double point)

      Compute the objective function value.
      Parameters:
        `point` - Point at which the objective function must be evaluated.
      Returns:
        the objective function value at specified point.
      Throws:
        `TooManyEvaluationsException` - if the maximal number of evaluations is exceeded.

    - #### optimize

          public UnivariatePointValuePair optimize(int maxEval,
                                          UnivariateFunction f,
                                          GoalType goalType,
                                          double min,
                                          double max,
                                          double startValue)

      Find an optimum in the given interval, start at startValue. An optimizer may require that the interval brackets a single optimum.
      Specified by:
        `optimize` in interface `BaseUnivariateOptimizer<UnivariateFunction>`
      Parameters:
        `maxEval` - Maximum number of function evaluations.
        `f` - Function to optimize.
        `goalType` - Type of optimization goal: either `GoalType.MAXIMIZE` or `GoalType.MINIMIZE`.
        `min` - Lower bound for the interval.
        `max` - Upper bound for the interval.
        `startValue` - Start value to use.
      Returns:
        a (point, value) pair where the function is optimum.

    - #### optimize

          public UnivariatePointValuePair optimize(int maxEval,
                                          UnivariateFunction f,
                                          GoalType goalType,
                                          double min,
                                          double max)

      Find an optimum in the given interval. An optimizer may require that the interval brackets a single optimum.
      Specified by:
        `optimize` in interface `BaseUnivariateOptimizer<UnivariateFunction>`
      Parameters:
        `maxEval` - Maximum number of function evaluations.
        `f` - Function to optimize.
        `goalType` - Type of optimization goal: either `GoalType.MAXIMIZE` or `GoalType.MINIMIZE`.
        `min` - Lower bound for the interval.
        `max` - Upper bound for the interval.
      Returns:
        a (point, value) pair where the function is optimum.

    - #### getConvergenceChecker

          public ConvergenceChecker<UnivariatePointValuePair> getConvergenceChecker()

      Get the convergence checker.
      Specified by:
        `getConvergenceChecker` in interface `BaseOptimizer<UnivariatePointValuePair>`
      Returns:
        the object used to check for convergence.

    - #### doOptimize

          protected abstract UnivariatePointValuePair doOptimize()

      Method for implementing actual optimization algorithms in derived classes.
      Returns:
        the optimum and its corresponding function value.
      Throws:
        `TooManyEvaluationsException` - if the maximal number of evaluations is exceeded.

Copyright © 2003-2012 The Apache Software Foundation. All Rights Reserved.