Class SequentialGaussNewtonOptimizer
- java.lang.Object
-
- org.hipparchus.optim.nonlinear.vector.leastsquares.SequentialGaussNewtonOptimizer
-
- All Implemented Interfaces:
LeastSquaresOptimizer
public class SequentialGaussNewtonOptimizer extends Object implements LeastSquaresOptimizer
Sequential Gauss-Newton least-squares solver.This class solve a least-square problem by solving the normal equations of the linearized problem at each iteration.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hipparchus.optim.nonlinear.vector.leastsquares.LeastSquaresOptimizer
LeastSquaresOptimizer.Optimum
-
-
Constructor Summary
Constructors Constructor Description SequentialGaussNewtonOptimizer()
Create a sequential Gauss Newton optimizer.SequentialGaussNewtonOptimizer(MatrixDecomposer decomposer, boolean formNormalEquations, LeastSquaresProblem.Evaluation evaluation)
Create a sequential Gauss Newton optimizer that uses the given matrix decomposition algorithm to solve the normal equations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MatrixDecomposer
getDecomposer()
Get the matrix decomposition algorithm.LeastSquaresProblem.Evaluation
getOldEvaluation()
Get the previous evaluation used by the optimizer.boolean
isFormNormalEquations()
Get if the normal equations are explicitly formed.LeastSquaresOptimizer.Optimum
optimize(LeastSquaresProblem lsp)
Solve the non-linear least squares problem.String
toString()
SequentialGaussNewtonOptimizer
withAPrioriData(RealVector aPrioriState, RealMatrix aPrioriCovariance)
Configure from a priori state and covariance.SequentialGaussNewtonOptimizer
withAPrioriData(RealVector aPrioriState, RealMatrix aPrioriCovariance, double relativeSymmetryThreshold, double absolutePositivityThreshold)
Configure from a priori state and covariance.SequentialGaussNewtonOptimizer
withDecomposer(MatrixDecomposer newDecomposer)
Configure the matrix decomposition algorithm.SequentialGaussNewtonOptimizer
withEvaluation(LeastSquaresProblem.Evaluation previousEvaluation)
Configure the previous evaluation used by the optimizer.SequentialGaussNewtonOptimizer
withFormNormalEquations(boolean newFormNormalEquations)
Configure if the normal equations should be explicitly formed.
-
-
-
Constructor Detail
-
SequentialGaussNewtonOptimizer
public SequentialGaussNewtonOptimizer()
Create a sequential Gauss Newton optimizer.The default for the algorithm is to use QR decomposition, not form normal equations and have no previous evaluation
-
SequentialGaussNewtonOptimizer
public SequentialGaussNewtonOptimizer(MatrixDecomposer decomposer, boolean formNormalEquations, LeastSquaresProblem.Evaluation evaluation)
Create a sequential Gauss Newton optimizer that uses the given matrix decomposition algorithm to solve the normal equations.The
decomposer
is used to solve JTJx=JTr.- Parameters:
decomposer
- the decomposition algorithm to use.formNormalEquations
- whether the normal equations should be explicitly formed. Iftrue
thendecomposer
is used to solve JTJx=JTr, otherwisedecomposer
is used to solve Jx=r. Ifdecomposer
can only solve square systems then this parameter should betrue
.evaluation
- old evaluation previously computed, null if there are no previous evaluations.
-
-
Method Detail
-
getDecomposer
public MatrixDecomposer getDecomposer()
Get the matrix decomposition algorithm.- Returns:
- the decomposition algorithm.
-
withDecomposer
public SequentialGaussNewtonOptimizer withDecomposer(MatrixDecomposer newDecomposer)
Configure the matrix decomposition algorithm.- Parameters:
newDecomposer
- the decomposition algorithm to use.- Returns:
- a new instance.
-
isFormNormalEquations
public boolean isFormNormalEquations()
Get if the normal equations are explicitly formed.- Returns:
- if the normal equations should be explicitly formed. If
true
thendecomposer
is used to solve JTJx=JTr, otherwisedecomposer
is used to solve Jx=r.
-
withFormNormalEquations
public SequentialGaussNewtonOptimizer withFormNormalEquations(boolean newFormNormalEquations)
Configure if the normal equations should be explicitly formed.- Parameters:
newFormNormalEquations
- whether the normal equations should be explicitly formed. Iftrue
thendecomposer
is used to solve JTJx=JTr, otherwisedecomposer
is used to solve Jx=r. Ifdecomposer
can only solve square systems then this parameter should betrue
.- Returns:
- a new instance.
-
getOldEvaluation
public LeastSquaresProblem.Evaluation getOldEvaluation()
Get the previous evaluation used by the optimizer.- Returns:
- the previous evaluation.
-
withEvaluation
public SequentialGaussNewtonOptimizer withEvaluation(LeastSquaresProblem.Evaluation previousEvaluation)
Configure the previous evaluation used by the optimizer.This building method uses a complete evaluation to retrieve a priori data. Note that as
withAPrioriData(RealVector, RealMatrix)
generates a fake evaluation and calls this method, eitherwithAPrioriData(RealVector, RealMatrix)
orwithEvaluation(LeastSquaresProblem.Evaluation)
should be called, but not both as the last one called will override the previous one.- Parameters:
previousEvaluation
- the previous evaluation used by the optimizer.- Returns:
- a new instance.
-
withAPrioriData
public SequentialGaussNewtonOptimizer withAPrioriData(RealVector aPrioriState, RealMatrix aPrioriCovariance)
Configure from a priori state and covariance.This building method generates a fake evaluation and calls
withEvaluation(LeastSquaresProblem.Evaluation)
, so eitherwithAPrioriData(RealVector, RealMatrix)
orwithEvaluation(LeastSquaresProblem.Evaluation)
should be called, but not both as the last one called will override the previous one.A Cholesky decomposition is used to compute the weighted jacobian from the a priori covariance. This method uses the default thresholds of the decomposition.
- Parameters:
aPrioriState
- a priori state to useaPrioriCovariance
- a priori covariance to use- Returns:
- a new instance.
- See Also:
withAPrioriData(RealVector, RealMatrix, double, double)
-
withAPrioriData
public SequentialGaussNewtonOptimizer withAPrioriData(RealVector aPrioriState, RealMatrix aPrioriCovariance, double relativeSymmetryThreshold, double absolutePositivityThreshold)
Configure from a priori state and covariance.This building method generates a fake evaluation and calls
withEvaluation(LeastSquaresProblem.Evaluation)
, so eitherwithAPrioriData(RealVector, RealMatrix)
orwithEvaluation(LeastSquaresProblem.Evaluation)
should be called, but not both as the last one called will override the previous one.A Cholesky decomposition is used to compute the weighted jacobian from the a priori covariance.
- Parameters:
aPrioriState
- a priori state to useaPrioriCovariance
- a priori covariance to userelativeSymmetryThreshold
- Cholesky decomposition threshold above which off-diagonal elements are considered too different and matrix not symmetricabsolutePositivityThreshold
- Cholesky decomposition threshold below which diagonal elements are considered null and matrix not positive definite- Returns:
- a new instance.
- Since:
- 2.3
-
optimize
public LeastSquaresOptimizer.Optimum optimize(LeastSquaresProblem lsp)
Solve the non-linear least squares problem.- Specified by:
optimize
in interfaceLeastSquaresOptimizer
- Parameters:
lsp
- the problem definition, including model function and convergence criteria.- Returns:
- The optimum.
-
-