org.apache.commons.math3.optimization.direct

## Class BaseAbstractMultivariateOptimizer<FUNC extends MultivariateFunction>

- java.lang.Object
- - org.apache.commons.math3.optimization.direct.BaseAbstractMultivariateOptimizer<FUNC>

- Type Parameters:
    `FUNC` - Type of the objective function to be optimized.
  All Implemented Interfaces:
    BaseMultivariateOptimizer<FUNC>, BaseOptimizer<PointValuePair>
  Direct Known Subclasses:
    AbstractScalarDifferentiableOptimizer, BaseAbstractMultivariateSimpleBoundsOptimizer, PowellOptimizer, SimplexOptimizer

      public abstract class BaseAbstractMultivariateOptimizer<FUNC extends MultivariateFunction>
      extends Object
      implements BaseMultivariateOptimizer<FUNC>

  Base class for implementing optimizers for multivariate scalar functions. This base class handles the boiler-plate methods associated to thresholds settings, iterations and evaluations counting.
  Since:
    2.2
  Version:
    $Id$

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Incrementor` | `evaluations` Evaluations counter.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `BaseAbstractMultivariateOptimizer()` Simple constructor with default settings.
    `protected` | `BaseAbstractMultivariateOptimizer(ConvergenceChecker<PointValuePair> checker)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected double` | `computeObjectiveValue(double[] point)` Compute the objective function value.
    `protected abstract PointValuePair` | `doOptimize()` Perform the bulk of the optimization algorithm.
    `ConvergenceChecker<PointValuePair>` | `getConvergenceChecker()` Get the convergence checker.
    `int` | `getEvaluations()` Get the number of evaluations of the objective function.
    `GoalType` | `getGoalType()`
    `int` | `getMaxEvaluations()` Get the maximal number of function evaluations.
    `double[]` | `getStartPoint()`
    `PointValuePair` | `optimize(int maxEval, FUNC f, GoalType goalType, double[] startPoint)` Optimize an objective function.

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

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

- - ### Field Detail

    - #### evaluations

          protected final Incrementor evaluations

      Evaluations counter.

  - ### Constructor Detail

    - #### BaseAbstractMultivariateOptimizer

          protected BaseAbstractMultivariateOptimizer()

      Simple constructor with default settings. The convergence check is set to a `SimpleValueChecker` and the allowed number of evaluations is set to `Integer.MAX_VALUE`.

    - #### BaseAbstractMultivariateOptimizer

          protected BaseAbstractMultivariateOptimizer(ConvergenceChecker<PointValuePair> checker)

      Parameters:
        `checker` - Convergence checker.

  - ### Method Detail

    - #### getMaxEvaluations

          public int getMaxEvaluations()

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

    - #### getConvergenceChecker

          public ConvergenceChecker<PointValuePair> getConvergenceChecker()

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

    - #### 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 the specified point.
      Throws:
        `TooManyEvaluationsException` - if the maximal number of evaluations is exceeded.

    - #### optimize

          public PointValuePair optimize(int maxEval,
                                FUNC f,
                                GoalType goalType,
                                double[] startPoint)

      Optimize an objective function.
      Specified by:
        `optimize` in interface `BaseMultivariateOptimizer<FUNC extends MultivariateFunction>`
      Parameters:
        `maxEval` - Maximum number of function evaluations.
        `f` - Objective function.
        `goalType` - Type of optimization goal: either `GoalType.MAXIMIZE` or `GoalType.MINIMIZE`.
        `startPoint` - Start point for optimization.
      Returns:
        the point/value pair giving the optimal value for objective function.

    - #### getGoalType

          public GoalType getGoalType()

      Returns:
        the optimization type.

    - #### getStartPoint

          public double[] getStartPoint()

      Returns:
        the initial guess.

    - #### doOptimize

          protected abstract PointValuePair doOptimize()

      Perform the bulk of the optimization algorithm.
      Returns:
        the point/value pair giving the optimal value for the objective function.

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