Class NonLinearConjugateGradientOptimizer
java.lang.Object
org.apache.commons.math.optimization.general.AbstractScalarDifferentiableOptimizer
org.apache.commons.math.optimization.general.NonLinearConjugateGradientOptimizer
- All Implemented Interfaces:
DifferentiableMultivariateRealOptimizer
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
- Version:
- $Revision: 1070725 $ $Date: 2011-02-15 02:31:12 +0100 (mar. 15 févr. 2011) $
-
Field Summary
Fields inherited from class org.apache.commons.math.optimization.general.AbstractScalarDifferentiableOptimizer
checker, DEFAULT_MAX_ITERATIONS, goal, point -
Constructor Summary
ConstructorsConstructorDescriptionNonLinearConjugateGradientOptimizer(ConjugateGradientFormula updateFormula) Simple constructor with default settings. -
Method Summary
Modifier and TypeMethodDescriptionprotected RealPointValuePairPerform the bulk of optimization algorithm.voidsetInitialStep(double initialStep) Set the initial step used to bracket the optimum in line search.voidsetLineSearchSolver(UnivariateRealSolver lineSearchSolver) Set the solver to use during line search.voidsetPreconditioner(Preconditioner preconditioner) Set the preconditioner.Methods inherited from class org.apache.commons.math.optimization.general.AbstractScalarDifferentiableOptimizer
computeObjectiveGradient, computeObjectiveValue, getConvergenceChecker, getEvaluations, getGradientEvaluations, getIterations, getMaxEvaluations, getMaxIterations, incrementIterationsCounter, optimize, setConvergenceChecker, setMaxEvaluations, setMaxIterations
-
Constructor Details
-
NonLinearConjugateGradientOptimizer
Simple constructor with default settings.The convergence check is set to a
SimpleVectorialValueCheckerand the maximal number of iterations is set toAbstractScalarDifferentiableOptimizer.DEFAULT_MAX_ITERATIONS.- Parameters:
updateFormula- formula to use for updating the β parameter, must be one ofConjugateGradientFormula.FLETCHER_REEVESorConjugateGradientFormula.POLAK_RIBIERE
-
-
Method Details
-
setPreconditioner
Set the preconditioner.- Parameters:
preconditioner- preconditioner to use for next optimization, may be null to remove an already registered preconditioner
-
setLineSearchSolver
Set the solver to use during line search.- Parameters:
lineSearchSolver- solver to use during line search, may be null to remove an already registered solver and fall back to the defaultBrent solver.
-
setInitialStep
public void setInitialStep(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- 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
-
doOptimize
protected RealPointValuePair doOptimize() throws FunctionEvaluationException, OptimizationException, IllegalArgumentExceptionPerform the bulk of optimization algorithm.- Specified by:
doOptimizein classAbstractScalarDifferentiableOptimizer- Returns:
- the point/value pair giving the optimal value for objective function
- Throws:
FunctionEvaluationException- if the objective function throws one during the searchOptimizationException- if the algorithm failed to convergeIllegalArgumentException- if the start point dimension is wrong
-