Top Description Inners Fields Constructors Methods
org.apache.commons.math3.optimization.general

public Class NonLinearConjugateGradientOptimizer

extends AbstractScalarDifferentiableOptimizer
Class Inheritance
Annotations
@Deprecated
Imports
org.apache.commons.math3.exception.MathIllegalStateException, org.apache.commons.math3.analysis.UnivariateFunction, org.apache.commons.math3.analysis.solvers.BrentSolver, .UnivariateSolver, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.optimization.GoalType, .PointValuePair, .SimpleValueChecker, .ConvergenceChecker, org.apache.commons.math3.util.FastMath

Deprecated

As of 3.1 (to be removed in 4.0).

Non-linear conjugate gradient optimizer.

This class supports both the Fletcher-Reeves and the Polak-Ribière update formulas for the conjugate search directions. It also supports optional preconditioning.

Since
2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
NonLinearConjugateGradientOptimizer.IdentityPreconditioner

Deprecated as a consequence of Preconditioner being deprecated.
Default identity preconditioner.
private class

Field Summary

Modifier and TypeField and Description
private double
initialStep

Initial step used to bracket the optimum in line search.

private double[]
point

Current point.

private final Preconditioner
preconditioner

Deprecated as a consequence of Preconditioner being deprecated.
Preconditioner (may be null).
private final UnivariateSolver
solver

solver to use in the line search (may be null).

private final ConjugateGradientFormula
updateFormula

Deprecated as a consequence of ConjugateGradientFormula being deprecated.
Update formula for the beta parameter.

Constructor Summary

AccessConstructor and Description
public
public
NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula
formula to use for updating the β parameter, must be one of ConjugateGradientFormula#FLETCHER_REEVES or ConjugateGradientFormula#POLAK_RIBIERE.
updateFormula
,
ConvergenceChecker<PointValuePair>
Convergence checker.
checker
)
Deprecated as a consequence of ConjugateGradientFormula and ConvergenceChecker being deprecated.

Constructor with default line search solver and preconditioner.

public
NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula
formula to use for updating the β parameter, must be one of ConjugateGradientFormula#FLETCHER_REEVES or ConjugateGradientFormula#POLAK_RIBIERE.
updateFormula
,
ConvergenceChecker<PointValuePair>
Convergence checker.
checker
,
final UnivariateSolver
Solver to use during line search.
lineSearchSolver
)
Deprecated as a consequence of ConjugateGradientFormula and ConvergenceChecker being deprecated.

Constructor with default preconditioner.

public
NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula
formula to use for updating the β parameter, must be one of ConjugateGradientFormula#FLETCHER_REEVES or ConjugateGradientFormula#POLAK_RIBIERE.
updateFormula
,
ConvergenceChecker<PointValuePair>
Convergence checker.
checker
,
final UnivariateSolver
Solver to use during line search.
lineSearchSolver
,
final Preconditioner
Preconditioner.
preconditioner
)
Deprecated as a consequence of ConjugateGradientFormula, ConvergenceChecker and Preconditioner being deprecated.

Method Summary

Modifier and TypeMethod and Description
protected PointValuePair
doOptimize()

Implements abstract org.apache.commons.math3.optimization.direct.BaseAbstractMultivariateOptimizer.doOptimize.

Deprecated as a consequence of PointValuePair being deprecated.

Perform the bulk of the optimization algorithm.

private double

Returns:

b such that f(a) and f(b) have opposite signs.
findUpperBound
(final UnivariateFunction
function whose root must be bracketed.
f
,
final double
lower bound of the interval.
a
,
final double
initial step to try.
h
)

Find the upper bound b ensuring bracketing of a root between a and b.

public void
setInitialStep(final double
initial step used to bracket the optimum in line search, if a non-positive value is used, the initial step is reset to its default value of 1.0
initialStep
)

Set the initial step used to bracket the optimum in line search.

Inherited from org.apache.commons.math3.optimization.general.AbstractScalarDifferentiableOptimizer:
computeObjectiveGradientoptimizeoptimizeInternal

Field Detail

initialStepback to summary
private double initialStep

Initial step used to bracket the optimum in line search.

pointback to summary
private double[] point

Current point.

preconditionerback to summary
private final Preconditioner preconditioner

Deprecated

as a consequence of Preconditioner being deprecated. See corresponding docs for further information.

Preconditioner (may be null).

solverback to summary
private final UnivariateSolver solver

solver to use in the line search (may be null).

updateFormulaback to summary
private final ConjugateGradientFormula updateFormula

Deprecated

as a consequence of ConjugateGradientFormula being deprecated. See corresponding docs for further information.

Update formula for the beta parameter.

Constructor Detail

NonLinearConjugateGradientOptimizerback to summary
public NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula updateFormula)

Constructor with default checker, line search solver and preconditioner.

Parameters
updateFormula:ConjugateGradientFormula

formula to use for updating the β parameter, must be one of ConjugateGradientFormula#FLETCHER_REEVES or ConjugateGradientFormula#POLAK_RIBIERE.

Annotations
@Deprecated
NonLinearConjugateGradientOptimizerback to summary
public NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula updateFormula, ConvergenceChecker<PointValuePair> checker)

Deprecated

as a consequence of ConjugateGradientFormula and ConvergenceChecker being deprecated. See corresponding docs for further information.

Constructor with default line search solver and preconditioner.

Parameters
updateFormula:ConjugateGradientFormula

formula to use for updating the β parameter, must be one of ConjugateGradientFormula#FLETCHER_REEVES or ConjugateGradientFormula#POLAK_RIBIERE.

