|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.math.optimization.general.AbstractLeastSquaresOptimizer
public abstract class AbstractLeastSquaresOptimizer
Base class for implementing least squares optimizers.
This base class handles the boilerplate methods associated to thresholds settings, jacobian and error estimation.
| Field Summary | |
|---|---|
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 |
| Constructor Summary | |
|---|---|
protected |
AbstractLeastSquaresOptimizer()
Simple constructor with default settings. |
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
protected AbstractLeastSquaresOptimizer()
The convergence check is set to a SimpleVectorialValueChecker
and the maximal number of evaluation is set to its default value.
| Method Detail |
|---|
public void setMaxIterations(int maxIterations)
setMaxIterations in interface DifferentiableMultivariateVectorialOptimizermaxIterations - maximal number of function calls
.public int getMaxIterations()
getMaxIterations in interface DifferentiableMultivariateVectorialOptimizerpublic int getIterations()
getIterations in interface DifferentiableMultivariateVectorialOptimizerpublic void setMaxEvaluations(int maxEvaluations)
setMaxEvaluations in interface DifferentiableMultivariateVectorialOptimizermaxEvaluations - maximal number of function evaluationspublic int getMaxEvaluations()
getMaxEvaluations in interface DifferentiableMultivariateVectorialOptimizerpublic 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 DifferentiableMultivariateVectorialOptimizerpublic 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 DifferentiableMultivariateVectorialOptimizerpublic void setConvergenceChecker(VectorialConvergenceChecker convergenceChecker)
setConvergenceChecker in interface DifferentiableMultivariateVectorialOptimizerconvergenceChecker - 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 exceeded
protected void updateJacobian()
throws FunctionEvaluationException
FunctionEvaluationException - if the function jacobian
cannot be evaluated or its dimension doesn't match problem dimension
protected 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 evaluated
OptimizationException - 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 evaluated
OptimizationException - 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 DifferentiableMultivariateVectorialOptimizerf - objective functiontarget - target value for the objective functions at optimumweights - weight for the least squares cost computationstartPoint - the start point for optimization
FunctionEvaluationException - if the objective function throws one during
the search
OptimizationException - if the algorithm failed to converge
IllegalArgumentException - if the start point dimension is wrong
protected abstract VectorialPointValuePair doOptimize()
throws FunctionEvaluationException,
OptimizationException,
IllegalArgumentException
FunctionEvaluationException - if the objective function throws one during
the search
OptimizationException - if the algorithm failed to converge
IllegalArgumentException - if the start point dimension is wrong
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||