|
|||||||||
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. |
private DifferentiableMultivariateVectorialFunction |
f
Objective function. |
private int |
iterations
Number of iterations already performed. |
protected double[][] |
jacobian
Jacobian matrix. |
private int |
jacobianEvaluations
Number of jacobian evaluations. |
private MultivariateMatrixFunction |
jF
Objective function derivatives. |
private int |
maxEvaluations
Maximal number of evaluations allowed. |
private int |
maxIterations
Maximal number of iterations allowed. |
protected double[] |
objective
Current objective function value. |
private int |
objectiveEvaluations
Number of evaluations already performed. |
protected double[] |
point
Current point. |
protected double[] |
residuals
Current residuals. |
protected int |
rows
Number of rows of the jacobian matrix. |
protected double[] |
target
Target value for the objective functions at optimum. |
protected double[] |
weights
Weight for the least squares cost computation. |
Constructor Summary | |
---|---|
protected |
AbstractLeastSquaresOptimizer()
Simple constructor with default settings. |
Method Summary | |
---|---|
protected abstract VectorialPointValuePair |
doOptimize()
Perform the bulk of optimization algorithm. |
double |
getChiSquare()
Get the Chi-Square value. |
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 checker)
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
private int maxIterations
private int iterations
private int maxEvaluations
private int objectiveEvaluations
private int jacobianEvaluations
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
private DifferentiableMultivariateVectorialFunction f
private MultivariateMatrixFunction jF
protected double[] target
protected double[] weights
protected double[] point
protected double[] objective
protected double[] residuals
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 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 checker)
setConvergenceChecker
in interface DifferentiableMultivariateVectorialOptimizer
checker
- 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 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 DifferentiableMultivariateVectorialOptimizer
f
- 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 wrongprotected 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 |