Class AbstractLeastSquaresOptimizer
- All Implemented Interfaces:
DifferentiableMultivariateVectorialOptimizer
- Direct Known Subclasses:
GaussNewtonOptimizer,LevenbergMarquardtOptimizer
This base class handles the boilerplate methods associated to thresholds settings, jacobian and error estimation.
- Since:
- 1.2
- Version:
- $Revision: 1073158 $ $Date: 2011-02-21 22:46:52 +0100 (lun. 21 févr. 2011) $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected VectorialConvergenceCheckerConvergence checker.protected intNumber of columns of the jacobian matrix.protected doubleCost value (square root of the sum of the residuals).static final intDefault maximal number of iterations allowed.protected double[][]Jacobian matrix.protected double[]Current objective function value.protected double[]Current point.protected double[]Current residuals.protected double[]Weight for the least squares cost computation.protected intNumber of rows of the jacobian matrix.protected double[]Target value for the objective functions at optimum.protected double[][]Weighted Jacobianprotected double[]Weighted residuals -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSimple constructor with default settings. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract VectorialPointValuePairPerform the bulk of optimization algorithm.doubleGet a Chi-Square-like value assuming the N residuals follow N distinct normal distributions centered on 0 and whose variances are the reciprocal of the weights.Get the convergence checker.double[][]Get the covariance matrix of optimized parameters.intGet the number of evaluations of the objective function.intGet the number of iterations realized by the algorithm.intGet the number of evaluations of the objective function jacobian .intGet the maximal number of functions evaluations.intGet the maximal number of iterations of the algorithm.doublegetRMS()Get the Root Mean Square value.double[]Guess the errors in optimized parameters.protected voidIncrement the iterations counter by 1.optimize(DifferentiableMultivariateVectorialFunction f, double[] target, double[] weights, double[] startPoint) Optimizes an objective function.voidsetConvergenceChecker(VectorialConvergenceChecker convergenceChecker) Set the convergence checker.voidsetMaxEvaluations(int maxEvaluations) Set the maximal number of functions evaluations.voidsetMaxIterations(int maxIterations) Set the maximal number of iterations of the algorithm.protected voidUpdate the jacobian matrix.protected voidUpdate the residuals array and cost function value.
-
Field Details
-
DEFAULT_MAX_ITERATIONS
public static final int DEFAULT_MAX_ITERATIONSDefault maximal number of iterations allowed.- See Also:
-
checker
Convergence checker. -
jacobian
protected double[][] jacobianJacobian matrix.This matrix is in canonical form just after the calls to
updateJacobian(), but may be modified by the solver in the derived class (theLevenberg-Marquardt optimizerdoes this). -
cols
protected int colsNumber of columns of the jacobian matrix. -
rows
protected int rowsNumber of rows of the jacobian matrix. -
targetValues
protected double[] targetValuesTarget value for the objective functions at optimum.- Since:
- 2.1
-
residualsWeights
protected double[] residualsWeightsWeight for the least squares cost computation.- Since:
- 2.1
-
point
protected double[] pointCurrent point. -
objective
protected double[] objectiveCurrent objective function value. -
residuals
protected double[] residualsCurrent residuals. -
wjacobian
protected double[][] wjacobianWeighted Jacobian -
wresiduals
protected double[] wresidualsWeighted residuals -
cost
protected double costCost value (square root of the sum of the residuals).
-
-
Constructor Details
-
AbstractLeastSquaresOptimizer
protected AbstractLeastSquaresOptimizer()Simple constructor with default settings.The convergence check is set to a
SimpleVectorialValueCheckerand the maximal number of evaluation is set to its default value.
-
-
Method Details
-
setMaxIterations
public void setMaxIterations(int maxIterations) Set the maximal number of iterations of the algorithm.- Specified by:
setMaxIterationsin interfaceDifferentiableMultivariateVectorialOptimizer- Parameters:
maxIterations- maximal number of function calls .
-
getMaxIterations
public int getMaxIterations()Get the maximal number of iterations of the algorithm.- Specified by:
getMaxIterationsin interfaceDifferentiableMultivariateVectorialOptimizer- Returns:
- maximal number of iterations
-
getIterations
public int getIterations()Get the number of iterations realized by the algorithm.- Specified by:
getIterationsin interfaceDifferentiableMultivariateVectorialOptimizer- Returns:
- number of iterations
-
setMaxEvaluations
public void setMaxEvaluations(int maxEvaluations) Set the maximal number of functions evaluations.- Specified by:
setMaxEvaluationsin interfaceDifferentiableMultivariateVectorialOptimizer- Parameters:
maxEvaluations- maximal number of function evaluations
-
getMaxEvaluations
public int getMaxEvaluations()Get the maximal number of functions evaluations.- Specified by:
getMaxEvaluationsin interfaceDifferentiableMultivariateVectorialOptimizer- Returns:
- maximal number of functions evaluations
-
getEvaluations
public int getEvaluations()Get the number of evaluations of the objective function.The number of evaluation correspond to the last call to the
optimizemethod. It is 0 if the method has not been called yet.- Specified by:
getEvaluationsin interfaceDifferentiableMultivariateVectorialOptimizer- Returns:
- number of evaluations of the objective function
-
getJacobianEvaluations
public int getJacobianEvaluations()Get the number of evaluations of the objective function jacobian .The number of evaluation correspond to the last call to the
optimizemethod. It is 0 if the method has not been called yet.- Specified by:
getJacobianEvaluationsin interfaceDifferentiableMultivariateVectorialOptimizer- Returns:
- number of evaluations of the objective function jacobian
-
setConvergenceChecker
Set the convergence checker.- Specified by:
setConvergenceCheckerin interfaceDifferentiableMultivariateVectorialOptimizer- Parameters:
convergenceChecker- object to use to check for convergence
-
getConvergenceChecker
Get the convergence checker.- Specified by:
getConvergenceCheckerin interfaceDifferentiableMultivariateVectorialOptimizer- Returns:
- object used to check for convergence
-
incrementIterationsCounter
Increment the iterations counter by 1.- Throws:
OptimizationException- if the maximal number of iterations is exceeded
-
updateJacobian
Update the jacobian matrix.- Throws:
FunctionEvaluationException- if the function jacobian cannot be evaluated or its dimension doesn't match problem dimension
-
updateResidualsAndCost
Update the residuals array and cost function value.- Throws:
FunctionEvaluationException- if the function cannot be evaluated or its dimension doesn't match problem dimension or maximal number of of evaluations is exceeded
-
getRMS
public double getRMS()Get the Root Mean Square value. Get the Root Mean Square value, i.e. the root of the arithmetic mean of the square of all weighted residuals. This is related to the criterion that is minimized by the optimizer as follows: if c if the criterion, and n is the number of measurements, then the RMS is sqrt (c/n).- Returns:
- RMS value
-
getChiSquare
public double getChiSquare()Get a Chi-Square-like value assuming the N residuals follow N distinct normal distributions centered on 0 and whose variances are the reciprocal of the weights.- Returns:
- chi-square value
-
getCovariances
Get the covariance matrix of optimized parameters.- Returns:
- covariance matrix
- Throws:
FunctionEvaluationException- if the function jacobian cannot be evaluatedOptimizationException- if the covariance matrix cannot be computed (singular problem)
-
guessParametersErrors
Guess the errors in optimized parameters.Guessing is covariance-based, it only gives rough order of magnitude.
- Returns:
- errors in optimized parameters
- Throws:
FunctionEvaluationException- if the function jacobian cannot b evaluatedOptimizationException- if the covariances matrix cannot be computed or the number of degrees of freedom is not positive (number of measurements lesser or equal to number of parameters)
-
optimize
public VectorialPointValuePair optimize(DifferentiableMultivariateVectorialFunction f, double[] target, double[] weights, double[] startPoint) throws FunctionEvaluationException, OptimizationException, IllegalArgumentException Optimizes an objective function.Optimization is considered to be a weighted least-squares minimization. The cost function to be minimized is ∑weighti(objectivei-targeti)2
- Specified by:
optimizein interfaceDifferentiableMultivariateVectorialOptimizer- Parameters:
f- objective functiontarget- target value for the objective functions at optimumweights- weight for the least squares cost computationstartPoint- the start point for optimization- 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
-
doOptimize
protected abstract VectorialPointValuePair doOptimize() throws FunctionEvaluationException, OptimizationException, IllegalArgumentExceptionPerform the bulk of optimization algorithm.- 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
-