## org.apache.commons.math3.optim
Class BaseOptimizer<PAIR>

    java.lang.Object
      org.apache.commons.math3.optim.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 java.lang.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, and storing the convergence checker. It is not a "user" class.

Since:
  3.1
Version:
  $Id$

Nested Class Summary
`private static class` `BaseOptimizer.MaxEvalCallback` Defines the action to perform when reaching the maximum number of evaluations.
`private static class` `BaseOptimizer.MaxIterCallback` Defines the action to perform when reaching the maximum number of evaluations.

Field Summary
`private ConvergenceChecker<PAIR>` `checker` Convergence checker.
`protected Incrementor` `evaluations` Evaluations counter.
`protected Incrementor` `iterations` Iterations counter.

Constructor Summary
`protected` `BaseOptimizer(ConvergenceChecker<PAIR> checker)`

Method Summary
`protected abstract PAIR` `doOptimize()` Performs the bulk of the optimization algorithm.
`ConvergenceChecker<PAIR>` `getConvergenceChecker()` Gets the convergence checker.
`int` `getEvaluations()` Gets the number of evaluations of the objective function.
`int` `getIterations()` Gets the number of iterations performed by the algorithm.
`int` `getMaxEvaluations()` Gets the maximal number of function evaluations.
`int` `getMaxIterations()` Gets the maximal number of iterations.
`protected void` `incrementEvaluationCount()` Increment the evaluation count.
`protected void` `incrementIterationCount()` Increment the iteration count.
`PAIR` `optimize(OptimizationData... optData)` Stores data and performs the optimization.
`private void` `parseOptimizationData(OptimizationData... optData)` Scans the list of (required and optional) optimization data that characterize the problem.

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.

### iterations

    protected final Incrementor iterations

  Iterations counter.

### checker

    private ConvergenceChecker<PAIR> checker

  Convergence checker.

Constructor Detail

### BaseOptimizer

    protected BaseOptimizer(ConvergenceChecker<PAIR> checker)

Parameters:
  `checker` - Convergence checker.

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.

### getConvergenceChecker

    public ConvergenceChecker<PAIR> getConvergenceChecker()

  Gets the convergence checker.

  Returns:
    the object used to check for convergence.

### optimize

    public PAIR optimize(OptimizationData... optData)
                  throws TooManyEvaluationsException,
                         TooManyIterationsException

  Stores data and performs the optimization.

  Parameters:
    `optData` - Optimization data. The following data will be looked for:
    - `MaxEval`
    - `MaxIter`
  Returns:
    a point/value pair that satifies 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.

### incrementEvaluationCount

    protected void incrementEvaluationCount()
                                     throws TooManyEvaluationsException

  Increment the evaluation count.

  Throws:
    `TooManyEvaluationsException` - if the allowed evaluations have been exhausted.

### incrementIterationCount

    protected void incrementIterationCount()
                                    throws TooManyIterationsException

  Increment the iteration count.

  Throws:
    `TooManyIterationsException` - if the allowed iterations have been exhausted.

### parseOptimizationData

    private void parseOptimizationData(OptimizationData... optData)

  Scans the list of (required and optional) optimization data that characterize the problem.

  Parameters:
    `optData` - Optimization data. The following data will be looked for:
    - `MaxEval`
    - `MaxIter`

Copyright (c) 2003-2013 Apache Software Foundation