org.apache.commons.math3.optimization.general

## Class NonLinearConjugateGradientOptimizer.IdentityPreconditioner

- java.lang.Object
- - org.apache.commons.math3.optimization.general.NonLinearConjugateGradientOptimizer.IdentityPreconditioner

- All Implemented Interfaces:
    Preconditioner
  Enclosing class:
    NonLinearConjugateGradientOptimizer

      public static class NonLinearConjugateGradientOptimizer.IdentityPreconditioner
      extends Object
      implements Preconditioner

  Default identity preconditioner.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `NonLinearConjugateGradientOptimizer.IdentityPreconditioner()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double[]` | `precondition(double[] variables, double[] r)` Precondition a search direction.

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

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

- - ### Constructor Detail

    - #### NonLinearConjugateGradientOptimizer.IdentityPreconditioner

          public NonLinearConjugateGradientOptimizer.IdentityPreconditioner()

  - ### Method Detail

    - #### precondition

          public double[] precondition(double[] variables,
                              double[] r)

      Precondition a search direction.

      The returned preconditioned search direction must be computed fast or the algorithm performances will drop drastically. A classical approach is to compute only the diagonal elements of the hessian and to divide the raw search direction by these elements if they are all positive. If at least one of them is negative, it is safer to return a clone of the raw search direction as if the hessian was the identity matrix. The rationale for this simplified choice is that a negative diagonal element means the current point is far from the optimum and preconditioning will not be efficient anyway in this case.

      Specified by:
        `precondition` in interface `Preconditioner`
      Parameters:
        `variables` - current point at which the search direction was computed
        `r` - raw search direction (i.e. opposite of the gradient)
      Returns:
        approximation of H-1r where H is the objective function hessian

Copyright © 2003–2014 The Apache Software Foundation. All rights reserved.