Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.math.optimization.univariate
Class AbstractUnivariateRealOptimizer

    java.lang.Object
      org.apache.commons.math.ConvergingAlgorithmImpl
          org.apache.commons.math.optimization.univariate.AbstractUnivariateRealOptimizer

All Implemented Interfaces:
  ConvergingAlgorithm, UnivariateRealOptimizer

Direct Known Subclasses:
  BrentOptimizer

    public abstract class AbstractUnivariateRealOptimizer

extends ConvergingAlgorithmImpl
implements UnivariateRealOptimizer

Provide a default implementation for several functions useful to generic optimizers.

Since:
  2.0
Version:
  $Revision: 811685 $ $Date: 2009-09-05 13:36:48 -0400 (Sat, 05 Sep 2009) $

Field Summary
`private int` | `evaluations` Number of evaluations already performed.
`protected double` | `functionValue` Value of the function at the last computed result.
`private int` | `maxEvaluations` Maximal number of evaluations allowed.
`protected double` | `result` The last computed root.
`protected boolean` | `resultComputed` Indicates where a root has been computed.

Fields inherited from class org.apache.commons.math.ConvergingAlgorithmImpl
`absoluteAccuracy, defaultAbsoluteAccuracy, defaultMaximalIterationCount, defaultRelativeAccuracy, iterationCount, maximalIterationCount, relativeAccuracy`

Constructor Summary
`protected` | `AbstractUnivariateRealOptimizer(int defaultMaximalIterationCount, double defaultAbsoluteAccuracy)` Construct a solver with given iteration count and accuracy.

Method Summary
`protected void` | `checkResultComputed()` Check if a result has been computed.
`protected void` | `clearResult()` Convenience function for implementations.
`protected double` | `computeObjectiveValue(UnivariateRealFunction f, double point)` Compute the objective function value.
`int` | `getEvaluations()` Get the number of evaluations of the objective function.
`double` | `getFunctionValue()` Get the result of the last run of the optimizer.
`int` | `getMaxEvaluations()` Get the maximal number of functions evaluations.
`double` | `getResult()` Get the result of the last run of the optimizer.
`void` | `setMaxEvaluations(int maxEvaluations)` Set the maximal number of functions evaluations.
`protected void` | `setResult(double x, double fx, int iterationCount)` Convenience function for implementations.

Methods inherited from class org.apache.commons.math.ConvergingAlgorithmImpl
`getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, resetAbsoluteAccuracy, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setMaximalIterationCount, setRelativeAccuracy`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.apache.commons.math.optimization.UnivariateRealOptimizer
`optimize, optimize`

Methods inherited from interface org.apache.commons.math.ConvergingAlgorithm
`getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, resetAbsoluteAccuracy, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setMaximalIterationCount, setRelativeAccuracy`

Field Detail

### resultComputed

    protected boolean resultComputed

  Indicates where a root has been computed.

### result

    protected double result

  The last computed root.

### functionValue

    protected double functionValue

  Value of the function at the last computed result.

### maxEvaluations

    private int maxEvaluations

  Maximal number of evaluations allowed.

### evaluations

    private int evaluations

  Number of evaluations already performed.

Constructor Detail

### AbstractUnivariateRealOptimizer

    protected AbstractUnivariateRealOptimizer(int defaultMaximalIterationCount,
                                              double defaultAbsoluteAccuracy)

  Construct a solver with given iteration count and accuracy. FunctionEvaluationExceptionFunctionEvaluationException

  Parameters:
    `defaultAbsoluteAccuracy` - maximum absolute error
    `defaultMaximalIterationCount` - maximum number of iterations
  Throws:
    `java.lang.IllegalArgumentException` - if f is null or the defaultAbsoluteAccuracy is not valid

Method Detail

### checkResultComputed

    protected void checkResultComputed()
                                throws java.lang.IllegalStateException

  Check if a result has been computed.

  Throws:
    `java.lang.IllegalStateException` - if no result has been computed

### getResult

    public double getResult()

  Get the result of the last run of the optimizer.

  Specified by:
    `getResult` in interface `UnivariateRealOptimizer`
  Returns:
    the last result.

### getFunctionValue

    public double getFunctionValue()

  Get the result of the last run of the optimizer.

  Specified by:
    `getFunctionValue` in interface `UnivariateRealOptimizer`
  Returns:
    the value of the function at the last result.

### setResult

    protected final void setResult(double x,
                                   double fx,
                                   int iterationCount)

  Convenience function for implementations.

  Parameters:
    `x` - the result to set
    `fx` - the result to set
    `iterationCount` - the iteration count to set

### clearResult

    protected final void clearResult()

  Convenience function for implementations.

### setMaxEvaluations

    public void setMaxEvaluations(int maxEvaluations)

  Set the maximal number of functions evaluations.

  Specified by:
    `setMaxEvaluations` in interface `UnivariateRealOptimizer`
  Parameters:
    `maxEvaluations` - maximal number of function evaluations

### getMaxEvaluations

    public int getMaxEvaluations()

  Get the maximal number of functions evaluations.

  Specified by:
    `getMaxEvaluations` in interface `UnivariateRealOptimizer`
  Returns:
    maximal number of functions 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 `UnivariateRealOptimizer`
  Returns:
    number of evaluations of the objective function

### computeObjectiveValue

    protected double computeObjectiveValue(UnivariateRealFunction f,
                                           double point)
                                    throws FunctionEvaluationException

  Compute the objective function value.

  Parameters:
    `f` - objective function
    `point` - point at which the objective function must be evaluated
  Returns:
    objective function value at specified point
  Throws:
    `FunctionEvaluationException` - if the function cannot be evaluated or the maximal number of iterations is exceeded

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2003-2011 Apache Software Foundation