checker:ConvergenceChecker<PointValuePair>

Convergence checker.

NonLinearConjugateGradientOptimizerback to summary
public NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula updateFormula, ConvergenceChecker<PointValuePair> checker, final UnivariateSolver lineSearchSolver)

Deprecated

as a consequence of ConjugateGradientFormula and ConvergenceChecker being deprecated. See corresponding docs for further information.

Constructor with default preconditioner.

Parameters
updateFormula:ConjugateGradientFormula

formula to use for updating the β parameter, must be one of ConjugateGradientFormula#FLETCHER_REEVES or ConjugateGradientFormula#POLAK_RIBIERE.

checker:ConvergenceChecker<PointValuePair>

Convergence checker.

lineSearchSolver:UnivariateSolver

Solver to use during line search.

NonLinearConjugateGradientOptimizerback to summary
public NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula updateFormula, ConvergenceChecker<PointValuePair> checker, final UnivariateSolver lineSearchSolver, final Preconditioner preconditioner)

Deprecated

as a consequence of ConjugateGradientFormula, ConvergenceChecker and Preconditioner being deprecated. See corresponding docs for further information.

Parameters
updateFormula:ConjugateGradientFormula

formula to use for updating the β parameter, must be one of ConjugateGradientFormula#FLETCHER_REEVES or ConjugateGradientFormula#POLAK_RIBIERE.

checker:ConvergenceChecker<PointValuePair>

Convergence checker.

lineSearchSolver:UnivariateSolver

Solver to use during line search.

preconditioner:Preconditioner

Preconditioner.

Method Detail

doOptimizeback to summary
protected PointValuePair doOptimize()

Implements abstract org.apache.commons.math3.optimization.direct.BaseAbstractMultivariateOptimizer.doOptimize.

Doc from org.apache.commons.math3.optimization.direct.BaseAbstractMultivariateOptimizer.doOptimize.

Deprecated

as a consequence of PointValuePair being deprecated. See corresponding docs for further information.

Perform the bulk of the optimization algorithm.

Returns:PointValuePair

the point/value pair giving the optimal value of the objective function.

Annotations
@Override
findUpperBoundback to summary
private double findUpperBound(final UnivariateFunction f, final double a, final double h)

Find the upper bound b ensuring bracketing of a root between a and b.

Parameters
f:UnivariateFunction

function whose root must be bracketed.

a:double

lower bound of the interval.

h:double

initial step to try.

Returns:double

b such that f(a) and f(b) have opposite signs.

Exceptions
MathIllegalStateException:
if no bracket can be found.
setInitialStepback to summary
public void setInitialStep(final double initialStep)

Set the initial step used to bracket the optimum in line search.

The initial step is a factor with respect to the search direction, which itself is roughly related to the gradient of the function

Parameters
initialStep:double

initial step used to bracket the optimum in line search, if a non-positive value is used, the initial step is reset to its default value of 1.0

org.apache.commons.math3.optimization.general back to summary

public Class NonLinearConjugateGradientOptimizer.IdentityPreconditioner

extends Object
implements Preconditioner
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.optimization.general.NonLinearConjugateGradientOptimizer.IdentityPreconditioner
All Implemented Interfaces
org.apache.commons.math3.optimization.general.Preconditioner

Deprecated

as a consequence of Preconditioner being deprecated. See corresponding docs for further information.

Default identity preconditioner.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public double[]
precondition(double[]
current point at which the search direction was computed
variables
,
double[]
raw search direction (i.e. opposite of the gradient)
r
)

Implements org.apache.commons.math3.optimization.general.Preconditioner.precondition.

Precondition a search direction.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

IdentityPreconditionerback to summary
public IdentityPreconditioner()

Method Detail

preconditionback to summary
public double[] precondition(double[] variables, double[] r)

Implements org.apache.commons.math3.optimization.general.Preconditioner.precondition.

Doc from org.apache.commons.math3.optimization.general.Preconditioner.precondition.

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.

Parameters
variables:double[]

current point at which the search direction was computed

r:double[]

raw search direction (i.e. opposite of the gradient)

Returns:double[]

approximation of H-1r where H is the objective function hessian

org.apache.commons.math3.optimization.general back to summary

private Class NonLinearConjugateGradientOptimizer.LineSearchFunction

extends Object
implements UnivariateFunction
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.optimization.general.NonLinearConjugateGradientOptimizer.LineSearchFunction
All Implemented Interfaces
org.apache.commons.math3.analysis.UnivariateFunction

Internal class for line search.

The function represented by this class is the dot product of the objective function gradient and the search direction. Its value is zero when the gradient is orthogonal to the search direction, i.e. when the objective function value is a local extremum along the search direction.

Field Summary

Modifier and TypeField and Description
private final double[]
searchDirection

Search direction.

Constructor Summary

AccessConstructor and Description
pack-priv
LineSearchFunction(final double[]
search direction
searchDirection
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public double
value(double
Point at which the function value should be computed.
x
)

Implements org.apache.commons.math3.analysis.UnivariateFunction.value.

Compute the value of the function.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

searchDirectionback to summary
private final double[] searchDirection

Search direction.

Constructor Detail

LineSearchFunctionback to summary
pack-priv LineSearchFunction(final double[] searchDirection)

Simple constructor.

Parameters
searchDirection:double[]

search direction

Method Detail

valueback to summary
public double value(double x)

Implements org.apache.commons.math3.analysis.UnivariateFunction.value.

Doc from org.apache.commons.math3.analysis.UnivariateFunction.value.

Compute the value of the function.

Parameters
x:double

Point at which the function value should be computed.

Returns:double

the value of the function.