public abstract class AbstractLeastSquaresOptimizer extends Object implements DifferentiableMultivariateVectorialOptimizer
This base class handles the boilerplate methods associated to thresholds settings, jacobian and error estimation.
Modifier and Type | Field and Description |
---|---|
protected VectorialConvergenceChecker |
checker
Convergence checker.
|
protected int |
cols
Number of columns of the jacobian matrix.
|
protected double |
cost
Cost value (square root of the sum of the residuals).
|
static int |
DEFAULT_MAX_ITERATIONS
Default maximal number of iterations allowed.
|
protected double[][] |
jacobian
Jacobian matrix.
|
protected double[] |
objective
Current objective function value.
|
protected double[] |
point
Current point.
|
protected double[] |
residuals
Current residuals.
|
protected double[] |
residualsWeights
Weight for the least squares cost computation.
|
protected int |
rows
Number of rows of the jacobian matrix.
|
protected double[] |
targetValues
Target value for the objective functions at optimum.
|
protected double[][] |
wjacobian
Weighted Jacobian
|
protected double[] |
wresiduals
Weighted residuals
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractLeastSquaresOptimizer()
Simple constructor with default settings.
|
Modifier and Type | Method and Description |
---|---|
protected abstract VectorialPointValuePair |
doOptimize()
Perform the bulk of optimization algorithm.
|
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.
|
VectorialConvergenceChecker |
getConvergenceChecker()
Get the convergence checker.
|
double[][] |
getCovariances()
Get the covariance matrix of optimized parameters.
|
int |
getEvaluations()
Get the number of evaluations of the objective function.
|
int |
getIterations()
Get the number of iterations realized by the algorithm.
|
int |
getJacobianEvaluations()
Get the number of evaluations of the objective function jacobian .
|
int |
getMaxEvaluations()
Get the maximal number of functions evaluations.
|
int |
getMaxIterations()
Get the maximal number of iterations of the algorithm.
|
double |
getRMS()
Get the Root Mean Square value.
|
double[] |
guessParametersErrors()
Guess the errors in optimized parameters.
|
protected void |
incrementIterationsCounter()
Increment the iterations counter by 1.
|
VectorialPointValuePair |
optimize(DifferentiableMultivariateVectorialFunction f,
double[] target,
double[] weights,
double[] startPoint)
Optimizes an objective function.
|
void |
setConvergenceChecker(VectorialConvergenceChecker convergenceChecker)
Set the convergence checker.
|
void |
setMaxEvaluations(int maxEvaluations)
Set the maximal number of functions evaluations.
|
void |
setMaxIterations(int maxIterations)
Set the maximal number of iterations of the algorithm.
|
protected void |
updateJacobian()
Update the jacobian matrix.
|
protected void |
updateResidualsAndCost()
Update the residuals array and cost function value.
|
public static final int DEFAULT_MAX_ITERATIONS
protected VectorialConvergenceChecker checker
protected double[][] jacobian
This matrix is in canonical form just after the calls to
updateJacobian()
, but may be modified by the solver
in the derived class (the Levenberg-Marquardt optimizer
does this).
protected int cols
protected int rows
protected double[] targetValues
protected double[] residualsWeights
protected double[] point
protected double[] objective
protected double[] residuals
protected double[][] wjacobian
protected double[] wresiduals
protected double cost
protected AbstractLeastSquaresOptimizer()
The convergence check is set to a SimpleVectorialValueChecker
and the maximal number of evaluation is set to its default value.
public void setMaxIterations(int maxIterations)
setMaxIterations
in interface DifferentiableMultivariateVectorialOptimizer
maxIterations
- maximal number of function calls
.public int getMaxIterations()
getMaxIterations
in interface DifferentiableMultivariateVectorialOptimizer
public int getIterations()
getIterations
in interface DifferentiableMultivariateVectorialOptimizer
public void setMaxEvaluations(int maxEvaluations)
setMaxEvaluations
in interface DifferentiableMultivariateVectorialOptimizer
maxEvaluations
- maximal number of function evaluationspublic int getMaxEvaluations()
getMaxEvaluations
in interface DifferentiableMultivariateVectorialOptimizer
public int getEvaluations()
The number of evaluation correspond to the last call to the
optimize
method. It is 0 if
the method has not been called yet.
getEvaluations
in interface DifferentiableMultivariateVectorialOptimizer
public int getJacobianEvaluations()
The number of evaluation correspond to the last call to the
optimize
method. It is 0 if
the method has not been called yet.
getJacobianEvaluations
in interface DifferentiableMultivariateVectorialOptimizer
public void setConvergenceChecker(VectorialConvergenceChecker convergenceChecker)
setConvergenceChecker
in interface DifferentiableMultivariateVectorialOptimizer
convergenceChecker
- object to use to check for convergencepublic VectorialConvergenceChecker getConvergenceChecker()
getConvergenceChecker
in interface DifferentiableMultivariateVectorialOptimizer
protected void incrementIterationsCounter() throws OptimizationException
OptimizationException
- if the maximal number
of iterations is exceededprotected void updateJacobian() throws FunctionEvaluationException
FunctionEvaluationException
- if the function jacobian
cannot be evaluated or its dimension doesn't match problem dimensionprotected void updateResidualsAndCost() throws FunctionEvaluationException
FunctionEvaluationException
- if the function cannot be evaluated
or its dimension doesn't match problem dimension or maximal number of
of evaluations is exceededpublic double getRMS()
public double getChiSquare()
public double[][] getCovariances() throws FunctionEvaluationException, OptimizationException
FunctionEvaluationException
- if the function jacobian cannot
be evaluatedOptimizationException
- if the covariance matrix
cannot be computed (singular problem)public double[] guessParametersErrors() throws FunctionEvaluationException, OptimizationException
Guessing is covariance-based, it only gives rough order of magnitude.
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)public VectorialPointValuePair optimize(DifferentiableMultivariateVectorialFunction f, double[] target, double[] weights, double[] startPoint) throws FunctionEvaluationException, OptimizationException, IllegalArgumentException
Optimization is considered to be a weighted least-squares minimization. The cost function to be minimized is ∑weighti(objectivei-targeti)2
optimize
in interface DifferentiableMultivariateVectorialOptimizer
f
- objective functiontarget
- target value for the objective functions at optimumweights
- weight for the least squares cost computationstartPoint
- the start point for optimizationFunctionEvaluationException
- if the objective function throws one during
the searchOptimizationException
- if the algorithm failed to convergeIllegalArgumentException
- if the start point dimension is wrongprotected abstract VectorialPointValuePair doOptimize() throws FunctionEvaluationException, OptimizationException, IllegalArgumentException
FunctionEvaluationException
- if the objective function throws one during
the searchOptimizationException
- if the algorithm failed to convergeIllegalArgumentException
- if the start point dimension is wrongCopyright © 2003–2015. All rights reserved.